Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT > Class Template Reference#include <InstanceTracker.h>
Inheritance diagram for InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >:
![]() Detailed Descriptiontemplate<class FamilyT, typename ClassNameT = std::string, class FactoryBaseT = Factory1Arg<FamilyT,std::string>, template< class U > class FactoryT = FactoryBaseT::template Factory>
Attempts to provide references to all currently instantiated objects of a class (and its subclasses).
|
Public Types | |
typedef plist::Dictionary::iterator | iterator |
shorthand for iterators to be returned | |
typedef plist::Dictionary::const_iterator | const_iterator |
shorthand for iterators to be returned | |
typedef FamilyT | FamilyType |
allows indirect access to the product family type | |
typedef ClassNameT | ClassNameType |
allows indirect access to the product class name type | |
typedef FactoryBaseT | FactoryBaseType |
allows indirect access to the factory base class | |
Public Member Functions | |
InstanceTracker () | |
constructor | |
template<class T> | |
bool | registerInstance (const std::string &name, T &inst) |
Register an existing instance via reference, does not assume responsibility for memory deallocation, returns false if name is already in use. | |
template<class T> | |
bool | registerInstance (const std::string &name, T *inst) |
Register an existing instance via pointer, does assume responsibility for memory deallocation, returns false if name is already in use. | |
template<class T> | |
bool | registerInstance (const ClassNameT &type, const std::string &name, T &inst) |
Register an existing instance via reference, does not assume responsibility for memory deallocation, returns false if name is already in use. | |
template<class T> | |
bool | registerInstance (const ClassNameT &type, const std::string &name, T *inst) |
Register an existing instance via pointer, does assume responsibility for memory deallocation, returns false if name is already in use. | |
FamilyT * | create (const ClassNameType &type, const std::string &name) |
create and register an instance in one call | |
FamilyT * | getInstance (const std::string &name) |
looks up a previously registered instance, returning NULL if not found | |
bool | destroy (const std::string &name) |
Removes an instance from the tracker. | |
void | loadXML (xmlNode *node) |
From the name of node, will instantiate a new ObjectBase subclass to load it. | |
Private Member Functions | |
InstanceTracker (const InstanceTracker &) | |
copy constructor, don't call | |
InstanceTracker & | operator= (const InstanceTracker &) |
assignment, don't call | |
Classes | |
struct | FactoryType |
allows indirect access to create factory classes More... | |
class | InstanceEntry |
Provides a wrapper for non-plistDictionary entries. More... |
typedef plist::Dictionary::iterator InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::iterator |
shorthand for iterators to be returned
Reimplemented from plist::DictionaryBase.
Definition at line 19 of file InstanceTracker.h.
typedef plist::Dictionary::const_iterator InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::const_iterator |
shorthand for iterators to be returned
Reimplemented from plist::DictionaryBase.
Definition at line 21 of file InstanceTracker.h.
typedef FamilyT InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::FamilyType |
allows indirect access to the product family type
Reimplemented from FamilyFactory< FamilyT, ClassNameT, FactoryBaseT, FactoryT >.
Definition at line 24 of file InstanceTracker.h.
typedef ClassNameT InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::ClassNameType |
allows indirect access to the product class name type
Definition at line 26 of file InstanceTracker.h.
typedef FactoryBaseT InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::FactoryBaseType |
allows indirect access to the factory base class
Reimplemented from FamilyFactory< FamilyT, ClassNameT, FactoryBaseT, FactoryT >.
Definition at line 28 of file InstanceTracker.h.
InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::InstanceTracker | ( | ) | [inline] |
InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::InstanceTracker | ( | const InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT > & | ) | [private] |
copy constructor, don't call
bool InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::registerInstance | ( | const std::string & | name, | |
T & | inst | |||
) | [inline] |
Register an existing instance via reference, does not assume responsibility for memory deallocation, returns false if name is already in use.
Definition at line 93 of file InstanceTracker.h.
Referenced by InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::create().
bool InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::registerInstance | ( | const std::string & | name, | |
T * | inst | |||
) | [inline] |
Register an existing instance via pointer, does assume responsibility for memory deallocation, returns false if name is already in use.
Definition at line 107 of file InstanceTracker.h.
bool InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::registerInstance | ( | const ClassNameT & | type, | |
const std::string & | name, | |||
T & | inst | |||
) | [inline] |
Register an existing instance via reference, does not assume responsibility for memory deallocation, returns false if name is already in use.
If type is not an empty string, and inst is a plist::Dictionary, a '.type' entry will be added to store the type. This allows polymorphic loading. Non-dictionaries will be wrapped in a new plist::Dictionary with a '.type'.
Definition at line 118 of file InstanceTracker.h.
bool InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::registerInstance | ( | const ClassNameT & | type, | |
const std::string & | name, | |||
T * | inst | |||
) | [inline] |
Register an existing instance via pointer, does assume responsibility for memory deallocation, returns false if name is already in use.
If type is not an empty string, and inst is a plist::Dictionary, a '.type' entry will be added to store the type. This allows polymorphic loading. Non-dictionaries will be wrapped in a new plist::Dictionary with a '.type'.
Definition at line 136 of file InstanceTracker.h.
FamilyT * InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::create | ( | const ClassNameType & | type, | |
const std::string & | name | |||
) | [inline] |
create and register an instance in one call
Definition at line 149 of file InstanceTracker.h.
Referenced by InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::loadXML().
FamilyT * InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::getInstance | ( | const std::string & | name | ) | [inline] |
looks up a previously registered instance, returning NULL if not found
Definition at line 160 of file InstanceTracker.h.
bool InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::destroy | ( | const std::string & | name | ) | [inline] |
Removes an instance from the tracker.
If the tracker was managing the memory allocation (via create() or the registerInstance() functions which take a pointer instead of a reference), then this will cause the instance to be deallocated.
Definition at line 170 of file InstanceTracker.h.
Referenced by InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::loadXML().
void InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::loadXML | ( | xmlNode * | node | ) | [inline, virtual] |
From the name of node, will instantiate a new ObjectBase subclass to load it.
The mapping from node names to actual instantiated types is:
If successful, returns a pointer to a newly allocated region, which the caller is responsible for freeing. If an error occurs, NULL is returned.
Reimplemented from plist::DictionaryBase.
Definition at line 179 of file InstanceTracker.h.
InstanceTracker& InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT >::operator= | ( | const InstanceTracker< FamilyT, ClassNameT, FactoryBaseT, FactoryT > & | ) | [private] |
assignment, don't call
Tekkotsu v4.0 |
Generated Thu Nov 22 00:58:26 2007 by Doxygen 1.5.4 |