Detailed Description

A FunctionDefinition defines the interface to a faudes-function.

The latter consists of a descriptive name to identify the function and a list of Signatures the function can operate on. Technically, the class FunctionDefinition is derived from Documentation and thereby inherits members for additional documentation-data.

Similar to Type and TypeDefinition, a FunctionDefinition uses a prototype object to provide the method NewFunction() which instantiates the corresponding Function object.

FunctionDefinition inherits the token io interface from Type, however, the class is not intended to register as a faudes type. The token io format is demonstrated by the following example:

<FunctionDefinition name="CoreFaudes::IntegerSum" ctype="faudes::IntegerSum">
<Documentation ref="integersum.html">
Returns the sum of integer arguments.
<Keywords> "integer" "elemetary types" </Keywords>
<VariantSignatures>
<Signature name="Two arguments">
<Parameter name="Arg1" ftype="Integer" access="In">
<Parameter name="Arg2" ftype="Integer" access="In">
<Parameter name="Res" ftype="Integer" access="Out" creturn="true">
</Signature>
<Signature name="Three arguments">
<Parameter name="Arg1" ftype="Integer" access="In">
<Parameter name="Arg2" ftype="Integer" access="In">
<Parameter name="Arg3" ftype="Integer" access="In">
<Parameter name="Res" ftype="Integer" access="Out" creturn="true">
</Signature>
</VariantSignatures>
Documentation(void)
Constructor.
Definition: cfl_types.cpp:352
const std::string & Keywords(void) const
Definition: cfl_types.cpp:401
FunctionDefinition(const std::string &name="")
Constructor.

Definition at line 419 of file cfl_functions.h.

#include <cfl_functions.h>

Public Member Functions

 FunctionDefinition (const std::string &name="")
 Constructor. More...
 
 FunctionDefinition (const FunctionDefinition &rSrc)
 Copy Constructor. More...
 
virtual ~FunctionDefinition ()
 Destructor. More...
 
virtual void Clear (void)
 Clear documentation-data and signature (keep prototype) More...
 
virtual void ClearVariants (void)
 Clear variants (keep docu and prototype) More...
 
const FunctionPrototype (void) const
 Return pointer to function object prototype. More...
 
FunctionNewFunction () const
 Construct function on heap. More...
 
int VariantsSize (void) const
 Return number of supported Signature instances. More...
 
bool ExistsVariant (const std::string &varname) const
 Test existence of variant by its name. More...
 
int VariantIndex (const std::string &rName) const
 Return index of Signature by name. More...
 
const SignatureVariant (const std::string &rName) const
 Return reference to Signature by name. More...
 
const SignatureVariant (int n) const
 Return reference to Signature by index. More...
 
virtual void AppendVariant (const Signature &pVar)
 Add Signature to function definition. More...
 
- Public Member Functions inherited from faudes::Documentation
 Documentation (void)
 Constructor. More...
 
 Documentation (const Documentation &rOther)
 Copy constructor. More...
 
virtual ~Documentation (void)
 Destructor. More...
 
void Clear (void)
 Clear. More...
 
const std::string & Name (void) const
 Get name of the entety to document (aka faudes-type or faudes-function). More...
 
const std::string & PlugIn (void) const
 Get name of plugin. More...
 
const std::string & CType (void) const
 Get corresponding C++ type. More...
 
const std::string & TextDoc (void) const
 
const std::string & HtmlDoc (void) const
 
const std::string & Keywords (void) const
 
std::string MatchKeyword (const std::string &rPattern) const
 Search comma-seperated keywords for a substring. More...
 
int KeywordsSize (void) const
 Not implemented. More...
 
std::string KeywordAt (int pos) const
 
bool AutoRegistered (void) const
 Get auto-register flag. More...
 
bool ApplicationRegistered (void) const
 Get application-registered flag. More...
 
virtual void MergeDocumentation (TokenReader &rTr)
 Merge documentation from token stream. More...
 
Typeoperator= (const Type &rSrc)
 Assign configurationdata from other object. More...
 
bool operator== (const Type &rOther) const
 Test equality of configuration data. More...
 
bool operator!= (const Type &rOther) const
 Test equality of configuration data. More...
 
- Public Member Functions inherited from faudes::Type
 Type (void)
 Constructor. More...
 
 Type (const Type &rType)
 Copy constructor. More...
 
virtual ~Type (void)
 Destructor. More...
 
virtual TypeNew (void) const
 Construct on heap. More...
 
virtual TypeCopy (void) const
 Construct on heap. More...
 
