#include <cfl_registry.h>

Public Types

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

Public Member Functions

void Clear ()
 
int Size () const
 
bool Exists (const std::string &rName) const
 
bool Exists (const Function &rFunction) const
 
Iterator Begin (void) const
 
Iterator End (void) const
 
void Insert (FunctionDefinition *pFunctionDef)
 
template<class T >
void Insert (const std::string &rFunctionName="")
 
void MergeDocumentation (TokenReader &rTr)
 
void MergeDocumentation (const std::string &rFileName)
 
FunctionNewFunction (const std::string &rFunctionName) const
 
FunctionNewFunction (const Function &rFunction) const
 
const FunctionDefinitionDefinition (const std::string &rFunctionName) const
 
const FunctionDefinitionDefinition (const Function &rFunction) const
 
const std::string & FunctionName (const Function &rFunction) const
 
Typeoperator= (const Type &rSrc)
 
- 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
 
virtual const std::string & TypeName (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 FunctionRegistryG ()
 

Protected Types

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

Protected Member Functions

virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 
 FunctionRegistry ()
 
virtual ~FunctionRegistry ()
 
- 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, FunctionDefinition * > mNameToFunctionDef
 
std::map< std::string, FunctionDefinition * > mIdToFunctionDef
 

Static Protected Attributes

static FunctionRegistrympInstance = 0
 

Detailed Description

The FunctionRegistry registers faudes-functions. A faudes-functions operates on faudes objects, eg the parallel composition of two generators is available as faudes-function. The registry maintains a mapping between function names and a coresponding function::Definition. The latter provides signatures, ie parameter types the function can take. The registry provides an interface to inspect TypeDefinitions or to construct function 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 498 of file cfl_registry.h.

Member Typedef Documentation

◆ Iterator

typedef std::map<std::string, FunctionDefinition*>::const_iterator faudes::FunctionRegistry::Iterator

Convenience typedef to access registry entries

Definition at line 505 of file cfl_registry.h.

◆ iterator

typedef std::map<std::string, FunctionDefinition*>::iterator faudes::FunctionRegistry::iterator
protected

Convenience typedef to access registry entries

Definition at line 724 of file cfl_registry.h.

Constructor & Destructor Documentation

◆ FunctionRegistry()

faudes::FunctionRegistry::FunctionRegistry ( )
inlineprotected

Constructor

Definition at line 730 of file cfl_registry.h.

◆ ~FunctionRegistry()

virtual faudes::FunctionRegistry::~FunctionRegistry ( )
inlineprotectedvirtual

Destructor

Definition at line 733 of file cfl_registry.h.

Member Function Documentation

◆ Begin()

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

STL interator to the internal function-name map.

Returns
Iterator to the first element.

Definition at line 428 of file cfl_registry.cpp.

◆ Clear()

void faudes::FunctionRegistry::Clear ( void  )
virtual

Clear all registered function definitions. This will also delete the correponsing prototype objects.

Reimplemented from faudes::Type.

Definition at line 406 of file cfl_registry.cpp.

◆ Definition() [1/2]

const FunctionDefinition & faudes::FunctionRegistry::Definition ( const Function rFunction) const

Look up the function definition by faudes object

Techcal note: this implementation is slow, we should use a function id map.

Parameters
rFunctionReference to faudes::Function to search for.
Returns
Reference to faudes::FunctionDefinition
Exceptions
Exception
  • Unknown function (id 46)

Definition at line 550 of file cfl_registry.cpp.

◆ Definition() [2/2]

const FunctionDefinition & faudes::FunctionRegistry::Definition ( const std::string &  rFunctionName) const

Look up the function definition by faudes-function name

Parameters
rFunctionNameLabel of faudes::FunctionDefinition to search for.
Returns
Reference to faudes::FunctionDefinition
Exceptions
Exception
  • Unknown function (id 46)

Definition at line 538 of file cfl_registry.cpp.

◆ DoWrite()

void faudes::FunctionRegistry::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 insert/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 582 of file cfl_registry.cpp.

◆ End()

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

STL interator to the internal function-name map.

Returns
Iterator to the end of the map.

Definition at line 433 of file cfl_registry.cpp.

◆ Exists() [1/2]

bool faudes::FunctionRegistry::Exists ( const Function rFunction) const

Test existence of a faudes-function by faudes object

Parameters
rFunctionObject of function to look up
Returns
True, if a corresponding definition is registered.

Definition at line 576 of file cfl_registry.cpp.

◆ Exists() [2/2]

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

Test existence of a faudes-function by its name.

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

Definition at line 571 of file cfl_registry.cpp.

◆ FunctionName()

const std::string & faudes::FunctionRegistry::FunctionName ( const Function rFunction) const

Look up the function name by faudes object

Parameters
rFunctionReference to faudes::Function to search for.
Returns
Function name as string or "" if unknown.

Definition at line 561 of file cfl_registry.cpp.

◆ G()

FunctionRegistry * faudes::FunctionRegistry::G ( )
static

Method to access the single global instance of the registry.

Definition at line 396 of file cfl_registry.cpp.

◆ Insert() [1/2]

template<class T >
void faudes::FunctionRegistry::Insert ( const std::string &  rFunctionName = "")
inline

Register a faudes-function with specified function name.

This is a convenience function: it uses the template parameter to construct the new instance of FunctionDefinition to be registered. However, no documentation is added. See also MergeDocumentation.

Template Parameters
TTemplate parameter to specify c++ function to register
Parameters
rFunctionNameSpecify the faudes-function name
Exceptions
Exception
  • Identical name found (id 46)

Definition at line 594 of file cfl_registry.h.

◆ Insert() [2/2]

void faudes::FunctionRegistry::Insert ( FunctionDefinition pFunctionDef)

Add another function definition to the registry.

The registry takes the ownership pf the provided function definition. It will be deleted either in Clear() or when the registry is destructed.

Parameters
pFunctionDefFunction definition to insert
Exceptions
Exception
  • Identical name found (id 46)

Definition at line 438 of file cfl_registry.cpp.

◆ MergeDocumentation() [1/2]

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

Scan file for function 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 500 of file cfl_registry.cpp.

◆ MergeDocumentation() [2/2]

void faudes::FunctionRegistry::MergeDocumentation ( TokenReader rTr)

Scan token input for function documentation. This function scans the entire token stream for sections with label "FunctionDefinition". Any such section that refers to a function name which is known to the registry, will be applied to the corresponding registry entry.

Parameters
rTrToken stream.
Exceptions
Exception
  • Token mismatch (id 50, 51, 52)
  • IO Error (id 1)

Definition at line 467 of file cfl_registry.cpp.

◆ NewFunction() [1/2]

Function * faudes::FunctionRegistry::NewFunction ( const Function rFunction) const

Construct a faudes object by protofunction object.

Depreciated: use new on the faudes object instead.

Parameters
rFunctionProtofunction object.
Returns
Pointer to new faudes::Function instance
Exceptions
Exception
  • Unknown function (id 47)

Definition at line 525 of file cfl_registry.cpp.

◆ NewFunction() [2/2]

Function * faudes::FunctionRegistry::NewFunction ( const std::string &  rFunctionName) const

Construct a faudes object by function name

Uses the internal prototype object to construct an object of the same c function on the heap.

Parameters
rFunctionNameLabel of FunctionDefinition to search for.
Returns
Pointer to new faudes::Function instance
Exceptions
Exception
  • Unknown function (id 47)

Definition at line 507 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.

◆ Size()

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

Return number of registered function definitions.

Returns
Size of map.

Definition at line 423 of file cfl_registry.cpp.

Member Data Documentation

◆ mIdToFunctionDef

std::map<std::string, FunctionDefinition*> faudes::FunctionRegistry::mIdToFunctionDef
protected

Definition at line 739 of file cfl_registry.h.

◆ mNameToFunctionDef

std::map<std::string, FunctionDefinition*> faudes::FunctionRegistry::mNameToFunctionDef
protected

Map to associate labels and faudes::FunctionDefinitions.

Definition at line 738 of file cfl_registry.h.

◆ mpInstance

FunctionRegistry * faudes::FunctionRegistry::mpInstance = 0
staticprotected

Singleton instance

Definition at line 727 of file cfl_registry.h.


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

libFAUDES 2.33c --- 2025.05.15 --- c++ api documentaion by doxygen