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 >:

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 ()
 
- Public Member Functions inherited from frepple::utils::Tree::TreeNode
TreeNodedecrement () const
 
const string & getName () const
 
TreeNodeincrement () const
 
bool operator< (const TreeNode &o)
 
 TreeNode (const string &n)
 
virtual ~TreeNode ()
 
- Public Member Functions inherited from frepple::utils::Object
virtual void beginElement (XMLInput &, const Attribute &)
 
virtual bool getHidden () const
 
virtual size_t getSize () const =0
 
virtual const MetaClassgetType () const =0
 
 Object ()
 
virtual void setHidden (bool b)
 
virtual void writeElement (XMLOutput *, const Keyword &, mode=DEFAULT) const
 
virtual ~Object ()
 
- Public Member Functions inherited from frepple::utils::PythonExtensionBase
virtual PyObject * call (const PythonObject &args, const PythonObject &kwds)
 
virtual PyObject * getattro (const Attribute &attr)
 
Py_ssize_t getReferenceCount () const
 
void initType (const MetaClass *t)
 
void initType (PyTypeObject *t)
 
virtual PyObject * iternext ()
 
 PythonExtensionBase ()
 
void resetReferenceCount ()
 
virtual int setattro (const Attribute &attr, const PythonObject &field)
 
virtual ~PythonExtensionBase ()
 

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)
 
- Static Public Member Functions inherited from frepple::utils::Object
template<class T >
static PyObject * create (PyTypeObject *pytype, PyObject *args, PyObject *kwds)
 
template<class T >
static ObjectcreateDefault ()
 
template<class T >
static ObjectcreateString (const string &n)
 
static PyObject * toXML (PyObject *, PyObject *)
 

Additional Inherited Members

- Protected Member Functions inherited from frepple::utils::NonCopyable
 NonCopyable ()
 
 ~NonCopyable ()
 
- Static Protected Member Functions inherited from frepple::utils::PythonExtensionBase
static PythonTyperegisterPythonType (int, const type_info *)
 
- Static Protected Attributes inherited from frepple::utils::PythonExtensionBase
static vector< PythonType * > table
 

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 4697 of file utils.h.

Constructor & Destructor Documentation

template<class T>
frepple::utils::HasName< T >::HasName ( const string &  n)
inlineexplicit

Constructor.

Definition at line 4782 of file utils.h.

template<class T>
frepple::utils::HasName< T >::HasName ( const char *  n)
inlineexplicit

Constructor.

Definition at line 4785 of file utils.h.

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

Destructor.

Definition at line 4791 of file utils.h.

Member Function Documentation

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

Creates a new entity.

Definition at line 4822 of file utils.h.

template<class T>
static T* frepple::utils::HasName< T >::add ( T *  t)
inlinestatic

Registers an entity created by the default constructor.

Definition at line 4835 of file utils.h.

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

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 4841 of file utils.h.

template<class T>
static iterator frepple::utils::HasName< T >::begin ( )
inlinestatic

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

Definition at line 4766 of file utils.h.

template<class T>
static void frepple::utils::HasName< T >::clear ( )
inlinestatic

Deletes all elements from the list.

Definition at line 4779 of file utils.h.

template<class T>
int frepple::utils::HasName< T >::compare ( const PyObject *  other) const
inlinevirtual

Comparison operator for Python.

Reimplemented from frepple::utils::PythonExtensionBase.

Definition at line 4797 of file utils.h.

template<class T>
static bool frepple::utils::HasName< T >::empty ( )
inlinestatic

Returns false if no named entities have been defined yet.

Definition at line 4769 of file utils.h.

template<class T>
static iterator frepple::utils::HasName< T >::end ( )
inlinestatic

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

Definition at line 4763 of file utils.h.

template<class T>
void frepple::utils::HasName< T >::endElement ( XMLInput ,
const Attribute ,
const DataElement  
)
inlinevirtual

Called while restoring the model from an XML-file.
This is called when the corresponding close element tag is encountered, and the Data() member of pElement is valid.

Implements frepple::utils::Object.

Reimplemented in frepple::utils::HasHierarchy< T >, frepple::utils::HasHierarchy< Item >, frepple::utils::HasHierarchy< Location >, frepple::utils::HasHierarchy< Demand >, frepple::utils::HasHierarchy< Customer >, frepple::utils::HasHierarchy< Resource >, and frepple::utils::HasHierarchy< Buffer >.

Definition at line 4843 of file utils.h.

template<class T>
static T* frepple::utils::HasName< T >::find ( const string &  k)
inlinestatic

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

Definition at line 4804 of file utils.h.

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

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 4815 of file utils.h.

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

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 4862 of file utils.h.

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

Rename the entity.

Definition at line 4788 of file utils.h.

template<class T>
static size_t frepple::utils::HasName< T >::size ( )
inlinestatic

Returns the number of defined entities.

Definition at line 4772 of file utils.h.

template<class T>
virtual PyObject* frepple::utils::HasName< T >::str ( ) const
inlinevirtual

Return the name as the string representation in Python.

Reimplemented from frepple::utils::PythonExtensionBase.

Definition at line 4794 of file utils.h.

template<class T>
static void frepple::utils::HasName< T >::verify ( )
inlinestatic

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

Definition at line 4776 of file utils.h.

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

A handler that is used to persist the tree.

Definition at line 4957 of file utils.h.


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