#include <cfl_registry.h>

Public Types

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

Public Member Functions

void Clear ()
 
void ClearAll ()
 
int Size () const
 
bool Exists (const std::string &rName) const
 
bool Exists (const Type &rType) const
 
Iterator Begin (void) const
 
Iterator End (void) const
 
void Insert (TypeDefinition *pTypeDef)
 
template<class T >
void Insert (const std::string &rTypeName="")
 
void Insert (Type *pProto, const std::string &rTypeName)
 
void MergeDocumentation (TokenReader &rTr)
 
void MergeDocumentation (const std::string &rFileName)
 
void XElementTag (const std::string &rTypeName, const std::string &rTag)
 
const std::string & XElementTag (const std::string &rTypeName) const
 
bool AutoRegistered (const std::string &rTypeName) const
 
void AutoRegistered (const std::string &rTypeName, bool flag)
 
TypeNewObject (const std::string &rTypeName) const
 
TypeNewObject (const Type &rType) const
 
const TypeDefinitionDefinition (const std::string &rTypeName) const
 
const TypeDefinitionDefinition (const Type &rType) const
 
const TypeDefinitionDefinitionp (const std::string &rTypeName) const
 
const TypeDefinitionDefinitionp (const Type &rType) const
 
const TypePrototype (const std::string &rTypeName) const
 
const std::string & TypeName (const Type &rType) const
 
bool TypeTest (const std::string &rTypeName, const Type &rObject) const
 
Typeoperator= (const Type &rSrc)
 
virtual const std::string & TypeName (void) const
 
- Public Member Functions inherited from faudes::Type
 Type (void)
 
 Type (const Type &rType)
 
virtual ~Type (void)
 
virtual TypeNew (void) const
 
virtual TypeCopy (void) const
 
virtual const TypeCast (const Type *pOther) const
 
virtual TypeAssign (const Type &rSrc)
 
Typeoperator= (const Type &rSrc)
 
virtual bool Equal (const Type &rOther) const
 
bool operator== (const Type &rOther) const
 
bool operator!= (const Type &rOther) const
 
virtual void Name (const std::string &rName)
 
virtual const std::string & Name (void) const
 
void Write (const Type *pContext=0) const
 
void Write (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 
void XWrite (const Type *pContext=0) const
 
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 
void DWrite (const Type *pContext=0) const
 
void DWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0, std::ios::openmode openmode=std::ios::out|std::ios::trunc) const
 
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
void SWrite (TokenWriter &rTw) const
 
void SWrite (void) const
 
std::string ToSText (void) const
 
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 

Static Public Member Functions

static TypeRegistryG ()
 

Protected Types

typedef std::map< std::string, TypeDefinition * >::iterator iterator
 

Protected Member Functions

virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
 TypeRegistry ()
 
virtual ~TypeRegistry ()
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 
bool DoEqual (const Type &rOther) const
 
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 
virtual void DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
virtual void DoSWrite (TokenWriter &rTw) const
 
virtual const TypeDefinitionTypeDefinitionp (void) const
 
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const
 

Protected Attributes

std::map< std::string, TypeDefinition * > mNameToTypeDef
 
std::map< std::string, TypeDefinition * > mIdToTypeDef
 

Static Protected Attributes

static TypeRegistrympInstance = 0
 

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

◆ Iterator

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

Convenience typedef to access registry entries

Definition at line 54 of file cfl_registry.h.

◆ iterator

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

Convenience typedef to access registry entries

Definition at line 423 of file cfl_registry.h.

Constructor & Destructor Documentation

◆ TypeRegistry()

faudes::TypeRegistry::TypeRegistry ( )
inlineprotected

Constructor

Definition at line 429 of file cfl_registry.h.

◆ ~TypeRegistry()

virtual faudes::TypeRegistry::~TypeRegistry ( )
inlineprotectedvirtual

Destructor

Definition at line 432 of file cfl_registry.h.

Member Function Documentation

◆ AutoRegistered() [1/2]

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
rTypeNameName of faudes-type
Returns
AutoRegister flag

Definition at line 239 of file cfl_registry.cpp.

◆ AutoRegistered() [2/2]

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
rTypeNameName of faudes-type
flagNew value of flag

Definition at line 229 of file cfl_registry.cpp.

◆ Begin()

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

STL interator to the internal type-name map.

Returns
Iterator to the first element.

Definition at line 127 of file cfl_registry.cpp.

◆ Clear()

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 72 of file cfl_registry.cpp.

◆ ClearAll()

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 106 of file cfl_registry.cpp.

◆ Definition() [1/2]

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

Look up the type definition by faudes-type name

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

Definition at line 278 of file cfl_registry.cpp.

◆ Definition() [2/2]

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

Look up the type definition by faudes object

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

Definition at line 290 of file cfl_registry.cpp.

◆ Definitionp() [1/2]

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

Look up the type definition by faudes-type name

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

Definition at line 301 of file cfl_registry.cpp.

◆ Definitionp() [2/2]

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

Look up the type definition by faudes object

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

Definition at line 309 of file cfl_registry.cpp.

◆ DoWrite()

