faudes::TypeRegistry Class Reference
[Run-Time Interface]

The TypeRegistry registers faudes-types. More...

#include <cfl_registry.h>

List of all members.

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.
void ClearAll ()
 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.
void XElementTag (const std::string &rTypeName, const std::string &rTag)
 Set Xml element tag for given faudes-type.
const std::string & XElementTag (const std::string &rTypeName) const
 Get Xml element tag for given faudes-type.
bool AutoRegistered (const std::string &rTypeName) const
 Get AutoRegister flag for given faudes-type.
void AutoRegistered (const std::string &rTypeName, bool flag)
 Set AutoRegistered flag for given faudes-type.
TypeNewObject (const std::string &rTypeName) const
 Construct a faudes object by type name.
TypeNewObject (const Type &rType) const
 Construct a faudes object by prototype object.
const TypeDefinitionDefinition (const std::string &rTypeName) const
 Look up the type definition by faudes-type name.
const TypeDefinitionDefinition (const Type &rType) const
 Look up the type definition by faudes object.
const TypeDefinitionDefinitionp (const std::string &rTypeName) const
 Look up the type definition by faudes-type name.
const TypeDefinitionDefinitionp (const Type &rType) const
 Look up the type definition by faudes object.
const TypePrototype (const std::string &rTypeName) const
 Look up the prototype object by faudes-type name.
const std::string & TypeName (const Type &rType) const
 Look up the type name by faudes object.
bool TypeTest (const std::string &rTypeName, const Type &rObject) const
 Test type compatibility.

Static Public Member Functions

static TypeRegistryG ()
 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 TypeRegistrympInstance = 0
 Singleton instance.

Detailed Description

The TypeRegistry registers faudes-types.

A faudes-type may be any class derived from faudes::Type, e.g. EventSet and generator. The registry maintains a mapping from faudes-type names to registred faudes::TypeDefinition. It provides an interface to inspect TypeDefinitions or to construct faudes-type objects by their type name.

Technical note: the class is implemented according to the "Singleton" design pattern, ie, only one global instance of the registry can exist.

Definition at line 47 of file cfl_registry.h.


Member Typedef Documentation

typedef std::map<std::string, TypeDefinition*>::iterator faudes::TypeRegistry::iterator [protected]

Convenience typedef to access registry entries.

Definition at line 416 of file cfl_registry.h.

typedef std::map<std::string, TypeDefinition*>::const_iterator faudes::TypeRegistry::Iterator

Convenience typedef to access registry entries.

Definition at line 52 of file cfl_registry.h.


Constructor & Destructor Documentation

faudes::TypeRegistry::TypeRegistry (  )  [inline, protected]

Constructor.

Definition at line 422 of file cfl_registry.h.

virtual faudes::TypeRegistry::~TypeRegistry (  )  [inline, protected, virtual]

Destructor.

Definition at line 425 of file cfl_registry.h.


Member Function Documentation

void faudes::TypeRegistry::AutoRegistered ( const std::string &  rTypeName,
bool  flag 
)

Set AutoRegistered flag for given faudes-type.

Access the AutoRegister flag of a type definition. The flag is true for entries with were instantiated by automatically by static constructor objects. AutoRegistered flags will not be cleared.

Parameters:
rTypeName Name of faudes-type
flag New value of flag

Definition at line 224 of file cfl_registry.cpp.

bool faudes::TypeRegistry::AutoRegistered ( const std::string &  rTypeName  )  const

Get AutoRegister flag for given faudes-type.

Access the AutoRegister flag of a type definition. The flag is true for entries which were instantiated automatically by static constructor objects. AutoRegistered flags will not be cleared.

Parameters:
rTypeName Name of faudes-type
Returns:
AutoRegister flag

Definition at line 234 of file cfl_registry.cpp.

TypeRegistry::Iterator faudes::TypeRegistry::Begin ( void   )  const

STL interator to the internal type-name map.

Returns:
Iterator to the first element.

Definition at line 123 of file cfl_registry.cpp.

void faudes::TypeRegistry::Clear ( void   )  [virtual]

Clear all registered type definitions.

This will also delete the correponsing prototype objects. It will, however, not delete C++-autoregistered registry entries.

Reimplemented from faudes::Type.

Definition at line 68 of file cfl_registry.cpp.

void faudes::TypeRegistry::ClearAll ( void   ) 

Clear all registered type definitions.

This will also delete the correponsing prototype objects. This version will also delete C++-autoregistered registry entries.

Definition at line 102 of file cfl_registry.cpp.

const TypeDefinition & faudes::TypeRegistry::Definition ( const Type rType  )  const

Look up the type definition by faudes object.

Parameters:
rType Reference to faudes::Type to search for.
Returns:
Reference to faudes::TypeDefinition
Exceptions:
Exception 
  • Unknown type (id 46)

Definition at line 285 of file cfl_registry.cpp.

const TypeDefinition & faudes::TypeRegistry::Definition ( const std::string &  rTypeName  )  const

Look up the type definition by faudes-type name.

Parameters:
rTypeName Faudes-tyep name to search for.
Returns:
Reference to faudes::TypeDefinition
Exceptions:
Exception 
  • Unknown type (id 46)

Definition at line 273 of file cfl_registry.cpp.

const TypeDefinition * faudes::TypeRegistry::Definitionp ( const Type rType  )  const

Look up the type definition by faudes object.

Parameters:
rType Reference to faudes::Type to search for.
Returns:
Pointer to faudes::TypeDefinition, NULL for unknoen type.

Definition at line 304 of file cfl_registry.cpp.

const TypeDefinition * faudes::TypeRegistry::Definitionp ( const std::string &  rTypeName  )  const

Look up the type definition by faudes-type name.

