DigitalSpaces::DIList1< ListType, ListItemType > Class Template Reference
[Lists]

#include <ContainerImplementations.h>

Inherits DigitalSpaces::ListType.


Detailed Description

template<typename ListType, typename ListItemType>
class DigitalSpaces::DIList1< ListType, ListItemType >

Customisable implementation for transporting a list of interfaces.

A component implementor will not generally use this function, but rather one of the derived classes (or template instances). For the sake of simplicity, so far only DIObjectBaseList1Impl is used, since each returned object can be dss_cast as appropriate.

Example usage:

                        DigitalSpaces::DIObjectBaseList1Impl objectList;
                        pSomeInterface->GetListOfObjects( &objectList );
                        std::vector<DigitalSpaces::DIObjectBase>& listOfObjects = objectList.GetList();
                        for( std::vector< DigitalSpaces::DIObjectBase >::const_iterator itCur = listOfObjects.begin(); itCur != listOfObjects.end(); ++itCur )
                        {
                                DigitalSpaces::DInterfaceThatIsUseful* pUsefulInterface = DigitalSpaces::dss_cast< DigitalSpaces::DInterfaceThatIsUseful >(*itCur);
                                pUsefulInterface->DoSomething();
                        }

Public Types

typedef DIList1< ListType,
ListItemType > 
self_type
 Convenient typedef, used for the DImplementation convenience macro.

Public Member Functions

 DIList1 ()
 Default contructor.
 DIList1 (const DIList1 &src)
 Copy constructor.
 DIList1 (const std::list< ListItemType * > srcList)
 Construct the object, copying the items from the provided STL list.
 DIList1 (const std::vector< ListItemType * > srcVector)
 Convenience constructor allowing initialization with a STL vector instead of a list.
 ~DIList1 ()
 Generic Destructor.
std::list< ListItemType * > & GetList ()
 Returns a direct reference to the implementations collection.
Interface Functions
These functions are those required by the implemented interface.

void Restart ()
ListItemType *const GetCurrent ()
bool Advance ()
bool AtEnd ()
bool Empty ()
unsigned int Size ()
ListItemType *const GetCurrentAndAdvance ()
void PushBack (ListItemType *item)
void Clear ()

Protected Attributes

std::list< ListItemType * > m_list
 The collection this implementation is wrapping.
std::list< ListItemType * >
::iterator 
m_iterator
 Storage for "current".

Member Typedef Documentation

template<typename ListType, typename ListItemType>
typedef DIList1<ListType,ListItemType> DigitalSpaces::DIList1< ListType, ListItemType >::self_type

Convenient typedef, used for the DImplementation convenience macro.


Constructor & Destructor Documentation

template<typename ListType, typename ListItemType>
DigitalSpaces::DIList1< ListType, ListItemType >::DIList1 (  )  [inline]

Default contructor.

Initializes an empty list.

template<typename ListType, typename ListItemType>
DigitalSpaces::DIList1< ListType, ListItemType >::DIList1 ( const DIList1< ListType, ListItemType > &  src  )  [inline]

Copy constructor.

Copys the list contents, however it puts "Current" at the beginning of the copied list.

template<typename ListType, typename ListItemType>
DigitalSpaces::DIList1< ListType, ListItemType >::DIList1 ( const std::list< ListItemType * >  srcList  )  [inline]

Construct the object, copying the items from the provided STL list.

"Current" will be set to the start of the new list.

template<typename ListType, typename ListItemType>
DigitalSpaces::DIList1< ListType, ListItemType >::DIList1 ( const std::vector< ListItemType * >  srcVector  )  [inline]

Convenience constructor allowing initialization with a STL vector instead of a list.

"Current" will be set to the start of the new list.

template<typename ListType, typename ListItemType>
DigitalSpaces::DIList1< ListType, ListItemType >::~DIList1 (  )  [inline]

Generic Destructor.

No work is performed in this implementation.


Member Function Documentation

template<typename ListType, typename ListItemType>
void DigitalSpaces::DIList1< ListType, ListItemType >::Restart (  )  [inline]

Resets "current" to the first item.

Referenced by DigitalSpaces::GetFactoriesWithInterface().

template<typename ListType, typename ListItemType>
ListItemType* const DigitalSpaces::DIList1< ListType, ListItemType >::GetCurrent (  )  [inline]

template<typename ListType, typename ListItemType>
bool DigitalSpaces::DIList1< ListType, ListItemType >::Advance (  )  [inline]

Advances "current".

Returns:
False if at the end of the list. In this case, the result from GetCurrent is undefined.

Referenced by DigitalSpaces::DIList1< ListType, ListItemType >::GetCurrentAndAdvance(), and DigitalSpaces::GetFactoriesWithInterface().

template<typename ListType, typename ListItemType>
bool DigitalSpaces::DIList1< ListType, ListItemType >::AtEnd (  )  [inline]

Check if "current" is past the end of the list.

This will be the same as checking if Advance has returned false. If true, GetCurrent returns undefined answers.

Returns:
True if at the end of the list, false if not.

Referenced by DigitalSpaces::GetFactoriesWithInterface().

template<typename ListType, typename ListItemType>
bool DigitalSpaces::DIList1< ListType, ListItemType >::Empty (  )  [inline]

Check if the list is empty.

Depending on the implementation, this may be faster then calling Size and comparing to zero, particularly in cases where the list is not empty.

template<typename ListType, typename ListItemType>
unsigned int DigitalSpaces::DIList1< ListType, ListItemType >::Size (  )  [inline]

Returns the length of the list.

template<typename ListType, typename ListItemType>
ListItemType* const DigitalSpaces::DIList1< ListType, ListItemType >::GetCurrentAndAdvance (  )  [inline]

Calls GetCurrent then Advance, returning the value from GetCurrent.

This is a convenience function.

template<typename ListType, typename ListItemType>
void DigitalSpaces::DIList1< ListType, ListItemType >::PushBack ( ListItemType *  item  )  [inline]

Appends an object to the list.

template<typename ListType, typename ListItemType>
void DigitalSpaces::DIList1< ListType, ListItemType >::Clear (  )  [inline]

Removes all items from the list.

template<typename ListType, typename ListItemType>
std::list<ListItemType*>& DigitalSpaces::DIList1< ListType, ListItemType >::GetList (  )  [inline]

Returns a direct reference to the implementations collection.

This allows you to use STL functions to work with the list, rather then the more unwieldy interface functions.

Note:
Because this a reference, modifying this list (adding, removing, changing the contained value) will alter the list contained by this object.


Field Documentation

template<typename ListType, typename ListItemType>
std::list<ListItemType*> DigitalSpaces::DIList1< ListType, ListItemType >::m_list [protected]

template<typename ListType, typename ListItemType>
std::list<ListItemType*>::iterator DigitalSpaces::DIList1< ListType, ListItemType >::m_iterator [protected]


The documentation for this class was generated from the following file:

Generated on Sun Aug 31 17:46:32 2008 for Digital Spaces by  doxygen 1.5.6