|
libFAUDES
Sections
Index
|
faudes::Function Class Reference
|
Public Member Functions | |
Function (const FunctionDefinition *fdef) | |
Constructor For the function to be operational, a valid reference to the corresponding FunctionDefinition is required. | |
~Function () | |
Destructor. | |
virtual Function * | New () const =0 |
Construct on heap. | |
virtual void | Definition (const FunctionDefinition *fdef) |
Set function definition. | |
const FunctionDefinition * | Definition (void) const |
Get function definition. | |
int | VariantsSize (void) const |
Return number of variants. | |
void | Variant (int n) |
Set signature from function definition. | |
void | Variant (const std::string &rVariantName) |
Set signature from function definition. | |
const Signature * | Variant (void) const |
Return pointer to assigned faudes::Signature. | |
int | ParamsSize (void) const |
Return number of parameters with current signature. | |
void | ParamValue (int n, Type *param) |
Set parameter at certain position. | |
Type * | ParamValue (int n) const |
Get parameter value. | |
void | AllocateValues (void) |
Construct parameter values. | |
void | AllocateValue (int i) |
void | FreeValues (void) |
Destruct parameter values. | |
bool | TypeCheck (int n) |
Perform a type check one parameter value. | |
bool | TypeCheck (void) |
Perform a type check on the list of current parameter values. | |
void | Execute (void) |
Perform operation. | |
Protected Member Functions | |
template<class T > | |
bool | DoTypeCast (int n, T *&rTypedRef) |
Helper: generate typed reference for parameter. | |
virtual bool | DoTypeCheck (int n)=0 |
Method to test the type of an assigned parameter with the specified faudes::Signature (i.e. | |
virtual void | DoExecute ()=0 |
Executes code of reimplemented method of child class(es). | |
void | DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const |
Write function-data (typeid-name of arguments) to TokenWriter. | |
Protected Attributes | |
const FunctionDefinition * | pFuncDef |
corresponding function definition | |
int | mVariantIndex |
current variant aka signature as index w.r.t. | |
std::vector< Type * > | mParameterValues |
Vector of arguments. |
A faudes-function hosts parameter values of some faudes type and provides a method to perform an operation on the specified paramters, e.g.
the parallel composition on two generators. The class Function is the base for all faudes-functions, which essenitally differ in the operation method.
The base class provides an application interface to
Derivates of the base class, that acually implement an operation, are required to cast the parameter values to the corresponding c types and then call the respective c function. To derive a class from Function, one will reimplment three virtual functions:
See IntegerSum in the autogenerated ./include/rtiautoload.h" for a simple example of a derived faudes-function.
Technichal note: In contrast to faudes objects (derivates from Type), a faudes-function must be provided a reference to the corresponding FunctionDefinition. This is because a function must be aware of its signature(s). You must not delete the FunctionDefinition object during the lifetime of a faudes-function.
Definition at line 725 of file cfl_functions.h.
faudes::Function::Function | ( | const FunctionDefinition * | fdef | ) |
Constructor For the function to be operational, a valid reference to the corresponding FunctionDefinition is required.
The only exception is the prototype function object used in the FunctionDefinition itself.
Definition at line 526 of file cfl_functions.cpp.
faudes::Function::~Function | ( | ) | [inline] |
Destructor.
Definition at line 737 of file cfl_functions.h.
void faudes::Function::AllocateValue | ( | int | i | ) |
Definition at line 648 of file cfl_functions.cpp.
void faudes::Function::AllocateValues | ( | void | ) |
Construct parameter values.
This is a convenience method to allocate faudes objects for parameter values with the type specified by the current signature. Note that the function does not take ownetship of the parameter values and it is the callers responsibility to delete them when no longer required.
Definition at line 664 of file cfl_functions.cpp.
const FunctionDefinition * faudes::Function::Definition | ( | void | ) | const |
Get function definition.
Reimplemented in faudes::LuaFunction.
Definition at line 559 of file cfl_functions.cpp.
void faudes::Function::Definition | ( | const FunctionDefinition * | fdef | ) | [virtual] |
Set function definition.
Normally, functions are provided with a function definition on construction. The only exception are prototype objects used in function definitions themselfs and in the function registry.
fdef | Function definition to set. |
Reimplemented in faudes::LuaFunction.
Definition at line 543 of file cfl_functions.cpp.
virtual void faudes::Function::DoExecute | ( | ) | [protected, pure virtual] |
Executes code of reimplemented method of child class(es).
Implemented in faudes::LuaFunction.
bool faudes::Function::DoTypeCast | ( | int | n, | |
T *& | rTypedRef | |||
) | [inline, protected] |
Helper: generate typed reference for parameter.
n | Parameter position to cast | |
rTypedRef | Typed reference to generyte |
T | c type to use for cast |
Definition at line 951 of file cfl_functions.h.
virtual bool faudes::Function::DoTypeCheck | ( | int | n | ) | [protected, pure virtual] |
Method to test the type of an assigned parameter with the specified faudes::Signature (i.e.
their TypeDefinition label).
Note: this method is called by Function::Execute() before actual function execution via DoExecute(). It may be used to perform a dynamic cast in preparation of DoExecute(). The latter is only called, if all types match.
n | Position of parameter to check |
Implemented in faudes::LuaFunction.
void faudes::Function::DoWrite | ( | TokenWriter & | rTw, | |
const std::string & | rLabel = "" , |
|||
const Type * | pContext = 0 | |||
) | const [protected, virtual] |
Write function-data (typeid-name of arguments) to TokenWriter.
rTw | Reference to Tokenwriter. | |
rLabel | Label of section to write. | |
pContext | Context pointer, ignored |
Exception |
|
Reimplemented from faudes::Type.
Definition at line 734 of file cfl_functions.cpp.
void faudes::Function::Execute | ( | void | ) |
Perform operation.
Runs a type check and then the actual function.
Exception |
Definition at line 713 of file cfl_functions.cpp.
void faudes::Function::FreeValues | ( | void | ) |
Destruct parameter values.
This is a convenience method to delete the assigned paramer values.
Definition at line 671 of file cfl_functions.cpp.
virtual Function* faudes::Function::New | ( | ) | const [pure virtual] |
Construct on heap.
Create a new instance of this function class and return pointer. The new instance will use the same function definition as this instance.
Reimplemented from faudes::Type.
Implemented in faudes::LuaFunction.
int faudes::Function::ParamsSize | ( | void | ) | const |
Return number of parameters with current signature.
Definition at line 622 of file cfl_functions.cpp.
Type * faudes::Function::ParamValue | ( | int | n | ) | const |
Get parameter value.
Returns a reference to the parameter value at the specified position.
n | Position index of parameter. |
Exception |
|
Definition at line 637 of file cfl_functions.cpp.
void faudes::Function::ParamValue | ( | int | n, | |
Type * | param | |||
) |
Set parameter at certain position.
Sets the internal refernce of the parameter value at the spcefied index. The ownership of the value remains with the caller, ie it will not be deleted in the destructor of the function object. You may set the parameter value to any faudes type (classes derived from Type). A type check will be performed before the function is executed.
n | Position index of parameter | |
param | Pointer to faudes object. |
Exception |
|
Definition at line 627 of file cfl_functions.cpp.
bool faudes::Function::TypeCheck | ( | void | ) |
Perform a type check on the list of current parameter values.
The type check is based on c type cast and should accept any types derived from those given in the signature.
Exception |
|
Definition at line 699 of file cfl_functions.cpp.
bool faudes::Function::TypeCheck | ( | int | n | ) |
Perform a type check one parameter value.
The type check is based on c type cast and should accept any types derived from the type given in the signature.
n | Position of parameter to check |
Exception |
|
Definition at line 681 of file cfl_functions.cpp.
const Signature * faudes::Function::Variant | ( | void | ) | const |
Return pointer to assigned faudes::Signature.
Definition at line 615 of file cfl_functions.cpp.
void faudes::Function::Variant | ( | const std::string & | rVariantName | ) |
Set signature from function definition.
The name refers to this function's FunctionDefinition. An exception is thrown if no such FunctionDefinition is set, as it is the case for prototype instances.
rVariantName | Variant name |
Exception |
|
Definition at line 595 of file cfl_functions.cpp.
void faudes::Function::Variant | ( | int | n | ) |
Set signature from function definition.
The index n refers this function's FunctionDefinition. An exception is thrown if no such FunctionDefinition is set, as it is the case for prototype instances.
n | Variant index |
Exception |
|
Definition at line 571 of file cfl_functions.cpp.
int faudes::Function::VariantsSize | ( | void | ) | const |
Return number of variants.
Definition at line 565 of file cfl_functions.cpp.
std::vector<Type*> faudes::Function::mParameterValues [protected] |
Vector of arguments.
Definition at line 1012 of file cfl_functions.h.
int faudes::Function::mVariantIndex [protected] |
current variant aka signature as index w.r.t.
the function definition
Definition at line 1009 of file cfl_functions.h.
const FunctionDefinition* faudes::Function::pFuncDef [protected] |
corresponding function definition
Definition at line 1006 of file cfl_functions.h.
libFAUDES 2.16b --- 2010-9-8 --- c++ source docu by doxygen 1.6.3