frepple::utils::HasName< T > Class Template Reference

Base class for objects using a string as their primary key. More...

#include <utils.h>

Inheritance diagram for frepple::utils::HasName< T >:

List of all members.

Classes

class  iterator
 This class models a STL-like iterator that allows us to iterate over the named entities in a simple and safe way. More...

Public Member Functions

int compare (const PyObject *other) const
void endElement (XMLInput &pIn, const Attribute &pAttr, const DataElement &pElement)
 HasName (const string &n)
 HasName (const char *n)
void setName (const string &newname)
virtual PyObject * str () const
 ~HasName ()

Static Public Member Functions

static T * add (const string &k, const MetaClass &cls)
static T * add (T *t)
static T * add (T *t, T *hint)
static iterator begin ()
static void clear ()
static bool empty ()
static iterator end ()
static T * find (const string &k)
static T * findLowerBound (const string &k, bool *f=NULL)
static Objectreader (const MetaClass *cat, const AttributeList &in)
static size_t size ()
static void verify ()
static void writer (const MetaCategory *c, XMLOutput *o)

Detailed Description

template<class T>
class frepple::utils::HasName< T >

Base class for objects using a string as their primary key.

Instances of this class have the following properties:

  • Have a unique name.
  • A hashtable (keyed on the name) is maintained as a container with all active instances.

Definition at line 4572 of file utils.h.


Constructor & Destructor Documentation

template<class T>
frepple::utils::HasName< T >::HasName ( const string &  n) [inline, explicit]

Constructor.

Definition at line 4658 of file utils.h.

template<class T>
frepple::utils::HasName< T >::HasName ( const char *  n) [inline, explicit]

Constructor.

Definition at line 4661 of file utils.h.

template<class T>
frepple::utils::HasName< T >::~HasName ( ) [inline]

Destructor.

Definition at line 4667 of file utils.h.


Member Function Documentation

template<class T>
static T* frepple::utils::HasName< T >::add ( const string &  k,
const MetaClass cls 
) [inline, static]

Creates a new entity.

Definition at line 4706 of file utils.h.

template<class T>
static T* frepple::utils::HasName< T >::add ( T *  t) [inline, static]

Registers an entity created by the default constructor.

Definition at line 4719 of file utils.h.

template<class T>
static T* frepple::utils::HasName< T >::add ( T *  t,
T *  hint 
) [inline, static]

Registers an entity created by the default constructor. The second argument is a hint: when passing an entity with a name close to the new one, the insertion will be sped up considerably.

Definition at line 4725 of file utils.h.

template<class T>
static iterator frepple::utils::HasName< T >::begin ( ) [inline, static]

Returns a STL-like iterator to the start of the entity list.

Definition at line 4642 of file utils.h.

template<class T>
static void frepple::utils::HasName< T >::clear ( ) [inline, static]

Deletes all elements from the list.

Definition at line 4655 of file utils.h.

template<class T>
int frepple::utils::HasName< T >::compare ( const PyObject *  other) const [inline, virtual]

Comparison operator for Python.

Reimplemented from frepple::utils::PythonExtensionBase.

Definition at line 4673 of file utils.h.

template<class T>
static bool frepple::utils::HasName< T >::empty ( ) [inline, static]

Returns false if no named entities have been defined yet.

Definition at line 4645 of file utils.h.

template<class T>
static iterator frepple::utils::HasName< T >::end ( ) [inline, static]

Returns a STL-like iterator to the end of the entity list.

Definition at line 4639 of file utils.h.

template<class T>
static T* frepple::utils::HasName< T >::find ( const string &  k) [inline, static]

Find an entity given its name. In case it can't be found, a NULL pointer is returned.

Definition at line 4688 of file utils.h.

template<class T>
static T* frepple::utils::HasName< T >::findLowerBound ( const string &  k,
bool *  f = NULL 
) [inline, static]

Find the element with this given key or the element immediately preceding it.
The optional second argument is a boolean that is set to true when the element is found in the list.

Definition at line 4699 of file utils.h.

template<class T>
static Object* frepple::utils::HasName< T >::reader ( const MetaClass cat,
const AttributeList in 
) [inline, static]

This method is available as a object creation factory for classes that are using a string as a key identifier, in particular classes derived from the HasName base class. The following attributes are recognized:

  • name:
    Name of the entity to be created/changed/removed.
    The default value is "unspecified".
  • type:
    Determines the subclass to be created.
    The default value is "default".
  • action:
    Determines the action to be performed on the object.
    This can be A (for 'add'), C (for 'change'), AC (for 'add_change') or R (for 'remove').
    'add_change' is the default value.
    See also:
    HasName

Definition at line 4746 of file utils.h.

template<class T>
void frepple::utils::HasName< T >::setName ( const string &  newname) [inline]

Rename the entity.

Definition at line 4664 of file utils.h.

template<class T>
static size_t frepple::utils::HasName< T >::size ( ) [inline, static]

Returns the number of defined entities.

Definition at line 4648 of file utils.h.

template<class T>
virtual PyObject* frepple::utils::HasName< T >::str ( ) const [inline, virtual]

Return the name as the string representation in Python.

Reimplemented from frepple::utils::PythonExtensionBase.

Definition at line 4670 of file utils.h.

template<class T>
static void frepple::utils::HasName< T >::verify ( ) [inline, static]

Debugging method to verify the validity of the tree. An exception is thrown when the tree is corrupted.

Definition at line 4652 of file utils.h.

template<class T>
static void frepple::utils::HasName< T >::writer ( const MetaCategory c,
XMLOutput o 
) [inline, static]

A handler that is used to persist the tree.

Definition at line 4841 of file utils.h.


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

Documentation generated for frePPLe by  doxygen