Parameters:
rTypeName Faudes-tyep name to search for.
Returns:
Pointer to faudes::TypeDefinition, NULL for unknoen type.

Definition at line 296 of file cfl_registry.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.

Parameters:
rTw Reference to TokenWriter
rLabel Label of section to write
pContext Write context to provide contextual information
Exceptions:
Exception 
  • IO errors (id 2)

Reimplemented from faudes::Type.

Definition at line 353 of file cfl_registry.cpp.

TypeRegistry::Iterator faudes::TypeRegistry::End ( void   )  const

STL interator to the internal type-name map.

Returns:
Iterator to the end of the map.

Definition at line 128 of file cfl_registry.cpp.

bool faudes::TypeRegistry::Exists ( const Type rType  )  const

Test existence of a faudes-type by faudes object.

Parameters:
rType Object of type to look up
Returns:
True, if a corresponding definition is registered.

Definition at line 347 of file cfl_registry.cpp.

bool faudes::TypeRegistry::Exists ( const std::string &  rName  )  const

Test existence of a faudes-type by its name.

Parameters:
rName Name of type to look up
Returns:
True, if a corresponding definition is registered.

Definition at line 342 of file cfl_registry.cpp.

TypeRegistry * faudes::TypeRegistry::G ( void   )  [static]

Method to access the single global instance of the registry.

Definition at line 58 of file cfl_registry.cpp.

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.

Parameters:
pProto Prototype object
rTypeName Specify the faudes-type name
Exceptions:
Exception 
  • Identical name found (id 46)

Definition at line 172 of file cfl_registry.h.

template<class T >
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.

Template Parameters:
T Template parameter to specify c++ type to register
Parameters:
rTypeName Specify the faudes-type name
Exceptions:
Exception 
  • Identical name found (id 46)

Definition at line 151 of file cfl_registry.h.

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. The insertion of an allready registered type is ignored as long as the ctype matches. If the ctype fails to match, an exception is thrown.

Parameters:
pTypeDef Type definition to insert
Exceptions:
Exception 
  • Identical name found (id 46)

Definition at line 133 of file cfl_registry.cpp.

void faudes::TypeRegistry::MergeDocumentation ( const std::string &  rFileName  ) 

Scan file for type documentation.

Convenience method, see also MergeDocumentation(TokenReader& rTr)

Parameters:
rFileName Name of file to scan.
Exceptions:
Exception 
  • Token mismatch (id 50, 51, 52)
  • IO Error (id 1)

Definition at line 201 of file cfl_registry.cpp.

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");
Parameters:
rTr Token stream.
Exceptions:
Exception 
  • Token mismatch (id 50, 51, 52)
  • IO Error (id 1)

Definition at line 172 of file cfl_registry.cpp.

Type * faudes::TypeRegistry::NewObject ( const Type rType  )  const

Construct a faudes object by prototype object.

Depreciated: use new on the faudes object instead.

Parameters:
rType Prototype object.
Returns:
Pointer to new faudes::Type instance
Exceptions:
Exception 
  • Unknown type (id 47)

Definition at line 260 of file cfl_registry.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.

Parameters:
rTypeName Label of TypeDefinition to search for.
Returns:
Pointer to new faudes::Type instance
Exceptions:
Exception 
  • Unknown type (id 47)

Definition at line 242 of file cfl_registry.cpp.

const Type * faudes::TypeRegistry::Prototype ( const std::string &  rTypeName  )  const

Look up the prototype object by faudes-type name.

Parameters:
rTypeName Label of faudes::TypeDefinition to search for.
Returns:
Reference to faudes::Type object, Null for unknown type

Definition at line 313 of file cfl_registry.cpp.

int faudes::TypeRegistry::Size ( void   )  const

Return number of registered type definitions.

Returns:
Size of map.

Definition at line 118 of file cfl_registry.cpp.

const std::string & faudes::TypeRegistry::TypeName ( const Type rType  )  const

Look up the type name by faudes object.

Parameters:
rType Reference to faudes::Type to search for.
Returns:
Type name as string or "" if unknown.

Definition at line 321 of file cfl_registry.cpp.

bool faudes::TypeRegistry::TypeTest ( const std::string &  rTypeName,
const Type rObject 
) const

Test type compatibility.

Test whether the provided object can be casted to the specified type name,

Parameters:
rTypeName Faudes type name
rObject Faudes object instance
Returns:
True, if object can be casted to specified faudes type.

Definition at line 331 of file cfl_registry.cpp.

const std::string & faudes::TypeRegistry::XElementTag ( const std::string &  rTypeName  )  const

Get Xml element tag for given faudes-type.

Access to the XElementTag of a type definition. The latter is used for Xml token IO of sets and vectors. Unregistered types return the empty string.

Parameters:
rTypeName Name of faudes-type
Returns:
Xml element tag

Definition at line 215 of file cfl_registry.cpp.

void faudes::TypeRegistry::XElementTag ( const std::string &  rTypeName,
const std::string &  rTag 
)

Set Xml element tag for given faudes-type.

Access to the XElementTag of a type definition. The latter is used for Xml token IO of sets and vectors. Unregistered types are silently ignored.

Parameters:
rTypeName Name of faudes-type
rTag New value of tag

Definition at line 208 of file cfl_registry.cpp.


Member Data Documentation

std::map<std::string, TypeDefinition*> faudes::TypeRegistry::mIdToTypeDef [protected]

Definition at line 431 of file cfl_registry.h.

std::map<std::string, TypeDefinition*> faudes::TypeRegistry::mNameToTypeDef [protected]

Map to associate labels and faudes::TypeDefinitions.

Definition at line 430 of file cfl_registry.h.

Singleton instance.

Definition at line 419 of file cfl_registry.h.


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

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen