NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgTaggedNamedList< T > Class Template Reference

Public Member Functions

 tgTaggedNamedList (std::vector< T > &elements)
 
std::vector< T * > find (std::string tags)
 
int size () const
 
std::vector< T * > findAll ()
 
std::vector< T * > findUntagged ()
 
bool contains (const T &needle) const
 
T & operator[] (int key)
 
const T & operator[] (int key) const
 
T & operator[] (const std::string &name)
 
T & operator+= (const T &other)
 
T & operator+= (const std::vector< T * > other)
 

Static Public Member Functions

static bool contains (std::vector< T * > haystack, const T *needle)
 

Protected Member Functions

int addElement (T element)
 
int addElement (T element, std::string name)
 
void addElements (std::vector< T * > elements)
 
void setElement (int key, T element)
 
std::vector< T > & getElements ()
 
const std::vector< T > & getElements () const
 
T & getElement (int key)
 
const T & getElement (int key) const
 
T & getElement (std::string name)
 
int setNameIndex (const std::string &name, int idx)
 
bool keyExists (int key) const
 
bool nameExists (std::string name) const
 
bool elementExists (const T &element) const
 
void assertKeyExists (int key, std::string message="Element at index does not exist") const
 
void assertNameExists (std::string name, std::string message="Name pointer does not exist") const
 
void assertNameUnused (std::string name, std::string message="Name already used") const
 
void assertUnique (T &element, std::string message="Taggable elements must be unique.")
 
void assertUniqueElements (std::string message="Taggable elements must be unique.") const
 
tgTaggable_taggable (T *obj)
 

Detailed Description

template<class T>
class tgTaggedNamedList< T >

Definition at line 38 of file tgTaggedNamedList.h.

Constructor & Destructor Documentation

template<class T >
tgTaggedNamedList< T >::tgTaggedNamedList ( std::vector< T > &  elements)
inline

Create a set of elements given a vector of T.

Parameters
[in]nodesa vector of T; the elements must be unique
Author
Lee Brownston
Date
Wed 26 Feb 2014

Definition at line 53 of file tgTaggedNamedList.h.

Member Function Documentation

template<class T >
std::vector<T*> tgTaggedNamedList< T >::find ( std::string  tags)
inline

Return a vector of pointers to Ts that have all of the specified tags.

Definition at line 65 of file tgTaggedNamedList.h.

template<class T >
bool tgTaggedNamedList< T >::keyExists ( int  key) const
inlineprotected

Is the index within range.

Parameters
[in]keyan int
Return values
trueif key is within range
falseif key is not within range

Definition at line 276 of file tgTaggedNamedList.h.

template<class T >
T& tgTaggedNamedList< T >::operator+= ( const T &  other)
inline

Remove the elements contained in 'other' from this object

Definition at line 162 of file tgTaggedNamedList.h.

template<class T >
T& tgTaggedNamedList< T >::operator[] ( int  key)
inline

Return a non-const reference to the element that is indexed by the int key. It must be in m_elements.

Parameters
[in]keythe key of the element to retrieve
Returns
a const reference to the element that is indexed by idx

Definition at line 123 of file tgTaggedNamedList.h.

template<class T >
T& tgTaggedNamedList< T >::operator[] ( const std::string &  name)
inline

Return a non-const reference to the element named by name. It must be in m_names. Note that there is no const access by name as the names are a map (since the [] operator on a map will automatically add an element, a const accessor would cause a compiler error).

Definition at line 139 of file tgTaggedNamedList.h.

template<class T >
int tgTaggedNamedList< T >::setNameIndex ( const std::string &  name,
int  idx 
)
inlineprotected

Set the index to which a name points.

Definition at line 264 of file tgTaggedNamedList.h.


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