virtual const TypeCast (const Type *pOther) const
 Cast other object to this type. More...
 
virtual TypeAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
Typeoperator= (const Type &rSrc)
 Assign configurationdata from other object. More...
 
virtual bool Equal (const Type &rOther) const
 Test equality of configuration data. More...
 
bool operator== (const Type &rOther) const
 Test equality of configuration data. More...
 
bool operator!= (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual const std::string & TypeName (void) const
 Get objects's type name. More...
 
void Write (const Type *pContext=0) const
 Write configuration data to console. More...
 
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
 Write configuration data to a file. More...
 
void Write (const std::string &pFileName, std::ios::openmode openmode) const
 Write configuration data to a file. More...
 
void Write (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to TokenWriter. More...
 
virtual void XWrite (const std::string &pFileName, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to an XML file. More...
 
void XWrite (const Type *pContext=0) const
 Write configuration data in XML format to concole Note: this write function uses the virtual function DoXWrite(), to be reimplemented by derived classes. More...
 
void XWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in XML format to TokenWriter. More...
 
std::string ToString (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a string. More...
 
std::string ToText (const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data to a formated string. More...
 
void DWrite (const Type *pContext=0) const
 Write configuration data to console, debugging format. More...
 
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
 Write configuration data to a file, debugging format. More...
 
void DWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debug format to TokenWriter. More...
 
void SWrite (TokenWriter &rTw) const
 Write statistics comment to TokenWriter. More...
 
void SWrite (void) const
 Write statistics comment to console. More...
 
std::string ToSText (void) const
 Write statistics to a string. More...
 
void Read (const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from file with label specified. More...
 
void FromString (const std::string &rString, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from a string. More...
 
void Read (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data from TokenReader with label sepcified. More...
 

Static Public Member Functions

template<class T >
static FunctionDefinitionConstructor (const std::string &rFunctName="")
 Construct empty FunctionDefinition object. More...
 
template<class T >
static FunctionDefinitionFromFile (const std::string &rFileName)
 Construct FunctionDefinition object and get name and docu from file. More...
 

Protected Member Functions

void DoAssign (const FunctionDefinition &rSrc)
 Std faudes type interface: assignment. More...
 
bool DoEqual (const FunctionDefinition &rOther) const
 Std faudes type interface: test equality. More...
 
virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Read configuration data of this object from TokenReader. More...
 
virtual void DoReadCore (TokenReader &rTr)
 Read configuration data of this object from TokenReader. More...
 
virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data of this object to TokenWriter. More...
 
virtual void DoWriteCore (TokenWriter &rTw) const
 Write configuration data of this object to TokenWriter. More...
 
virtual void Prototype (Function *pFunc)
 Assign prototype object. More...
 
- Protected Member Functions inherited from faudes::Documentation
void Name (const std::string &name)
 Set name. More...
 
void PlugIn (const std::string &plugin)
 Set name of plugin. More...
 
void CType (const std::string &name)
 Set C++ type. More...
 
void TextDoc (const std::string &textdoc)
 Set a short textual documentation. More...
 
void AutoRegistered (bool flag)
 Set auto-register flag. More...
 
void ApplicationRegistered (bool flag)
 Set application-registered flag. More...
 
void HtmlDoc (const std::string &fname)
 Set name of file pointing to the html documentation. More...
 
void AddKeyword (const std::string &rKeyword)
 Append keyword. More...
 
void DoAssign (const Documentation &rSrc)
 Std faudes type interface: assignment. More...
 
bool DoEqual (const Documentation &rOther) const
 Std faudes type interface: test equality. More...
 
- Protected Member Functions inherited from faudes::Type
void DoAssign (const Type &rSrc)
 Assign configuration data from other object. More...
 
bool DoEqual (const Type &rOther) const
 Test equality of configuration data. More...
 
virtual void DoXWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data of this object to TokenWriter in XML format. More...
 
virtual void DoDWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write configuration data in debugging format to TokenWriter. More...
 
virtual void DoSWrite (TokenWriter &rTw) const
 Write statistical data as a comment to TokenWriter. More...
 
virtual const TypeDefinitionTypeDefinitionp (void) const
 Get objects's type definition. More...
 
virtual Token XBeginTag (const std::string &rLabel="", const std::string &rFallbackLabel="") const
 

Protected Attributes

FunctionmpFunction
 Prototype instance. More...
 
std::vector< faudes::SignaturemVariants
 Vector containing all supported Signatures. More...
 
std::map< std::string, int > mVariantIndexMap
 Variant name to index map. More...
 
- Protected Attributes inherited from faudes::Documentation
std::string mName
 Faudes name. More...
 
std::string mPlugIn
 Faudes plugin. More...
 
std::string mCType
 Corresponing C++ type, or "" if no such. More...
 
std::string mTextDoc
 String containing the text-documentation. More...
 
std::string mHtmlDoc
 String containing the filename of the corresponding html-documentation. More...
 
std::string mKeywords
 Comma-seperated string containing all keywords. More...
 
bool mAutoRegistered
 Flag to indicate automated registration. More...
 
bool mApplicationRegistered
 Flag to indicate application registration. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from faudes::Documentation
static const char mDelim = ';'
 Constant characted used to seperate keywords. More...
 

Constructor & Destructor Documentation

◆ FunctionDefinition() [1/2]

faudes::FunctionDefinition::FunctionDefinition ( const std::string &  name = "")

Constructor.

The default constructor instantiates an invalid function definition without prototype. To construct a valid function definition, use the static Constructor() template function.

Definition at line 356 of file cfl_functions.cpp.

◆ FunctionDefinition() [2/2]

faudes::FunctionDefinition::FunctionDefinition ( const FunctionDefinition rSrc)

Copy Constructor.

The copy constructor copies all members one-to-one, except for the prototype object. The latter is re-created using its factory function.

Definition at line 364 of file cfl_functions.cpp.

◆ ~FunctionDefinition()

virtual faudes::FunctionDefinition::~FunctionDefinition ( )
inlinevirtual

Destructor.

Definition at line 450 of file cfl_functions.h.

Member Function Documentation

◆ AppendVariant()

void faudes::FunctionDefinition::AppendVariant ( const Signature pVar)
virtual

Add Signature to function definition.

Parameters
pVarSignature to insert
Exceptions
Exception

Definition at line 458 of file cfl_functions.cpp.

◆ Clear()

void faudes::FunctionDefinition::Clear ( void  )
virtual

Clear documentation-data and signature (keep prototype)

Reimplemented from faudes::Type.

Reimplemented in faudes::LuaFunctionDefinition.

Definition at line 397 of file cfl_functions.cpp.

◆ ClearVariants()

void faudes::FunctionDefinition::ClearVariants ( void  )
virtual

Clear variants (keep docu and prototype)

Definition at line 407 of file cfl_functions.cpp.

◆ Constructor()

template<class T >
FunctionDefinition * faudes::FunctionDefinition::Constructor ( const std::string &  rFunctName = "")
static

Construct empty FunctionDefinition object.

The given template parameter denotes a Function class. Member variable (mpFunction) is set to a new instance of that class whereas the name is set as specified. No further documentation or signatures are recorded.

Template Parameters
TActual function class, derived from Function
Parameters
rFunctNameName to identify this faudes-function
Returns
Newly constructed function definition.

Definition at line 1046 of file cfl_functions.h.

◆ DoAssign()

void faudes::FunctionDefinition::DoAssign ( const FunctionDefinition rSrc)
protected

Std faudes type interface: assignment.

Parameters
rSrcSource to copy from

Definition at line 372 of file cfl_functions.cpp.

◆ DoEqual()

bool faudes::FunctionDefinition::DoEqual ( const FunctionDefinition rOther) const
protected

Std faudes type interface: test equality.

Parameters
rOtherOther object to compare with.
Returns
True on match.

Definition at line 388 of file cfl_functions.cpp.

◆ DoRead()

void faudes::FunctionDefinition::DoRead ( TokenReader rTr,
const std::string &  rLabel = "",
const Type pContext = 0 
)
protectedvirtual

Read configuration data of this object from TokenReader.

Actual reading is done by DoReadCore.

The section defaults to "FunctionDefinition", context ignored.

Parameters
rTrTokenReader to read from
rLabelSection to read
pContextRead context to provide contextual information (ignored)
Exceptions
Exception
  • Token mismatch (id 50, 51, 52)
  • IO error (id 1)

Reimplemented from faudes::Documentation.

Reimplemented in faudes::LuaFunctionDefinition.

Definition at line 497 of file cfl_functions.cpp.

◆ DoReadCore()

void faudes::FunctionDefinition::DoReadCore ( TokenReader rTr)
protectedvirtual

Read configuration data of this object from TokenReader.

This method reads members only, it does not read the section.

Parameters
rTrTokenReader to read from
Exceptions
Exception
  • Token mismatch (id 50, 51, 52)
  • IO error (id 1)

Reimplemented from faudes::Documentation.

Reimplemented in faudes::LuaFunctionDefinition.

Definition at line 510 of file cfl_functions.cpp.

◆ DoWrite()

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

Write configuration data of this object to TokenWriter.

The section defaults to "FunctionDefinition", context ignored.

Parameters
rTwReference to TokenWriter
rLabelLabel of section to write
pContextWrite context to provide contextual information
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::Documentation.

Reimplemented in faudes::LuaFunctionDefinition.

Definition at line 529 of file cfl_functions.cpp.

◆ DoWriteCore()

void faudes::FunctionDefinition::DoWriteCore ( TokenWriter rTw) const
protectedvirtual

Write configuration data of this object to TokenWriter.

This method writes plain member data, the section lables are not written.

Parameters
rTwReference to TokenWriter
Exceptions
Exception
  • IO errors (id 2)

Reimplemented from faudes::Documentation.

Reimplemented in faudes::LuaFunctionDefinition.

Definition at line 538 of file cfl_functions.cpp.

◆ ExistsVariant()

bool faudes::FunctionDefinition::ExistsVariant ( const std::string &  varname) const

Test existence of variant by its name.

Returns
True if variant exists

Definition at line 446 of file cfl_functions.cpp.

◆ FromFile()

template<class T >
FunctionDefinition * faudes::FunctionDefinition::FromFile ( const std::string &  rFileName)
static

Construct FunctionDefinition object and get name and docu from file.

The member variable mpFunction is set to a new instance of class T. which must be derived from Function. The function name, any documentation as well as supported signatures are read from the specified file.

Template Parameters
TActual function class, derived from Function
Parameters
rFileNameFile to read documentation and signatures from.
Returns
Newly constructed function definition.

Definition at line 1063 of file cfl_functions.h.

◆ NewFunction()

Function * faudes::FunctionDefinition::NewFunction ( ) const

Construct function on heap.

Return pointer to new instance of assigned Function class.

Note: If no prototype is installed, NULL is returned.

Returns
Pointer to new Function instance.

Definition at line 433 of file cfl_functions.cpp.

◆ Prototype() [1/2]

void faudes::FunctionDefinition::Prototype ( Function pFunc)
protectedvirtual

Assign prototype object.

Parameters
pFuncFunction instance

Reimplemented in faudes::LuaFunctionDefinition.

Definition at line 421 of file cfl_functions.cpp.

◆ Prototype() [2/2]

const Function * faudes::FunctionDefinition::Prototype ( void  ) const

Return pointer to function object prototype.

Note: this method is meant for inspection only, control over the prototype remains with the FunctionDefinition. Use NewFunction() to instantiate a new function object.

Returns
Reference to prototype function.

Definition at line 416 of file cfl_functions.cpp.

◆ Variant() [1/2]

const Signature & faudes::FunctionDefinition::Variant ( const std::string &  rName) const

Return reference to Signature by name.

Parameters
rNameName of signature to search.
Returns
Reference to Signature
Exceptions
Exception
  • No such signature (id 47)

Definition at line 473 of file cfl_functions.cpp.

◆ Variant() [2/2]

const Signature & faudes::FunctionDefinition::Variant ( int  n) const

Return reference to Signature by index.

Parameters
nIndex to look up
Returns
Reference to Signature
Exceptions
Exception
  • Index out of range (id 47)

Definition at line 485 of file cfl_functions.cpp.

◆ VariantIndex()

int faudes::FunctionDefinition::VariantIndex ( const std::string &  rName) const

Return index of Signature by name.

Parameters
rNameName of signature to search.
Returns
Index of signature, or -1 if not existant

Definition at line 451 of file cfl_functions.cpp.

◆ VariantsSize()

int faudes::FunctionDefinition::VariantsSize ( void  ) const

Return number of supported Signature instances.

Returns
Size of signature vector.

Definition at line 441 of file cfl_functions.cpp.

Member Data Documentation

◆ mpFunction

Function* faudes::FunctionDefinition::mpFunction
protected

Prototype instance.

Definition at line 675 of file cfl_functions.h.

◆ mVariantIndexMap

std::map<std::string,int> faudes::FunctionDefinition::mVariantIndexMap
protected

Variant name to index map.

Definition at line 681 of file cfl_functions.h.

◆ mVariants

std::vector<faudes::Signature> faudes::FunctionDefinition::mVariants
protected

Vector containing all supported Signatures.

Definition at line 678 of file cfl_functions.h.


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

libFAUDES 2.32f --- 2024.12.22 --- c++ api documentaion by doxygen