| |
libFAUDES
Sections
Index
|
rtifncts.hGo to the documentation of this file.00001 /** @file rtifncts.h Runtime interface, operations on faudes types */ 00002 00003 /* FAU Discrete Event Systems Library (libfaudes) 00004 00005 Copyright (C) 2009 Ruediger Berndt 00006 Copyright (C) 2009 Thomas Moor 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 00021 00022 00023 #ifndef FAUDES_RTIFNCTS_H 00024 #define FAUDES_RTIFNCTS_H 00025 00026 // todo: fix/hide copy constructor 00027 00028 #include "rtitypes.h" 00029 00030 namespace faudes{ 00031 00032 /** 00033 * Structure to model a parameter type within the Signature of a 00034 * Function. 00035 * A Parameter is made of a descriptive name, a faudes type and 00036 * an io-attribute. The latter specifies whether the parameter 00037 * is an input or output of the corresponding function. 00038 */ 00039 00040 class Parameter { 00041 00042 public: 00043 00044 /** 00045 * A function parameter has has one out of four so called io-attrributes; 00046 */ 00047 enum ParamAttr{ 00048 In, //// Input parameter, aka argument, remains constant while execution 00049 Out, //// Output parameter, aka result, is generated during function execution 00050 InOut, //// InOut parameter, is interpreted and possibly altered during execution 00051 UnDef //// UnDef parameter indicates unconfigured signature 00052 }; 00053 00054 /** Constructor, default */ 00055 Parameter(void) : mName(""), mTDName(""), mAttr(Parameter::UnDef) {}; 00056 00057 /** Constructor, by member values */ 00058 Parameter(const std::string& rName, const std::string& rTypeName, ParamAttr attr) : 00059 mName(rName), mTDName(rTypeName), mAttr(attr) {}; 00060 00061 /** Desctructor */ 00062 ~Parameter(void){}; 00063 00064 /** 00065 * Convenience method to produce a textual representation of an io attribute. 00066 * 00067 * @param attr 00068 * Enum value denoting the attribute. 00069 * @return 00070 * Parameter IO attribute as std::string 00071 */ 00072 static std::string AStr(Parameter::ParamAttr attr){ 00073 switch(attr){ 00074 case Parameter::In: return "In"; 00075 case Parameter::Out: return "Out"; 00076 case Parameter::InOut: return "InOut"; 00077 default: break; 00078 } 00079 return "UnDef"; 00080 }; 00081 00082 /** 00083 * Convenience method to produce a textual representation of a parameter. 00084 * 00085 */ 00086 std::string Str(void) const { 00087 std::string res = "+" + AStr(mAttr)+ "+ " + mTDName + " " + mName; 00088 return res; 00089 }; 00090 00091 /** 00092 * Set to "undefined" 00093 */ 00094 void Clear(){ 00095 mName = ""; 00096 mTDName = ""; 00097 mAttr = Parameter::UnDef; 00098 }; 00099 00100 /** Name */ 00101 std::string mName; 00102 00103 /** Faudes type */ 00104 std::string mTDName; 00105 00106 /** IO-Attribute */ 00107 ParamAttr mAttr; 00108 00109 protected: 00110 00111 }; // Parameter 00112 00113 00114 00115 00116 /** 00117 * Signature of a Function. 00118 * 00119 * A Signature describes the faudes types of the positional 00120 * parameters. Tecnically, a Signature is a vector of Parameters. 00121 * Each Function may execute serveral variants indicated by setting 00122 * a particular Signature. A list of valid Signatures is maintained in 00123 * the coresponding FunctionDefinition. 00124 * 00125 * Core members are 00126 * - mName: string to identify ths signature 00127 * - mParameters: vector of Paramters. 00128 * 00129 * The Signature is formally derived from Type to inherit the std token io 00130 * interface. It is not meant to be registered as a faudes type. 00131 * The token io format is demonstrated by the following example: 00132 * 00133 * @code 00134 * <Signature> 00135 * "Sum of two integers" 00136 * <Parameters> 00137 * "arg1" "Integer" +InOut+ 00138 * "arg2" "Integer" +In+ 00139 * "result" "String" +Out+ 00140 * </Parameters> 00141 * </Signature> 00142 * @endcode 00143 * 00144 * Technical note: the variable parameter feature offered by FunctionDefinition is a purely 00145 * cosmetic hack implemented in FunctionDefinition:MergeDocumentation. 00146 */ 00147 00148 class Signature : public Type { 00149 00150 public: 00151 00152 /** Constructor */ 00153 Signature(void){}; 00154 00155 /** Destructor */ 00156 ~Signature(void){}; 00157 00158 /** 00159 * Return signature name. 00160 * 00161 * @return 00162 * Name 00163 */ 00164 const std::string& Name(void) const; 00165 00166 /** 00167 * Set signature name. 00168 * 00169 * @param 00170 * rName 00171 */ 00172 void Name(const std::string& rName); 00173 00174 /** 00175 * Clear signature 00176 */ 00177 void Clear(void); 00178 00179 /** 00180 * Return number of parameters. 00181 * 00182 * @return 00183 * int 00184 */ 00185 int Size(void) const; 00186 00187 /** 00188 * Get parameter type by position. 00189 * 00190 * @param n 00191 * Position of patameter. 00192 * 00193 * @exception Exception 00194 * - Index out of range 00195 */ 00196 const Parameter& At(int n) const; 00197 00198 /** 00199 * Append positional parameter. 00200 * 00201 * @param rParam 00202 * Parameter to append 00203 */ 00204 void Append(const Parameter& rParam); 00205 00206 00207 protected: 00208 00209 /** 00210 * Read signature from from TokenReader. 00211 * 00212 * The section is hardcoded to "Signature", context is ignored. 00213 * 00214 * @param rTr 00215 * TokenReader to read from 00216 * @param rLabel 00217 * Section to read 00218 * @param pContext 00219 * Read context to provide contextual information (ignored) 00220 * 00221 * @exception Exception 00222 * - IO error (id 1) 00223 * - Token mismatch 00224 */ 00225 virtual void DoRead(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0); 00226 00227 /** 00228 * Write configuration data of this object to TokenWriter. 00229 * 00230 * The section is hardcoded to "Signature", context is ignored. 00231 * 00232 * @param rTw 00233 * Reference to TokenWriter 00234 * @param rLabel 00235 * Label of section to write 00236 * @param pContext 00237 * Write context to provide contextual information 00238 * 00239 * @exception Exception 00240 * - IO errors (id 2) 00241 */ 00242 virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const; 00243 00244 /** Variable to store name */ 00245 std::string mName; 00246 00247 /** Vector of Parameter-objects */ 00248 std::vector<Parameter> mParameters; 00249 00250 }; // Signature 00251 00252 00253 00254 // forward 00255 class Function; 00256 00257 00258 /** 00259 * A FunctionDefinition defines the interface to a faudes-function. 00260 * The latter consists of a descriptive name to identify the function and 00261 * a list of Signatures the function can operate on. 00262 * Technically, the class FunctionDefinition is derived from Documentation and 00263 * thereby inherits members for additional 00264 * documentation-data. 00265 * 00266 * Similar to Type and TypeDefinition, a FunctionDefinition uses a prototype object to 00267 * provide the method NewFunction() which instantiates the corresponding Function object. 00268 * 00269 * FunctionDefinition inherits the token io interface from Type, however, the class is 00270 * not intended to register as a faudes type. The token io format is demonstrated by the 00271 * following example: 00272 * 00273 * @code 00274 * <FunctionDefinition> 00275 * "CoreFaudes::IntegerSum" 00276 * 00277 * <TextDoc> "Returns the sum of integer arguments." </TextDoc> 00278 * <HtmlDoc> "integersum.html" </HtmlDoc> 00279 * <Keywords> "integer" "elemetary types" </Keywords> 00280 * 00281 * <VariantSignatures> 00282 * <Signature> 00283 * "Two arguments" 00284 * "Arg1" "Integer" +In+ 00285 * "Arg2" "Integer" +In+ 00286 * "Res" "Integer" +Out+ 00287 * </Signature> 00288 * 00289 * <Signature> 00290 * "Three arguments" 00291 * "Arg1" "Integer" +In+ 00292 * "Arg2" "Integer" +In+ 00293 * "Arg3" "Integer" +In+ 00294 * "Res" "Integer" +Out+ 00295 * </Signature> 00296 * </VariantSignatures> 00297 * 00298 * </FunctionDefinition> 00299 * @endcode 00300 * 00301 * For functions that allow for a variable number of arguments of thesame type, there 00302 * is a purely cosmetic hack: when in a function definition a signature has a double hash "##" 00303 * in its name, any parameters with a "##" can apprear repeatedly. This short cut is expanded 00304 * by the token input function MergeDocumentation, that actually inserts the respective signatures. 00305 * The compile time option FD_RTIMAXPARAMS defines how many copies of the parameter can appear. 00306 * Obviously, this only makes sense if the corresponding Function object supports every 00307 * automatically generated signature. 00308 * Example from IntegerSum 00309 * 00310 * @code 00311 * <Signature> 00312 * "Ires=Sum_(i=1)^(##) Ii" 00313 * "Arg##" "Integer" +In+ 00314 * "Res" "Integer" +Out+ 00315 * </Signature> 00316 * @endcode 00317 * 00318 * 00319 * @ingroup RunTimeInterface 00320 */ 00321 00322 class FunctionDefinition : public Documentation { 00323 00324 public: 00325 00326 /** 00327 * Constructor 00328 * 00329 * The default constructor instantiates an invalid function definition 00330 * without prototype. To construct 00331 * a valid type definition, use the static Constructor() template 00332 * function. 00333 */ 00334 FunctionDefinition(const std::string& name="") : Documentation(), mpFunction(NULL) {Name(name);}; 00335 00336 /** 00337 * Destructor 00338 */ 00339 virtual ~FunctionDefinition(){ Prototype(NULL);}; 00340 00341 /** 00342 * Construct empty FunctionDefinition object. 00343 * The given template parameter denotes a Function class. 00344 * Member variable (mpFunction) is set to a new instance of that class 00345 * whereas the name is set as specified. No further documentation 00346 * or signatures are recorded. 00347 * 00348 * @tparam T 00349 * Actual function class, derived from Function 00350 * @param rFunctName 00351 * Name to identify this faudes-function 00352 * @return 00353 * Newly constructed function definition. 00354 */ 00355 template<class T> 00356 static FunctionDefinition* Constructor(const std::string& rFunctName=""); 00357 00358 /** 00359 * Construct FunctionDefinition object and get name and docu from file. 00360 * 00361 * The member variable mpFunction is set to a new instance of class T. 00362 * which must be derived from Function. The function name, any documentation 00363 * as well as supported signatures are read from the specified file. 00364 * 00365 * @tparam T 00366 * Actual function class, derived from Function 00367 * @param rFileName 00368 * File to read documentation and signatures from. 00369 * @return 00370 * Newly constructed function definition. 00371 */ 00372 template<class T> 00373 static FunctionDefinition* FromFile(const std::string& rFileName); 00374 00375 /** 00376 * Clear documentation-data and signature (keep prototype) 00377 */ 00378 void Clear(void); 00379 00380 /** 00381 * Merge documentation and signatures from token stream. 00382 * This member reads the body of the FunctionDefinition token format 00383 * and sets the function name, any further documentation and the 00384 * supported signatures accordingly. An exception is 00385 * thrown if the current function name differs from the one in the documentation. 00386 * 00387 * 00388 * 00389 * @param rTr 00390 * TokenReader to read from. 00391 * 00392 * @exception Exception 00393 * - Type mismatch (id ) 00394 * - Token mismatch (id 50, 51, 52) 00395 * - IO Error (id 1) 00396 */ 00397 void MergeDocumentationBody(TokenReader& rTr); 00398 00399 00400 /** 00401 * Return pointer to function object prototype 00402 * 00403 * Note: this method is meant for inspection only, control over 00404 * the prototype remains with the FunctionDefinition. Use 00405 * NewFunction() to instantiate a new function object. 00406 * 00407 * @return 00408 * Reference to prototype function. 00409 */ 00410 const Function* Prototype(void) const; 00411 00412 /** 00413 * Construct function on heap. 00414 * Return pointer to new instance of assigned Function class. 00415 * 00416 * Note: If no prototype is installed, NULL is returned. 00417 * 00418 * @return 00419 * Pointer to new Function instance. 00420 */ 00421 Function* NewFunction() const; 00422 00423 00424 /** 00425 * Return number of supported Signature instances. 00426 * 00427 * @return 00428 * Size of signature vector. 00429 */ 00430 int VariantsSize(void) const; 00431 00432 /** 00433 * Test existence of variant by its name. 00434 * 00435 * @return 00436 * True if variant exists 00437 */ 00438 bool ExistsVariant(const std::string& varname) const; 00439 00440 /** 00441 * Return index of Signature by name. 00442 * 00443 * @param rName 00444 * Name of signature to search. 00445 * @return 00446 * Index of signature, or -1 if not existant 00447 */ 00448 int VariantIndex(const std::string& rName) const; 00449 00450 /** 00451 * Return reference to Signature by name. 00452 * 00453 * @param rName 00454 * Name of signature to search. 00455 * @return 00456 * Reference to Signature 00457 * @exception Exception 00458 * - No such signature (id 47) 00459 */ 00460 const Signature& Variant(const std::string& rName) const; 00461 00462 /** 00463 * Return reference to Signature by index. 00464 * 00465 * @param n 00466 * Index to look up 00467 * @return 00468 * Reference to Signature 00469 * @exception Exception 00470 * - Index out of range (id 47) 00471 */ 00472 const Signature& Variant(int n) const; 00473 00474 protected: 00475 00476 /** 00477 * Read configuration data of this object from TokenReader. 00478 * 00479 * The section is hardcode to "FunctionDefinition", context ignored. 00480 * 00481 * @param rTr 00482 * TokenReader to read from 00483 * @param rLabel 00484 * Section to read 00485 * @param pContext 00486 * Read context to provide contextual information (ignored) 00487 * 00488 * @exception Exception 00489 * - IO error (id 1) 00490 */ 00491 virtual void DoRead(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0); 00492 00493 /** 00494 * Write configuration data of this object to TokenWriter. 00495 * 00496 * The section is hardcode to "FunctionDefinition", context ignored. 00497 * 00498 * @param rTw 00499 * Reference to TokenWriter 00500 * @param rLabel 00501 * Label of section to write 00502 * @param pContext 00503 * Write context to provide contextual information 00504 * 00505 * @exception Exception 00506 * - IO errors (id 2) 00507 */ 00508 virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const; 00509 00510 /** 00511 * Add Signature to function definition. 00512 * 00513 * @param pVar 00514 * Signature to insert 00515 * @exception Exception 00516 * - Signature with same name exists (id 47) 00517 */ 00518 void AppendVariant(const Signature& pVar); 00519 00520 /** Disable Copy Constructor */ 00521 FunctionDefinition(const FunctionDefinition& rOther) : Documentation(rOther) {}; 00522 00523 00524 /** 00525 * Assign prototype object 00526 * 00527 * @param pFunc 00528 * Function instance 00529 * 00530 */ 00531 void Prototype(Function* pFunc); 00532 00533 /** Prototype instance */ 00534 Function* mpFunction; 00535 00536 /** Vector containing all supported Signatures */ 00537 std::vector<faudes::Signature> mVariants; 00538 00539 /** Variant name to index map */ 00540 std::map<std::string,int> mVariantIndexMap; 00541 00542 }; // FunctionDefinition 00543 00544 00545 00546 /** 00547 * A faudes-function hosts parameter values of some faudes type and provides 00548 * a method to perform an operation on the specified paramters, e.g. the 00549 * parallel composition on two generators. The class Function is the base 00550 * for all faudes-functions, which essenitally differ in the operation method. 00551 * 00552 * The base class provides an application interface to 00553 * - select a variant signature, see Variant(); 00554 * - set and get parameter values of any faudes type, see ParamValue(); 00555 * - type check the provided parameter values, see TypeCheck(); 00556 * - perform the operation, see Execute(). 00557 * 00558 * Derivates of the base class, that acually implement an operation, 00559 * are required to cast the parameter values to the corresponding c types and then 00560 * call the respective c function. To derive a class from Function, one will 00561 * reimplment three virtual functions: 00562 * - DoTypeCheck() to perform the cast 00563 * - DoExecute() to call the c function. 00564 * - the constructor New() to replicate the function object. 00565 * 00566 * See IntegerSum in the autogenerated ./include/rtiautoload.h" for a simple example 00567 * of a derived faudes-function. 00568 * 00569 * 00570 * Technichal note: In contrast to faudes objects (derivates from Type), a faudes-function 00571 * must be provided a reference to the corresponding FunctionDefinition. This is because 00572 * a function must be aware of its signature(s). You must not delete 00573 * the FunctionDefinition object during the lifetime of a faudes-function. 00574 * 00575 * 00576 * @ingroup RunTimeInterface 00577 */ 00578 00579 class Function : public Type { 00580 00581 public: 00582 /** 00583 * Constructor 00584 * For the function to be operational, a valid reference to the corresponding 00585 * FunctionDefinition is required. The only exception is the prototype function 00586 * object used in the FunctionDefinition itself. 00587 */ 00588 Function(const FunctionDefinition* fdef); 00589 00590 /** Destructor */ 00591 ~Function(){} 00592 00593 /** 00594 * Construct on heap. 00595 * Create a new instance of this function class and return pointer. 00596 * The new instance will use the same function definition as this instance. 00597 * 00598 * @return 00599 * Pointer to faudes::Function instance. 00600 * 00601 */ 00602 virtual Function* New() const = 0; 00603 00604 00605 /** 00606 * Set function definition. 00607 * Normally, functions are provided with a function definition on construction. 00608 * The only exception are prototype objects used in function definitions themselfs 00609 * and in the function registry. 00610 * 00611 * @param fdef 00612 * Function definition to set. 00613 * 00614 */ 00615 void Definition(const FunctionDefinition* fdef); 00616 00617 00618 /** 00619 * Get function definition. 00620 * 00621 * @return 00622 * Function definition used by this function. 00623 * 00624 */ 00625 const FunctionDefinition* Definition(void) const; 00626 00627 00628 /** 00629 * Return number of variants. 00630 * 00631 * @return 00632 * Size of vector. 00633 */ 00634 int VariantsSize(void) const; 00635 00636 /** 00637 * Set signature from function definition. 00638 * 00639 * The index n refers this function's FunctionDefinition. 00640 * An exception is thrown if no such FunctionDefinition is set, as it 00641 * is the case for prototype instances. 00642 * 00643 * @param n 00644 * Variant index 00645 * 00646 * @exception Exception 00647 * - No function definition available (id 47) 00648 */ 00649 void Variant(int n); 00650 00651 00652 /** 00653 * Set signature from function definition. 00654 * 00655 * The name refers to this function's FunctionDefinition. 00656 * An exception is thrown if no such FunctionDefinition is set, as it 00657 * is the case for prototype instances. 00658 * 00659 * @param rVariantName 00660 * Variant name 00661 * 00662 * @exception Exception 00663 * - No function definition available (id 47) 00664 */ 00665 void Variant(const std::string& rVariantName); 00666 00667 00668 /** 00669 * Return pointer to assigned faudes::Signature. 00670 * 00671 * @return 00672 * Pointer to faudes::Signature. 00673 */ 00674 const Signature* Variant(void) const; 00675 00676 00677 /** 00678 * Return number of parameters with current signature. 00679 * 00680 * @return 00681 * Size of vector. 00682 */ 00683 int ParamsSize(void) const; 00684 00685 /** 00686 * Set parameter at certain position. 00687 * 00688 * Sets the internal refernce of the parameter value 00689 * at the spcefied index. The ownership of the value remains with 00690 * the caller, ie it will not be deleted in the destructor of the 00691 * function object. 00692 * You may set the parameter value to any faudes type 00693 * (classes derived from Type). A type check will be performed before the function 00694 * is executed. 00695 * 00696 * @param n 00697 * Position index of parameter 00698 * @param param 00699 * Pointer to faudes object. 00700 * 00701 * @exception Exception 00702 * - Index out of range (id 47) 00703 * - No variant set (id 47) 00704 */ 00705 void ParamValue(int n, Type* param); 00706 00707 /** 00708 * Get parameter value. 00709 * Returns a reference to the parameter value at the specified position. 00710 * 00711 * @param n 00712 * Position index of parameter. 00713 * 00714 * @exception Exception 00715 * - Index out of range (id 47) 00716 */ 00717 Type* ParamValue(int n) const; 00718 00719 /** 00720 * Construct parameter values. 00721 * 00722 * This is a convenience method to allocate faudes objects for 00723 * parameter values with the type specified by the current signature. 00724 * Note that the function does not take ownetship of the parameter values and 00725 * it is the callers responsibility to delete them when no longer required. 00726 * 00727 */ 00728 void AllocateValues(void); 00729 void AllocateValue(int i); 00730 00731 /** 00732 * Destruct parameter values. 00733 * 00734 * This is a convenience method to delete the assigned paramer values. 00735 * 00736 */ 00737 void FreeValues(void); 00738 00739 /** 00740 * Perform a type check one parameter value. 00741 * 00742 * The type check is based on c type cast and should accept any types 00743 * derived from the type given in the signature. 00744 * 00745 * @param n 00746 * Position of parameter to check 00747 * @return 00748 * True if type matches 00749 * 00750 * @exception Exception 00751 * - No variant specified (id 48) 00752 * - Number of parameter is outside the specified signature (id 48) 00753 * 00754 */ 00755 bool TypeCheck(int n); 00756 00757 /** 00758 * Perform a type check on the list of current parameter values. 00759 * 00760 * The type check is based on c type cast and should accept any types 00761 * derived from those given in the signature. 00762 * 00763 * @return 00764 * True if all parameter types matche the signature 00765 * 00766 * @exception Exception 00767 * - No variant specified (id 48) 00768 * - Number of parameters does not match signature (id 48) 00769 * 00770 */ 00771 bool TypeCheck(void); 00772 00773 /** 00774 * Perform operation. 00775 * 00776 * Runs a type check and then the actual function. 00777 * 00778 * @exception Exception 00779 * - No variant specified (id 48) 00780 * - Parameter position out of range (id 48) 00781 * - Type mismatch (id 48) 00782 * - Any other exception thrown ba the actual function (id xxx) 00783 */ 00784 void Execute(void); 00785 00786 00787 protected: 00788 00789 /** 00790 * Helper: generate typed reference for parameter. 00791 * 00792 * @param n 00793 * Parameter position to cast 00794 * @param rTypedRef 00795 * Typed reference to generyte 00796 * @tparam T 00797 * c type to use for cast 00798 * @return 00799 * True if cast succeeded. 00800 * @exception Exception 00801 * - No variant specified (id 48) 00802 * - Parameter position out of range (id 48) 00803 */ 00804 template<class T> 00805 bool DoTypeCast(int n, T*& rTypedRef) { 00806 if(!Variant()) { 00807 std::stringstream err; 00808 err << "No variant specified"; 00809 throw Exception("Function::DoTypeCast()", err.str(), 48); 00810 } 00811 if(n<0 || n >= ParamsSize()) { 00812 std::stringstream err; 00813 err << "Parameter position out of range"; 00814 throw Exception("Function::DoTypeCast()", err.str(), 48); 00815 } 00816 rTypedRef=dynamic_cast<T*>(ParamValue(n)); 00817 return rTypedRef!=NULL; 00818 } 00819 00820 /** 00821 * Method to test the type of an assigned parameter with the 00822 * specified faudes::Signature (i.e. their TypeDefinition label). 00823 * 00824 * Note: this method is called by Function::Execute() before actual function 00825 * execution via DoExecute(). It may be used to perform a dynamic cast in 00826 * preparation of DoExecute(). The latter is only called, if all types match. 00827 * 00828 * @param n 00829 * Position of parameter to check 00830 * @return 00831 * True if type matches signature. 00832 * 00833 * @exception Exception 00834 * - Signature undefined (id 48) 00835 * - Parameter number out of range (id 48) 00836 */ 00837 virtual bool DoTypeCheck(int n) = 0; 00838 00839 /** 00840 * Executes code of reimplemented method of child class(es). 00841 */ 00842 virtual void DoExecute() = 0; 00843 00844 /** 00845 * Write function-data (typeid-name of arguments) to TokenWriter. 00846 * 00847 * @param rTw 00848 * Reference to Tokenwriter. 00849 * @param rLabel 00850 * Label of section to write. 00851 * @param pContext 00852 * Context pointer, ignored 00853 * 00854 * @exception Exception 00855 * - IO Error 00856 */ 00857 void DoWrite(TokenWriter& rTw, const std::string& rLabel = "", const Type* pContext=0) const; 00858 00859 /** corresponding function definition */ 00860 const FunctionDefinition* pFuncDef; 00861 00862 /** current variant aka signature as index w.r.t. the function definition */ 00863 int mVariantIndex; 00864 00865 /** Vector of arguments. */ 00866 std::vector<Type*> mParameterValues; 00867 00868 }; // Function 00869 00870 00871 00872 /********************************************************************************************** 00873 *********************************************************************************************** 00874 *********************************************************************************************** 00875 00876 Implemention of template members functions 00877 00878 *********************************************************************************************** 00879 *********************************************************************************************** 00880 **********************************************************************************************/ 00881 00882 00883 // typedefinition constructor function 00884 template<class T> 00885 FunctionDefinition* FunctionDefinition::Constructor(const std::string& rFunctionName){ 00886 FD_DRTI("FunctionDefinition::Construct<" << typeid(T).name() << ">()"); 00887 // construct void definition 00888 FunctionDefinition* td = new FunctionDefinition(); 00889 // set its prototype object (note the 0 param in the new constructor) 00890 td->Prototype(new T(0)); 00891 // set minmum values ie the function name 00892 std::string name=rFunctionName; 00893 if(name=="") name=typeid(T).name(); 00894 td->Name(name); 00895 FD_DRTI("FunctionDefinition::Constructor<" << typeid(T).name() << ">(): done"); 00896 return(td); 00897 } 00898 00899 00900 // function definition constructor function 00901 template<class T> 00902 FunctionDefinition* FunctionDefinition::FromFile(const std::string& rFileName){ 00903 FD_DRTI("FunctionDefinition::FromFile<" << typeid(T).name() << ">()"); 00904 // construct with fallback name 00905 FunctionDefinition* td = Constructor<T>(); 00906 // read docu, incl actual name 00907 td->Read(rFileName); 00908 // done 00909 FD_DRTI("FunctionDefinition::FromFile<" << typeid(T).name() << ">(): done"); 00910 return(td); 00911 } 00912 00913 00914 } // namespace 00915 00916 00917 #endif /* FAUDES_FUNCTIONS_H */ |
libFAUDES 2.14g --- 2009-12-3 --- c++ source docu by doxygen 1.5.6