| |
libFAUDES
Sections
Index
|
faudes::TypeRegistry Class Reference |
Public Types | |
typedef std::map< std::string, TypeDefinition * > ::const_iterator | Iterator |
Convenience typedef to access registry entries. | |
Public Member Functions | |
void | Clear () |
Clear all registered type definitions. | |
int | Size () const |
Return number of registered type definitions. | |
bool | Exists (const std::string &rName) const |
Test existence of a faudes-type by its name. | |
bool | Exists (const Type &rType) const |
Test existence of a faudes-type by faudes object. | |
Iterator | Begin (void) const |
STL interator to the internal type-name map. | |
Iterator | End (void) const |
STL interator to the internal type-name map. | |
void | Insert (TypeDefinition *pTypeDef) |
Add another type definition to the registry. | |
template<class T> | |
void | Insert (const std::string &rTypeName="") |
Register a faudes-type with specified type name. | |
void | Insert (Type *pProto, const std::string &rTypeName) |
Register a faudes-type with specified type name. | |
void | MergeDocumentation (TokenReader &rTr) |
Scan token input for type documentation. | |
void | MergeDocumentation (const std::string &rFileName) |
Scan file for type documentation. | |
Type * | NewObject (const std::string &rTypeName) const |
Construct a faudes object by type name. | |
Type * | NewObject (const Type &rType) const |
Construct a faudes object by prototype object. | |
const TypeDefinition & | Definition (const std::string &rTypeName) const |
Look up the type definition by faudes-type name. | |
const TypeDefinition & | Definition (const Type &rType) const |
Look up the type definition by faudes object. | |
const std::string & | TypeName (const Type &rType) const |
Look up the type name by faudes object. | |
Static Public Member Functions | |
static TypeRegistry * | G () |
Method to access the single global instance of the registry. | |
Protected Types | |
typedef std::map< std::string, TypeDefinition * >::iterator | iterator |
Convenience typedef to access registry entries. | |
Protected Member Functions | |
virtual void | DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const |
Write registry data of this to TokenWriter. | |
TypeRegistry () | |
Constructor. | |
virtual | ~TypeRegistry () |
Destructor. | |
Protected Attributes | |
std::map< std::string, TypeDefinition * > | mNameToTypeDef |
Map to associate labels and faudes::TypeDefinitions. | |
std::map< std::string, TypeDefinition * > | mIdToTypeDef |
Static Protected Attributes | |
static TypeRegistry * | mpInstance = 0 |
Singleton instance. |
typedef std::map<std::string, TypeDefinition*>::const_iterator faudes::TypeRegistry::Iterator |
typedef std::map<std::string, TypeDefinition*>::iterator faudes::TypeRegistry::iterator [protected] |
faudes::TypeRegistry::TypeRegistry | ( | ) | [inline, protected] |
virtual faudes::TypeRegistry::~TypeRegistry | ( | ) | [inline, protected, virtual] |
TypeRegistry * faudes::TypeRegistry::G | ( | ) | [static] |
Method to access the single global instance of the registry.
Definition at line 55 of file rtiregistry.cpp.
void faudes::TypeRegistry::Clear | ( | void | ) | [virtual] |
Clear all registered type definitions.
This will also delete the correponsing prototype objects.
Reimplemented from faudes::Type.
Definition at line 65 of file rtiregistry.cpp.
int faudes::TypeRegistry::Size | ( | void | ) | const |
Return number of registered type definitions.
Definition at line 80 of file rtiregistry.cpp.
bool faudes::TypeRegistry::Exists | ( | const std::string & | rName | ) | const |
Test existence of a faudes-type by its name.
rName | Name of type to look up |
Definition at line 215 of file rtiregistry.cpp.
bool faudes::TypeRegistry::Exists | ( | const Type & | rType | ) | const |
Test existence of a faudes-type by faudes object.
rType | Object of type to look up |
Definition at line 220 of file rtiregistry.cpp.
TypeRegistry::Iterator faudes::TypeRegistry::Begin | ( | void | ) | const |
STL interator to the internal type-name map.
Definition at line 85 of file rtiregistry.cpp.
TypeRegistry::Iterator faudes::TypeRegistry::End | ( | void | ) | const |
STL interator to the internal type-name map.
Definition at line 90 of file rtiregistry.cpp.
void faudes::TypeRegistry::Insert | ( | TypeDefinition * | pTypeDef | ) |
Add another type definition to the registry.
The registry takes the ownership pf the provided type definition. It will be deleted either in Clear() or when the registry is destructed.
pTypeDef | Type definition to insert |
Exception |
|
Definition at line 95 of file rtiregistry.cpp.
void faudes::TypeRegistry::Insert | ( | const std::string & | rTypeName = "" |
) | [inline] |
Register a faudes-type with specified type name.
This is a convenience function: it uses the template parameter to construct the new instance of TypeDefinition to be registered. However, no documentation is added. See also MergeDocumentation.
T | Template parameter to specify c++ type to register |
rTypeName | Specify the faudes-type name |
Exception |
|
Definition at line 141 of file rtiregistry.h.
void faudes::TypeRegistry::Insert | ( | Type * | pProto, | |
const std::string & | rTypeName | |||
) | [inline] |
Register a faudes-type with specified type name.
This is a convenience function: it uses the specified object as a a prototype and registers it under the given name. The registry takes ownership of the prototype. However, no documentation is added. See also MergeDocumentation.
pProto | Prototype object | |
rTypeName | Specify the faudes-type name |
Exception |
|
Definition at line 162 of file rtiregistry.h.
void faudes::TypeRegistry::MergeDocumentation | ( | TokenReader & | rTr | ) |
Scan token input for type documentation.
This function scans the entire token stream for sections with label "TypeDefinition". Any such section that refers to a type name which is known to the registry, will be applied to the corresponding registry entry. Typical invokation is as follows
TypeRegistry::G()->Insert<EventSet>("EventSet"); TypeRegistry::G()->Insert<Generator>("Generator"); TypeRegistry::G()->MergeDocumentation("alldocufile.rti");
rTr | Token stream. |
Definition at line 112 of file rtiregistry.cpp.
void faudes::TypeRegistry::MergeDocumentation | ( | const std::string & | rFileName | ) |
Scan file for type documentation.
Convenience method, see also MergeDocumentation(TokenReader& rTr)
rFileName | Name of file to scan. |
Definition at line 144 of file rtiregistry.cpp.
Type * faudes::TypeRegistry::NewObject | ( | const std::string & | rTypeName | ) | const |
Construct a faudes object by type name.
Uses the internal prototype object to construct an object of the same c type on the heap.
rTypeName | Label of TypeDefinition to search for. |
Exception |
|
Definition at line 151 of file rtiregistry.cpp.
Construct a faudes object by prototype object.
Depreciated: use new on the faudes object instead.
rType | Prototype object. |
Exception |
|
Definition at line 169 of file rtiregistry.cpp.
const TypeDefinition & faudes::TypeRegistry::Definition | ( | const std::string & | rTypeName | ) | const |
Look up the type definition by faudes-type name.
rTypeName | Label of faudes::TypeDefinition to search for. |
Exception |
|
Definition at line 182 of file rtiregistry.cpp.
const TypeDefinition & faudes::TypeRegistry::Definition | ( | const Type & | rType | ) | const |
Look up the type definition by faudes object.
Techcal note: this implementation is slow, we should use a type id map.
rType | Reference to faudes::Type to search for. |
Exception |
|
Definition at line 194 of file rtiregistry.cpp.
const std::string & faudes::TypeRegistry::TypeName | ( | const Type & | rType | ) | const |
Look up the type name by faudes object.
rType | Reference to faudes::Type to search for. |
Definition at line 205 of file rtiregistry.cpp.
void faudes::TypeRegistry::DoWrite | ( | TokenWriter & | rTw, | |
const std::string & | rLabel = "" , |
|||
const Type * | pContext = 0 | |||
) | const [protected, virtual] |
Write registry data of this to TokenWriter.
Since the registry cannot reconfigure itself from a token stream, this output is informative only. However, MergeDocumentation will accept the format to extract documentation.
rTw | Reference to TokenWriter | |
rLabel | Label of section to write | |
pContext | Write context to provide contextual information |
Exception |
|
Reimplemented from faudes::Type.
Definition at line 226 of file rtiregistry.cpp.
TypeRegistry * faudes::TypeRegistry::mpInstance = 0 [static, protected] |
std::map<std::string, TypeDefinition*> faudes::TypeRegistry::mNameToTypeDef [protected] |
std::map<std::string, TypeDefinition*> faudes::TypeRegistry::mIdToTypeDef [protected] |
Definition at line 312 of file rtiregistry.h.
libFAUDES 2.14g --- 2009-12-3 --- c++ source docu by doxygen 1.5.6