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

The FunctionRegistry registers faudes-functions. More...

#include <cfl_registry.h>

List of all members.

Public Types

typedef std::map< std::string,
FunctionDefinition * >
::const_iterator 
Iterator
 Convenience typedef to access registry entries.

Public Member Functions

void Clear ()
 Clear all registered function definitions.
int Size () const
 Return number of registered function definitions.
bool Exists (const std::string &rName) const
 Test existence of a faudes-function by its name.
bool Exists (const Function &rFunction) const
 Test existence of a faudes-function by faudes object.
Iterator Begin (void) const
 STL interator to the internal function-name map.
Iterator End (void) const
 STL interator to the internal function-name map.
void Insert (FunctionDefinition *pFunctionDef)
 Add another function definition to the registry.
template<class T >
void Insert (const std::string &rFunctionName="")
 Register a faudes-function with specified function name.
void MergeDocumentation (TokenReader &rTr)
 Scan token input for function documentation.
void MergeDocumentation (const std::string &rFileName)
 Scan file for function documentation.
FunctionNewFunction (const std::string &rFunctionName) const
 Construct a faudes object by function name.
FunctionNewFunction (const Function &rFunction) const
 Construct a faudes object by protofunction object.
const FunctionDefinitionDefinition (const std::string &rFunctionName) const
 Look up the function definition by faudes-function name.
const FunctionDefinitionDefinition (const Function &rFunction) const
 Look up the function definition by faudes object.
const std::string & FunctionName (const Function &rFunction) const
 Look up the function name by faudes object.

Static Public Member Functions

static FunctionRegistryG ()
 Method to access the single global instance of the registry.

Protected Types

typedef std::map< std::string,
FunctionDefinition * >
::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.
 FunctionRegistry ()
 Constructor.
virtual ~FunctionRegistry ()
 Destructor.

Protected Attributes

std::map< std::string,
FunctionDefinition * > 
mNameToFunctionDef
 Map to associate labels and faudes::FunctionDefinitions.
std::map< std::string,
FunctionDefinition * > 
mIdToFunctionDef

Static Protected Attributes

static FunctionRegistrympInstance = 0
 Singleton instance.

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 491 of file cfl_registry.h.


Member Typedef Documentation

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

Convenience typedef to access registry entries.

Definition at line 715 of file cfl_registry.h.

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

Convenience typedef to access registry entries.

Definition at line 496 of file cfl_registry.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 721 of file cfl_registry.h.

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

Destructor.

Definition at line 724 of file cfl_registry.h.


Member Function Documentation

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

STL interator to the internal function-name map.

Returns:
Iterator to the first element.

Definition at line 422 of file cfl_registry.cpp.

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

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:
rFunction Reference to faudes::Function to search for.
Returns:
Reference to faudes::FunctionDefinition
Exceptions:
Exception 
  • Unknown function (id 46)

Definition at line 544 of file cfl_registry.cpp.

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

Look up the function definition by faudes-function name.

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

Definition at line 532 of file cfl_registry.cpp.

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

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

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

Test existence of a faudes-function by faudes object.

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

Definition at line 570 of file cfl_registry.cpp.

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

Test existence of a faudes-function by its name.

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

Definition at line 565 of file cfl_registry.cpp.

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

Look up the function name by faudes object.

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

Definition at line 555 of file cfl_registry.cpp.

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

Method to access the single global instance of the registry.

Definition at line 390 of file cfl_registry.cpp.

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:
T Template parameter to specify c++ function to register
Parameters:
rFunctionName Specify the faudes-function name
Exceptions:
Exception 
  • Identical name found (id 46)

Definition at line 585 of file cfl_registry.h.

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

Definition at line 432 of file cfl_registry.cpp.

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

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

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

Definition at line 461 of file cfl_registry.cpp.

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

Construct a faudes object by protofunction object.

Depreciated: use new on the faudes object instead.

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

Definition at line 519 of file cfl_registry.cpp.

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:
rFunctionName Label of FunctionDefinition to search for.
Returns:
Pointer to new faudes::Function instance
Exceptions:
Exception 
  • Unknown function (id 47)

Definition at line 501 of file cfl_registry.cpp.

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

Return number of registered function definitions.

Returns:
Size of map.

Definition at line 417 of file cfl_registry.cpp.


Member Data Documentation

Definition at line 730 of file cfl_registry.h.

Map to associate labels and faudes::FunctionDefinitions.

Definition at line 729 of file cfl_registry.h.

Singleton instance.

Definition at line 718 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