Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Tools/Xabsl2/Xabsl2Engine/Xabsl2Symbols.cpp

Go to the documentation of this file.

    00001 /**
    00002 * @file Xabsl2Symbols.cpp
    00003 *
    00004 * Implementation of class Xabsl2Symbols and helper classes
    00005 *
    00006 * @author Martin Lötzsch
    00007 */
    00008
    00009 #include "Xabsl2Symbols.h"
    00010
    00011 Xabsl2EnumeratedInputSymbol::~Xabsl2EnumeratedInputSymbol()
    00012 {
    00013   int i;
    00014   for (i=0; i< enumElements.getSize(); i++)
    00015   {
    00016     delete enumElements[i];
    00017   }
    00018 }
    00019
    00020 Xabsl2EnumeratedOutputSymbol::~Xabsl2EnumeratedOutputSymbol()
    00021 {
    00022   int i;
    00023   for (i=0; i< enumElements.getSize(); i++)
    00024   {
    00025     delete enumElements[i];
    00026   }
    00027 }
    00028
    00029 void Xabsl2EnumeratedOutputSymbol::setActiveValue()
    00030 {
    00031   if (activeValueWasSet)
    00032   {
    00033     if (pF!=0)
    00034     {
    00035       (pI->*pF)(activeValue);
    00036     }
    00037     else
    00038     {
    00039       *pV=activeValue;
    00040     }
    00041     activeValueWasSet = false;
    00042   }
    00043 }
    00044
    00045 Xabsl2Symbols::~Xabsl2Symbols()
    00046 {
    00047   int i;
    00048   for (i=0; i< decimalInputSymbols.getSize(); i++) delete decimalInputSymbols[i];
    00049   for (i=0; i< decimalInputFunctions.getSize(); i++) delete decimalInputFunctions[i];
    00050   for (i=0; i< booleanInputSymbols.getSize(); i++) delete booleanInputSymbols[i];
    00051   for (i=0; i< enumeratedInputSymbols.getSize(); i++) delete enumeratedInputSymbols[i];
    00052   for (i=0; i< enumeratedOutputSymbols.getSize(); i++) delete enumeratedOutputSymbols[i];
    00053 }
    00054
    00055 void Xabsl2Symbols::registerDecimalInputSymbol(const char* name, const double* pVariable)
    00056 {
    00057   XABSL2_DEBUG_INIT(errorHandler.message("registering decimal input symbol \"%s\"",name));
    00058
    00059   if (decimalInputSymbols.exists(name))
    00060   {
    00061     errorHandler.error("registerDecimalInputSymbol(): symbol \"%s\" was already registered",name);
    00062     return;
    00063   }
    00064   decimalInputSymbols.append(name,new Xabsl2DecimalInputSymbol(name, pVariable));
    00065 }
    00066
    00067 void Xabsl2Symbols::registerDecimalInputSymbol
    00068 (const char* name, Xabsl2FunctionProvider* pInstance,
    00069  double (Xabsl2FunctionProvider::*pFunction)())
    00070 {
    00071   XABSL2_DEBUG_INIT(errorHandler.message("registering decimal input symbol \"%s\"",name));
    00072
    00073   if (decimalInputSymbols.exists(name))
    00074   {
    00075     errorHandler.error("registerDecimalInputSymbol(): symbol \"%s\" was already registered",name);
    00076     return;
    00077   }
    00078   decimalInputSymbols.append(name,new Xabsl2DecimalInputSymbol(name, pInstance,pFunction));
    00079 }
    00080
    00081 Xabsl2DecimalInputSymbol* Xabsl2Symbols::getDecimalInputSymbol(const char* name)
    00082 {
    00083   return decimalInputSymbols.getElement(name);
    00084 }
    00085
    00086 bool Xabsl2Symbols::existsDecimalInputSymbol(const char* name)
    00087 {
    00088   return decimalInputSymbols.exists(name);
    00089 }
    00090
    00091  int Xabsl2Symbols::numberOfDecimalInputSymbols()
    00092 {
    00093   return decimalInputSymbols.getSize();
    00094 }
    00095
    00096 const Xabsl2DecimalInputSymbol* Xabsl2Symbols::getDecimalInputSymbol(int index){
    00097   if(index < decimalInputSymbols.getSize())
    00098     return decimalInputSymbols.getElement(index);
    00099   return NULL;
    00100 }
    00101
    00102
    00103 void Xabsl2Symbols::registerDecimalInputFunction(const char* name, Xabsl2FunctionProvider* pInstance,
    00104                                                  double (Xabsl2FunctionProvider::*pFunction)())
    00105 {
    00106   XABSL2_DEBUG_INIT(errorHandler.message("registering decimal input function\"%s\"",name));
    00107
    00108   if (decimalInputFunctions.exists(name))
    00109   {
    00110     errorHandler.error("registerDecimalInputFunction(): function \"%s\" was already registered",name);
    00111     return;
    00112   }
    00113
    00114   decimalInputFunctions.append(name, new Xabsl2DecimalInputFunction(name,pInstance,pFunction));
    00115 }
    00116
    00117 void Xabsl2Symbols::registerDecimalInputFunctionParameter(const char* functionName,
    00118     const char* name, double& param)
    00119 {
    00120   XABSL2_DEBUG_INIT(errorHandler.message("registering parameter \"%s\" for decimal input function\"%s\"",name, functionName));
    00121
    00122   if (!decimalInputFunctions.exists(functionName))
    00123   {
    00124     errorHandler.error("registerDecimalInputFunctionParameter(): function \"%s\" was not registered",functionName);
    00125     return;
    00126   }
    00127   if (decimalInputFunctions.getElement(functionName)->parameters.exists(name))
    00128   {
    00129     errorHandler.error("registerDecimalInputFunctionParameter(): parameter \"%s\" was already registered",name);
    00130     return;
    00131   }
    00132
    00133   decimalInputFunctions.getElement(functionName)->parameters.append(name,param);
    00134 }
    00135
    00136 Xabsl2DecimalInputFunction* Xabsl2Symbols::getDecimalInputFunction(const char* name)
    00137 {
    00138   return decimalInputFunctions.getElement(name);
    00139 }
    00140
    00141 bool Xabsl2Symbols::existsDecimalInputFunction(const char* name)
    00142 {
    00143   return decimalInputFunctions.exists(name);
    00144 }
    00145
    00146
    00147 void Xabsl2Symbols::registerBooleanInputSymbol(const char* name, const bool* pVariable)
    00148 {
    00149   XABSL2_DEBUG_INIT(errorHandler.message("registering boolean input symbol \"%s\"",name));
    00150
    00151   if (booleanInputSymbols.exists(name))
    00152   {
    00153     errorHandler.error("registerBooleanInputSymbol(): symbol \"%s\" was already registered",name);
    00154     return;
    00155   }
    00156   booleanInputSymbols.append(name,new Xabsl2BooleanInputSymbol(name, pVariable));
    00157 }
    00158
    00159
    00160 void Xabsl2Symbols::registerBooleanInputSymbol(const char* name, Xabsl2FunctionProvider* pInstance,
    00161                                                bool (Xabsl2FunctionProvider::*pFunction)())
    00162 {
    00163   XABSL2_DEBUG_INIT(errorHandler.message("registering boolean input symbol \"%s\"",name));
    00164
    00165   if (booleanInputSymbols.exists(name))
    00166   {
    00167     errorHandler.error("registerBooleanInputSymbol(): symbol \"%s\" was already registered",name);
    00168     return;
    00169   }
    00170   booleanInputSymbols.append(name,new Xabsl2BooleanInputSymbol(name, pInstance,pFunction));
    00171 }
    00172
    00173 Xabsl2BooleanInputSymbol* Xabsl2Symbols::getBooleanInputSymbol(const char* name)
    00174 {
    00175   return booleanInputSymbols.getElement(name);
    00176 }
    00177
    00178 bool Xabsl2Symbols::existsBooleanInputSymbol(const char* name)
    00179 {
    00180   return booleanInputSymbols.exists(name);
    00181 }
    00182
    00183  int Xabsl2Symbols::numberOfBooleanInputSymbols()
    00184 {
    00185   return booleanInputSymbols.getSize();
    00186 }
    00187
    00188 const Xabsl2BooleanInputSymbol* Xabsl2Symbols::getBooleanInputSymbol(int index){
    00189   if(index < booleanInputSymbols.getSize())
    00190     return booleanInputSymbols.getElement(index);
    00191   return NULL;
    00192 }
    00193
    00194
    00195 void Xabsl2Symbols::registerEnumeratedInputSymbol(const char* name, const int* pVariable)
    00196 {
    00197   XABSL2_DEBUG_INIT(errorHandler.message("registering enumerated input symbol \"%s\"",name));
    00198
    00199   if (enumeratedInputSymbols.exists(name))
    00200   {
    00201     errorHandler.error("registerEnumeratedInputSymbol(): symbol \"%s\" was already registered",name);
    00202     return;
    00203   }
    00204   enumeratedInputSymbols.append(name,new Xabsl2EnumeratedInputSymbol(name, pVariable));
    00205 }
    00206
    00207 void Xabsl2Symbols::registerEnumeratedInputSymbol(const char* name, Xabsl2FunctionProvider* pInstance,
    00208     int (Xabsl2FunctionProvider::*pFunction)())
    00209 {
    00210   XABSL2_DEBUG_INIT(errorHandler.message("registering enumerated input symbol \"%s\"",name));
    00211
    00212   if (enumeratedInputSymbols.exists(name))
    00213   {
    00214     errorHandler.error("registerEnumeratedInputSymbol(): symbol \"%s\" was already registered",name);
    00215     return;
    00216   }
    00217   enumeratedInputSymbols.append(name,new Xabsl2EnumeratedInputSymbol(name, pInstance,pFunction));
    00218 }
    00219
    00220 Xabsl2EnumeratedInputSymbol* Xabsl2Symbols::getEnumeratedInputSymbol(const char* name)
    00221 {
    00222   return enumeratedInputSymbols.getElement(name);
    00223 }
    00224
    00225 void Xabsl2Symbols::registerEnumeratedInputSymbolEnumElement(const char* symbolName,
    00226     const char* name, int value)
    00227 {
    00228   XABSL2_DEBUG_INIT(errorHandler.message("registering enum element \"%s\" for enumerated input symbol \"%s\"",name, symbolName));
    00229
    00230   if (!enumeratedInputSymbols.exists(symbolName))
    00231   {
    00232     errorHandler.error("registerEnumeratedInputSymbolEnumElement(): symbol \"%s\" was not registered.", symbolName);
    00233     return;
    00234   }
    00235   if (enumeratedInputSymbols.getElement(symbolName)->enumElements.exists(name))
    00236   {
    00237     errorHandler.error("registerEnumeratedInputSymbolEnumElement(): enum element \"%s\" for symbol \"%s\" was already registered.", name, symbolName);
    00238     return;
    00239   }
    00240   enumeratedInputSymbols.getElement(symbolName)->enumElements.append(name, new Xabsl2EnumElement(name,value));
    00241 }
    00242
    00243 bool Xabsl2Symbols::existsEnumeratedInputSymbol(const char* name)
    00244 {
    00245   return enumeratedInputSymbols.exists(name);
    00246 }
    00247
    00248  int Xabsl2Symbols::numberOfEnumeratedInputSymbols()
    00249 {
    00250   return enumeratedInputSymbols.getSize();
    00251 }
    00252
    00253 const Xabsl2EnumeratedInputSymbol* Xabsl2Symbols::getEnumeratedInputSymbol(int index){
    00254   if(index < enumeratedInputSymbols.getSize())
    00255     return enumeratedInputSymbols.getElement(index);
    00256   return NULL;
    00257 }
    00258
    00259
    00260 void Xabsl2Symbols::registerEnumeratedOutputSymbol(const char* name, int* pVariable)
    00261 {
    00262   XABSL2_DEBUG_INIT(errorHandler.message("registering enumerated output symbol \"%s\"",name));
    00263
    00264   if (enumeratedOutputSymbols.exists(name))
    00265   {
    00266     errorHandler.error("registerEnumeratedOutputSymbol(): symbol \"%s\" was already registered",name);
    00267     return;
    00268   }
    00269   enumeratedOutputSymbols.append(name,new Xabsl2EnumeratedOutputSymbol(name, pVariable));
    00270 }
    00271
    00272 void Xabsl2Symbols::registerEnumeratedOutputSymbol(const char* name, Xabsl2FunctionProvider* pInstance,
    00273     void (Xabsl2FunctionProvider::*pFunction)(int))
    00274 {
    00275   XABSL2_DEBUG_INIT(errorHandler.message("registering enumerated output symbol \"%s\"",name));
    00276
    00277   if (enumeratedOutputSymbols.exists(name))
    00278   {
    00279     errorHandler.error("registerEnumeratedOutputSymbol(): symbol \"%s\" was already registered",name);
    00280     return;
    00281   }
    00282   enumeratedOutputSymbols.append(name,new Xabsl2EnumeratedOutputSymbol(name, pInstance,pFunction));
    00283 }
    00284
    00285 Xabsl2EnumeratedOutputSymbol* Xabsl2Symbols::getEnumeratedOutputSymbol(const char* name)
    00286 {
    00287   return enumeratedOutputSymbols.getElement(name);
    00288 }
    00289
    00290 void Xabsl2Symbols::registerEnumeratedOutputSymbolEnumElement(const char* symbolName,
    00291     const char* name, int value)
    00292 {
    00293   XABSL2_DEBUG_INIT(errorHandler.message("registering enum element \"%s\" for enumerated output symbol \"%s\"",name, symbolName));
    00294
    00295   if (!enumeratedOutputSymbols.exists(symbolName))
    00296   {
    00297     errorHandler.error("registerEnumeratedOutputSymbolEnumElement(): symbol \"%s\" was not registered.", symbolName);
    00298     return;
    00299   }
    00300   if (enumeratedOutputSymbols.getElement(symbolName)->enumElements.exists(name))
    00301   {
    00302     errorHandler.error("registerEnumeratedOutputSymbolEnumElement(): enum element \"%s\" for symbol \"%s\" was already registered.", name, symbolName);
    00303     return;
    00304   }
    00305   enumeratedOutputSymbols.getElement(symbolName)->enumElements.append(name, new Xabsl2EnumElement(name,value));
    00306 }
    00307
    00308 bool Xabsl2Symbols::existsEnumeratedOutputSymbol(const char* name)
    00309 {
    00310   return enumeratedOutputSymbols.exists(name);
    00311 }
    00312
    00313
    00314 void Xabsl2Symbols::setOutputSymbols()
    00315 {
    00316   for (int i=0;i<enumeratedOutputSymbols.getSize();i++)
    00317     enumeratedOutputSymbols[i]->setActiveValue();
    00318 }