libFAUDES

Sections

Index

cfl_functions.cpp

Go to the documentation of this file.
00001 /** @file cfl_functions.cpp 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 #include "cfl_functions.h"
00024 #include "cfl_registry.h"
00025 
00026 
00027 namespace faudes{
00028 
00029 /*
00030 ********************************************************************
00031 ********************************************************************
00032 ********************************************************************
00033 
00034 Implementation of class Parameter
00035 
00036 ********************************************************************
00037 ********************************************************************
00038 ********************************************************************
00039 */
00040 
00041 // constructor, default 
00042 Parameter::Parameter(void) : 
00043   mName(""), mTDName(""), mAttr(Parameter::UnDef), mCReturn(false) 
00044 {}
00045 
00046 // constructor, by member values 
00047   Parameter::Parameter(const std::string& rName, const std::string& rTypeName, ParamAttr attr, bool cret) : 
00048     mName(rName), mTDName(rTypeName), mAttr(attr), mCReturn(cret) 
00049 {}
00050 
00051 // Desctructor 
00052 Parameter::~Parameter(void){}
00053 
00054 // get name
00055 const std::string& Parameter::Name(void) const 
00056   { return mName;}
00057 
00058 // set name
00059 void Parameter::Name(const std::string& rName) 
00060   { mName=rName;}
00061 
00062 // get type
00063 const std::string& Parameter::Type(void) const 
00064   { return mTDName;}
00065 
00066 // set type
00067 void Parameter::Type(const std::string& rTypeName) 
00068   { mTDName=rTypeName;}
00069 
00070 // get attribute
00071 const Parameter::ParamAttr& Parameter::Attribute(void) const 
00072   { return mAttr; }
00073 
00074 // set attribute
00075 void Parameter::Attribute(const ParamAttr& rAttr) 
00076   { mAttr=rAttr;}
00077 
00078 // get c ret flag
00079 bool  Parameter::CReturn(void) const 
00080   { return mCReturn; }
00081 
00082 // set c ret flag
00083 void Parameter::CReturn(bool cret) 
00084 { mCReturn=cret;}
00085 
00086 // set attribute
00087 void Parameter::Attribute(const std::string& rAttrStr) { 
00088   mAttr=Parameter::UnDef;    
00089   if(rAttrStr=="In") mAttr=Parameter::In;
00090   if(rAttrStr=="Out") mAttr=Parameter::Out;
00091   if(rAttrStr=="InOut") mAttr=Parameter::InOut;
00092 }
00093 
00094 // textual attribute
00095 std::string Parameter::AStr(Parameter::ParamAttr attr){
00096   switch(attr){
00097   case Parameter::In: return "In";
00098   case Parameter::Out: return "Out";
00099   case Parameter::InOut: return "InOut";
00100   default: break;
00101   }
00102   return "UnDef";
00103 }
00104 
00105 // textual parameter
00106 std::string Parameter::Str(void) const {
00107   std::string res = "+" + AStr(mAttr)+ "+ " + mTDName + " " + mName;
00108   return res;
00109 }
00110 
00111 // set to "undefined"
00112 void Parameter::Clear(void){
00113   mName = "";
00114   mTDName = "";
00115   mAttr = Parameter::UnDef;
00116   mCReturn=false;
00117 }
00118 
00119 // test equality
00120 bool Parameter::operator==(const Parameter& rOther) const {
00121   if(mName!=rOther.mName) return false;
00122   if(mTDName!=rOther.mTDName) return false;
00123   if(mAttr!=rOther.mAttr) return false;
00124   if(mCReturn!=rOther.mCReturn) return false;
00125   return true;
00126 }
00127 
00128 
00129 
00130 /*
00131 ********************************************************************
00132 ********************************************************************
00133 ********************************************************************
00134 
00135 Implementation of class Signature
00136 
00137 ********************************************************************
00138 ********************************************************************
00139 ********************************************************************
00140 */
00141 
00142 
00143 // faudes type
00144 FAUDES_TYPE_IMPLEMENTATION(Signature,Type)
00145 
00146 // constructor
00147 Signature::Signature(void) : Type() {}
00148 
00149 // copy constructor
00150 Signature::Signature(const Signature& rSrc) : Type()
00151 {
00152   DoAssign(rSrc);
00153 }
00154 
00155 // std faudes type
00156 Signature& Signature::DoAssign(const Signature& rSrc) {
00157   // assign my members
00158   mName=rSrc.mName;
00159   mParameters=rSrc.mParameters;
00160    // done
00161   return *this;
00162 }
00163 
00164 // std faudes type
00165 bool Signature::DoEqual(const Signature& rOther) const {
00166   // test my members
00167   if(mName!=rOther.mName) return false;
00168   if(mParameters!=rOther.mParameters) return false;
00169   return true;
00170 }
00171 
00172 
00173 // clear signature
00174 void Signature::Clear(void){
00175   FD_DRTI("Signature::Clear()");
00176   mName="";
00177   mParameters.clear();
00178 }
00179 
00180 // get name
00181 const std::string& Signature::Name(void) const{
00182   return mName;
00183 }
00184 
00185 // set name
00186 void Signature::Name(const std::string& rName){
00187   mName = rName;
00188 }
00189 
00190 // get size
00191 int Signature::Size() const{
00192   return mParameters.size();
00193 }
00194 
00195 // get parameter
00196 const Parameter& Signature::At(int n) const{
00197   // check range
00198   if((n < 0) || (n >= Size())){
00199     std::stringstream err;
00200     err << "Index out of range: " << n << std::endl;
00201     throw Exception("Signature::At()", err.str(), 47);
00202   }
00203   // return const ref
00204   return mParameters.at(n);
00205 }
00206 
00207 // set parameter
00208 void Signature::At(int n, const Parameter& rParam) {
00209   // check range
00210   if((n < 0) || (n >= Size())){
00211     std::stringstream err;
00212     err << "Index out of range: " << n << std::endl;
00213     throw Exception("Signature::At()", err.str(), 47);
00214   }
00215   // set ref
00216   mParameters[n]=rParam;
00217 }
00218 
00219 // append parameter
00220 void Signature::Append(const Parameter& rParam){
00221   mParameters.push_back(rParam);
00222 }
00223 
00224 
00225 
00226 // token io
00227 void Signature::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const{
00228   // ignore
00229   (void) rLabel;
00230   (void) pContext;
00231   // write my section
00232   rTw.WriteBegin("Signature");
00233   // name
00234   rTw.WriteString(mName);
00235   rTw << "\n";
00236   rTw << "\n";
00237   // parameter specs
00238   int intOldCols = rTw.Columns();
00239   rTw.Columns(4);
00240   for(int i=0; i<Size(); i++){
00241     rTw << mParameters.at(i).Name();
00242     rTw << mParameters.at(i).Type();
00243     switch(mParameters.at(i).Attribute()){
00244     case Parameter::In: rTw.WriteOption("In"); break;
00245     case Parameter::Out: rTw.WriteOption("Out"); break;
00246     case Parameter::InOut: rTw.WriteOption("InOut"); break;
00247     default: rTw.WriteOption("UnDef"); break;
00248     }
00249     if(mParameters.at(i).CReturn()) rTw.WriteOption("CReturn");
00250     rTw << "\n";
00251   }
00252   rTw.Columns(intOldCols);
00253   // end section
00254   rTw << "\n";
00255   rTw.WriteEnd("Signature");
00256 }
00257 
00258 // token io
00259 void Signature::DoRead(TokenReader& rTr,  const std::string& rLabel, const Type* pContext){
00260   // ignore
00261   (void) rLabel;
00262   (void) pContext;
00263   // read my section
00264   FD_DRTI("Signature::DoRead(): file " << rTr.FileName());
00265   rTr.ReadBegin("Signature");
00266   mName=rTr.ReadString();
00267   FD_DRTI("Signature::DoRead(): found " << mName);
00268   // loop parameters
00269   while(!rTr.Eos("Signature")) {
00270     std::string pname=rTr.ReadString();
00271     std::string ptype=rTr.ReadString();
00272     Parameter::ParamAttr pattr= Parameter::UnDef;
00273     bool cret=false;
00274     Token token;
00275     rTr.Peek(token);
00276     // interpret options
00277     while(token.Type()==Token::Option) {
00278       rTr.Get(token);
00279       if(token.StringValue()=="In") pattr= Parameter::In;
00280       if(token.StringValue()=="Out") pattr= Parameter::Out;
00281       if(token.StringValue()=="InOut") pattr= Parameter::InOut;
00282       if(token.StringValue()=="OutIn") pattr= Parameter::InOut;
00283       if(token.StringValue()=="CReturn") cret=true;
00284       rTr.Peek(token);
00285     }
00286     Append(Parameter(pname,ptype,pattr,cret));
00287   }
00288   // done
00289   rTr.ReadEnd("Signature");
00290   FD_DRTI("Signature::DoRead(): done");
00291 }
00292 
00293 
00294 
00295 
00296 /*
00297 ********************************************************************
00298 ********************************************************************
00299 ********************************************************************
00300 
00301 Implementation of class FunctionDefinition
00302 
00303 ********************************************************************
00304 ********************************************************************
00305 ********************************************************************
00306 */
00307 
00308 // faudes type
00309 FAUDES_TYPE_IMPLEMENTATION(FunctionDefinition,Documentation)
00310 
00311 // constructor
00312 FunctionDefinition::FunctionDefinition(const std::string& name) : 
00313   Documentation(), 
00314   mpFunction(NULL) 
00315 {
00316   Name(name);
00317 }
00318 
00319 // copy constructor
00320 FunctionDefinition::FunctionDefinition(const FunctionDefinition& rSrc) :
00321   Documentation(), 
00322   mpFunction(NULL) 
00323 {
00324   DoAssign(rSrc);
00325 }
00326 
00327 // std faudes type
00328 FunctionDefinition& FunctionDefinition::DoAssign(const FunctionDefinition& rSrc) {
00329   // assign base members
00330   Documentation::DoAssign(rSrc);
00331   // assign my members
00332   mVariants=rSrc.mVariants;
00333   mVariantIndexMap=rSrc.mVariantIndexMap;
00334   // special member
00335   if(mpFunction) delete mpFunction;
00336   mpFunction=0;
00337   if(rSrc.mpFunction) {
00338     mpFunction=rSrc.mpFunction->New();
00339     mpFunction->Definition(this);
00340   }
00341   // done
00342   return *this;
00343 }
00344 
00345 // std faudes type
00346 bool FunctionDefinition::DoEqual(const FunctionDefinition& rOther) const {
00347   // test base members
00348   if(!Documentation::DoEqual(rOther)) return false;
00349   // test my members
00350   if(mVariants!=rOther.mVariants) return false;
00351   return true;
00352 }
00353 
00354 // clear (all but prototype)
00355 void FunctionDefinition::Clear(){
00356   FD_DRTI("FunctionDefinition::Clear(): " << Name());
00357   // call base
00358   Documentation::Clear();
00359   // clear my variants
00360   mVariants.clear();
00361   mVariantIndexMap.clear();
00362 }
00363 
00364 // clear (variants only)
00365 void FunctionDefinition::ClearVariants(){
00366   FD_DRTI("FunctionDefinition::ClearVariants(): " << Name());
00367   // clear my variants
00368   mVariants.clear();
00369   mVariantIndexMap.clear();
00370 }
00371 
00372 
00373 // get prototype object
00374 const Function* FunctionDefinition::Prototype(void) const{
00375   return(mpFunction);
00376 }
00377 
00378 // set prototype object
00379 void FunctionDefinition::Prototype(Function* pFunc){
00380   // delte any existing prototype
00381   if(mpFunction) delete mpFunction;
00382   // record new prototype
00383   mpFunction = pFunc;
00384   // bail out
00385   if(!mpFunction) return;
00386   // ensure that our prototype uses us as function definition
00387   mpFunction->Definition(this);
00388 }
00389 
00390 // construct function on head
00391 Function* FunctionDefinition::NewFunction() const{
00392   FD_DRTI("FunctionDefinition::NewFunction(): name " << Name());
00393   if(!mpFunction) return NULL;
00394   return(mpFunction->New());
00395 }
00396 
00397 
00398 // # of variants
00399 int FunctionDefinition::VariantsSize() const{
00400   return(mVariants.size());
00401 }
00402 
00403 // existence of variant by name
00404 bool FunctionDefinition::ExistsVariant(const std::string& varname) const {
00405   return mVariantIndexMap.find(varname)!= mVariantIndexMap.end();
00406 }
00407 
00408 // get index by variant name
00409 int FunctionDefinition::VariantIndex(const std::string& rName) const {
00410   std::map<std::string,int>::const_iterator vit= mVariantIndexMap.find(rName);
00411   if(vit==mVariantIndexMap.end()) return -1;
00412   return vit->second;
00413 }
00414 
00415 // extend variants
00416 void FunctionDefinition::AppendVariant(const Signature& rVariant){
00417   FD_DRTI("FunctionDefinition::AppendVariant()");
00418   // assure that no variant with the same name is yet contained in the list
00419   if(ExistsVariant(rVariant.Name())) {
00420     std::stringstream err;
00421     err << "Attempt to append variant with existing name: " << rVariant.Name() << " in " << Name() << std::endl;
00422     throw Exception("FunctionDefinition::AppendVariant()", err.str(), 47);
00423   }
00424   // do append
00425   mVariantIndexMap[rVariant.Name()]=mVariants.size();
00426   mVariants.push_back(rVariant);
00427 }
00428 
00429 
00430 // get signature by variant name
00431 const Signature& FunctionDefinition::Variant(const std::string& rName) const{
00432   std::map<std::string,int>::const_iterator vit= mVariantIndexMap.find(rName);
00433   if(vit==mVariantIndexMap.end()) {
00434     std::stringstream err;
00435     err << "Access to non existing variant " << rName << " in fnct " << Name() << std::endl;
00436     throw Exception("FunctionDefinition::Variant()", err.str(), 47);
00437   }
00438   return mVariants.at(vit->second);
00439 }
00440 
00441 
00442 // get signature by variant index
00443 const Signature& FunctionDefinition::Variant(int n) const{
00444   // check range
00445   if((n < 0) || (n >= VariantsSize())){
00446     std::stringstream err;
00447     err << "Index out of range: " << n << std::endl;
00448     throw Exception("FunctionDefinition::Variant()", err.str(), 47);
00449   }
00450   return mVariants.at(n);
00451 }
00452 
00453 
00454 // token io
00455 void FunctionDefinition::DoRead(TokenReader& rTr,  const std::string& rLabel, const Type* pContext) {
00456   FD_DRTI("FunctionDefinition::DoRead()");
00457   // ignore
00458   (void) pContext;
00459   // label
00460   std::string label=rLabel;
00461   if(label=="") label="FunctionDefinition";
00462   // base can handle this
00463   Documentation::DoRead(rTr,label,pContext);
00464 }
00465 
00466 
00467 // token io
00468 void FunctionDefinition::DoReadCore(TokenReader& rTr) {
00469   FD_DRTI("FunctionDefinition::DoReadCore()");
00470   // call base
00471   Documentation::DoReadCore(rTr);  
00472   // do variants
00473   rTr.ReadBegin("VariantSignatures");
00474   while(!rTr.Eos("VariantSignatures")) {
00475     Signature sig;
00476     sig.Read(rTr);
00477     // no doublets
00478     if(ExistsVariant(sig.Name())) continue;
00479     // append variant signature
00480     AppendVariant(sig);
00481   } // end: !EOS
00482   rTr.ReadEnd("VariantSignatures");
00483 }
00484 
00485 
00486 // token io
00487 void FunctionDefinition::DoWrite(TokenWriter& rTw,  const std::string& rLabel, const Type* pContext) const {
00488   // label
00489   std::string label=rLabel;
00490   if(label=="") label="FunctionDefinition";
00491   // base can handle
00492   Documentation::DoWrite(rTw,label,pContext); 
00493 }
00494 
00495 // token io
00496 void FunctionDefinition::DoWriteCore(TokenWriter& rTw) const {
00497   FD_DRTI("FunctionDefinition::DoWriteCore(): file " << rTw.FileName());
00498   // call base core
00499   Documentation::DoWriteCore(rTw);  
00500   rTw << "\n";
00501   // write signatures
00502   rTw.WriteBegin("VariantSignatures");
00503   rTw << "\n";
00504   for(unsigned int i=0; i<mVariants.size(); i++) {
00505     mVariants.at(i).Write(rTw);
00506     rTw << "\n";
00507   }
00508   rTw.WriteEnd("VariantSignatures");
00509   rTw << "\n";
00510 }
00511 
00512 
00513 /*
00514 ********************************************************************
00515 ********************************************************************
00516 ********************************************************************
00517 
00518 Implementation of class Function
00519 
00520 ********************************************************************
00521 ********************************************************************
00522 ********************************************************************
00523 */
00524 
00525 // Constructor 
00526 Function::Function(const FunctionDefinition* fdef) : 
00527   pFuncDef(fdef), 
00528   mVariantIndex(-1) 
00529 {
00530 #ifdef FAUDES_DEBUG_RUNTIMEINTERFACE
00531   if(!pFuncDef)
00532     {FD_DRTI("Function::Function(): prototype object");}
00533   else
00534     {FD_DRTI("Function::Function(): " << pFuncDef->Name());}
00535 #endif
00536   // have default variant
00537   if(pFuncDef)
00538   if(pFuncDef->VariantsSize()>0)
00539      Variant(0);
00540 }
00541 
00542 // set function definition
00543 void Function::Definition(const FunctionDefinition* fdef) {
00544   // invalidate variant
00545   mVariantIndex = -1;
00546   mParameterValues.clear();
00547   // set
00548   pFuncDef=fdef;
00549   // report
00550 #ifdef FAUDES_DEBUG_RUNTIMEINTERFACE
00551   if(!pFuncDef)
00552     {FD_DRTI("Function::Definition(): prototype object");}
00553   else
00554     {FD_DRTI("Function::Definition(): " << pFuncDef->Name());}
00555 #endif
00556 }
00557 
00558 // get function definition
00559 const FunctionDefinition* Function::Definition(void) const {
00560   return pFuncDef;
00561 }
00562 
00563 
00564 // get signature size
00565 int Function::VariantsSize(void) const {
00566   if(!pFuncDef) return 0;
00567   return pFuncDef->VariantsSize();
00568 }
00569 
00570 // set variant signature
00571 void Function::Variant(int n) {
00572   // clear recent variant
00573   mVariantIndex=-1;
00574   mParameterValues.clear(); 
00575   // prototype object can not have a variant
00576   if(!pFuncDef) {
00577     std::stringstream err;
00578     err << "No valid function definition available" << std::endl;
00579     throw Exception("Function::Variant(n)", err.str(), 47);
00580   }
00581   // index out of ragne
00582   if(n<0 || n >= VariantsSize()) {
00583     std::stringstream err;
00584     err << "Variant index out of range" << std::endl;
00585     throw Exception("Function::Variant(n)", err.str(), 48);
00586   }
00587   // set variant 
00588   mVariantIndex=n;
00589   int nparam = pFuncDef->Variant(mVariantIndex).Size();
00590   while((int) mParameterValues.size()<nparam)
00591     mParameterValues.push_back(0);
00592 }
00593 
00594 // set variant signature
00595 void Function::Variant(const std::string& rVariantName) {
00596   // prototype object can not have a variant
00597   if(!pFuncDef) {
00598     std::stringstream err;
00599     err << "No valid function definition available" << std::endl;
00600     throw Exception("Function::Variant(name)", err.str(), 47);
00601   }
00602   // get index
00603   int varid = pFuncDef->VariantIndex(rVariantName);
00604   // detect invalid name
00605   if(varid<0) {
00606     std::stringstream err;
00607     err << "Unknown varaiant name " << rVariantName << std::endl;
00608     throw Exception("Function::Variant(name)", err.str(), 47);
00609   }
00610   // set by index
00611   Variant(varid);
00612 }
00613 
00614 // get signature
00615 const Signature* Function::Variant(void) const {
00616   if(!pFuncDef) return 0;
00617   if(mVariantIndex<0) return 0;
00618   return &pFuncDef->Variant(mVariantIndex);
00619 }
00620 
00621 // get signature size
00622 int Function::ParamsSize(void) const {
00623   return mParameterValues.size();
00624 }
00625 
00626 // set parameter value
00627 void Function::ParamValue(int n, Type* pVal){
00628   if((n < 0) || (n >= ParamsSize())){
00629     std::stringstream err;
00630     err << "Parameter index out of range: " << n << std::endl;
00631     throw Exception("Function::ParamValue()", err.str(), 47);
00632   }
00633   mParameterValues.at(n) = pVal;
00634 }
00635 
00636 // get parameter
00637 Type* Function::ParamValue(int n) const{
00638   if((n < 0) || (n >= ParamsSize())){
00639     std::stringstream err;
00640     err << "Parameter index out of range: " << n << std::endl;
00641     throw Exception("Function::ParamValue()", err.str(), 47);
00642   }
00643   return(mParameterValues.at(n));
00644 }
00645 
00646 
00647 // allocate parameter value
00648 void Function::AllocateValue(int n) {
00649   FD_DRTI("Function::AllocateValue()");
00650   if(!Variant()) {
00651     std::stringstream err;
00652     err << "No variant specified";
00653     throw Exception("Function::AllocateValue()", err.str(), 47);
00654   }
00655   if((n < 0) || (n >= ParamsSize())){
00656     std::stringstream err;
00657     err << "Parameter index out of range: " << n << std::endl;
00658     throw Exception("Function::AllocateValue()", err.str(), 47);
00659   }
00660   ParamValue(n,TypeRegistry::G()->NewObject(Variant()->At(n).Type()));
00661 }
00662 
00663 // allocate parameter value
00664 void Function::AllocateValues(void) {
00665   FD_DRTI("Function::AllocateValues()");
00666   for(int i = 0; i < ParamsSize(); i++) 
00667     AllocateValue(i);
00668 }
00669 
00670 // allocate parameter value
00671 void Function::FreeValues(void) {
00672   FD_DRTI("Function::FreeValues()");
00673   for(int i = 0; i < ParamsSize(); i++) { 
00674     delete mParameterValues.at(i);
00675     mParameterValues.at(i) =0;
00676   }
00677 }
00678 
00679 
00680 // type check wrapper
00681 bool Function::TypeCheck(int n) {
00682   FD_DRTI("Function::TypeCheck()");
00683   if(mVariantIndex<0) {
00684     std::stringstream err;
00685     err << "Variant not set" << std::endl;
00686     throw Exception("Function::TypeCheck(n)", err.str(), 48);
00687   }
00688   if(n<0 || n>= ParamsSize()) {
00689     std::stringstream err;
00690     err << "Parameter out of range" << std::endl;
00691     throw Exception("Function::Typechek(n)", err.str(), 48);
00692   }
00693   bool res=DoTypeCheck(n);
00694   FD_DRTI("Function::TypeCheck() done, ok=" << res);
00695   return res;
00696 }
00697 
00698 // type check wrapper
00699 bool Function::TypeCheck(void) {
00700   FD_DRTI("Function::TypeCheck()");
00701   if(mVariantIndex<0) {
00702     std::stringstream err;
00703     err << "Variant not set" << std::endl;
00704     throw Exception("Function::TypeCheck()", err.str(), 48);
00705   }
00706   for(int i=0; i<ParamsSize(); i++) 
00707     if(!DoTypeCheck(i)) return false;
00708   FD_DRTI("Function::TypeCheck() done, ok");
00709   return true;
00710 }
00711 
00712 // exec wrapper
00713 void Function::Execute(void){
00714   FD_DRTI("Function::Execute()");
00715   if(!Variant()) {
00716     std::stringstream err;
00717     err << "Variant not set" << std::endl;
00718     throw Exception("Function::Execute()", err.str(), 48);
00719   }
00720   for(int n=0; n<ParamsSize(); n++) {
00721     if(!DoTypeCheck(n)) {
00722       std::stringstream err;
00723       err << "Cannot cast parameter \"" << Variant()->At(n).Name() << 
00724         "\" to type \"" << Variant()->At(n).Type() << "\"";
00725       throw Exception("Function::Execute()", err.str(), 48);
00726     }
00727   }
00728   DoExecute();
00729   FD_DRTI("Function::Execute() done");
00730 }
00731 
00732 
00733 // token io (informative/debug)
00734 void Function::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const{
00735   (void) pContext;
00736   std::string label = rLabel;
00737   if(label == "") label = "Function";
00738   FD_DRTI("Function::DoWrite(): file " << rTw.FileName() << " section " << label);
00739   rTw.Columns(1);
00740   rTw.WriteBegin(label);
00741   rTw << "\n";
00742   rTw.WriteBegin("Parameters");
00743   for(int i = 0; i < ParamsSize(); i++){
00744     rTw << typeid(ParamValue(i)).name();
00745     rTw << "\n";
00746   }
00747   rTw.WriteEnd("Parameters");
00748   rTw << "\n";
00749   rTw.WriteEnd(label);
00750   FD_DRTI("Function::DoWrite(): done");
00751 }
00752 
00753 
00754 } // namespace
00755 

libFAUDES 2.16b --- 2010-9-8 --- c++ source docu by doxygen 1.6.3