void faudes::TypeRegistry::DoWrite ( TokenWriter rTw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const
protectedvirtual

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
rTwReference to TokenWriter
rLabelLabel of section to write
pContextWrite context to provide contextual information
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::Type.

Definition at line 358 of file cfl_registry.cpp.

◆ End()

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 132 of file cfl_registry.cpp.

◆ Exists() [1/2]

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

Test existence of a faudes-type by its name.

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

Definition at line 347 of file cfl_registry.cpp.

◆ Exists() [2/2]

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

Test existence of a faudes-type by faudes object

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

Definition at line 352 of file cfl_registry.cpp.

◆ G()

TypeRegistry * faudes::TypeRegistry::G ( )
static

Method to access the single global instance of the registry.

Definition at line 62 of file cfl_registry.cpp.

◆ Insert() [1/3]

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
TTemplate parameter to specify c++ type to register
Parameters
rTypeNameSpecify the faudes-type name
Exceptions
Exception
  • Identical name found (id 46)

Definition at line 153 of file cfl_registry.h.

◆ Insert() [2/3]

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
pProtoPrototype object
rTypeNameSpecify the faudes-type name
Exceptions
Exception
  • Identical name found (id 46)

Definition at line 174 of file cfl_registry.h.

◆ Insert() [3/3]

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
pTypeDefType definition to insert
Exceptions
Exception
  • Identical name found (id 46)

Definition at line 137 of file cfl_registry.cpp.

◆ MergeDocumentation() [1/2]

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

Scan file for type documentation. Convenience method, see also MergeDocumentation(TokenReader& rTr)

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

Definition at line 206 of file cfl_registry.cpp.

◆ MergeDocumentation() [2/2]

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<Generator>("Generator");
TypeRegistry::G()->MergeDocumentation("alldocufile.rti");
void MergeDocumentation(TokenReader &rTr)
static TypeRegistry * G()
void Insert(TypeDefinition *pTypeDef)
NameSet EventSet
Definition: cfl_nameset.h:533
vGenerator Generator
Parameters
rTrToken stream.
Exceptions
Exception
  • Token mismatch (id 50, 51, 52)
  • IO Error (id 1)

Definition at line 178 of file cfl_registry.cpp.

◆ NewObject() [1/2]

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
rTypeNameLabel of TypeDefinition to search for.
Returns
Pointer to new faudes::Type instance
Exceptions
Exception
  • Unknown type (id 47)

Definition at line 247 of file cfl_registry.cpp.

◆ NewObject() [2/2]

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

Construct a faudes object by prototype object.

Depreciated: use new on the faudes object instead.

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

Definition at line 265 of file cfl_registry.cpp.

◆ operator=()

Type & faudes::Type::operator=

Assign configurationdata from other object. Derived classes should implement the operator form for the assignment for each source type which allows for a non-trivial assignment. This includes the particular case were the source and destination types match exactly. In the latter case the DoAssign method should be invoked. In contrast to the Assign function, the operator form must not be reimplemented for missmatched source types: the operator form only accepts sensible source types. This allows for compiletime typeckecking. However, the downside is that when the type is not known at compiletime, configuration is not properly assigned.

Re-implementation can be done via the convenience macros FAUDES_TYPE_DECLARATION and FAUDES_TYPE_IMPLEMENTATION.

Parameters
rSrcSource to copy from
Returns
Reference to this object.

Definition at line 340 of file cfl_types.cpp.

◆ Prototype()

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

Look up the prototype object by faudes-type name

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

Definition at line 318 of file cfl_registry.cpp.

◆ Size()

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

Return number of registered type definitions.

Returns
Size of map.

Definition at line 122 of file cfl_registry.cpp.

◆ TypeName() [1/2]

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

Look up the type name by faudes object

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

Definition at line 326 of file cfl_registry.cpp.

◆ TypeName() [2/2]

const std::string & faudes::Type::TypeName ( void  )
virtual

Cosmetic: fix compile warning for recent LLVM/clang++

Reimplemented from faudes::Type.

Definition at line 425 of file cfl_types.cpp.

◆ TypeTest()

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
rTypeNameFaudes type name
rObjectFaudes object instance
Returns
True, if object can be casted to specified faudes type.

Definition at line 336 of file cfl_registry.cpp.

◆ XElementTag() [1/2]

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
rTypeNameName of faudes-type
Returns
Xml element tag

Definition at line 220 of file cfl_registry.cpp.

◆ XElementTag() [2/2]

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
rTypeNameName of faudes-type
rTagNew value of tag

Definition at line 213 of file cfl_registry.cpp.

Member Data Documentation

◆ mIdToTypeDef

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

Definition at line 438 of file cfl_registry.h.

◆ mNameToTypeDef

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

Map to associate labels and faudes::TypeDefinitions.

Definition at line 437 of file cfl_registry.h.

◆ mpInstance

TypeRegistry * faudes::TypeRegistry::mpInstance = 0
staticprotected

Singleton instance

Definition at line 426 of file cfl_registry.h.


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

libFAUDES 2.33b --- 2025.05.07 --- c++ api documentaion by doxygen