Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 16, 2006, 2:00:13 PM (18 years ago)
Author:
bensch
Message:

added a Substring handler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/executor/executor_generic.h

    r9740 r9742  
    2626
    2727#include "executor.h"
    28 #include "substring.h"
    29 
    30 
    31 template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; };
    32 template<> bool fromString<bool>(const std::string& input, bool defaultValue);
    33 template<> int fromString<int>(const std::string& input, int defaultValue);
    34 template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue);
    35 template<> float fromString<float>(const std::string& input, float defaultValue);
    36 template<> char fromString<char>(const std::string& input, char defaultValue);
    37 template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue);
    38 
    39 template<typename type> type fromMulti(const MultiType& multi) { /* return defaultValue; */ };
    40 template<> bool fromMulti<bool>(const MultiType& multi);
    41 template<> int fromMulti<int>(const MultiType& multi);
    42 template<> unsigned int fromMulti<unsigned int>(const MultiType& multi);
    43 template<> float fromMulti<float>(const MultiType& multi);
    44 template<> char fromMulti<char>(const MultiType& multi);
    45 template<> const std::string& fromMulti<const std::string&>(const MultiType& multi);
    46 
    47 
    48 template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; };
    49 template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i);
    50 template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i);
    51 template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i);
    52 template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i);
    53 template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i);
    54 template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i);
    55 
    56 
    5728/**
    5829 * @brief this is a Template Class used as an evaluater.
     
    7849  ToType operator()(FromType& CallValue, const MultiType* const defaults)
    7950  {
    80     return defaultValue; /*(CallValue.size() > index) ?
    81            fromString<ToType>(CallValue[index], getDefault<ToType>(defaults, index)) :
    82     fromMulti<ToType>(defaults[index]); */
     51    return defaultValue;
    8352  }
    84   static FromType& defaultValue() { return FromType(); };
    85 };
    86 
    87 /**
    88  * @brief to remove writing errors, this function is Used.
    89  * @param sub The SubString to use
    90  * @param default The default Values.
    91  */
    92 template<> class ExecutorEvaluater <const SubString>
    93 {
    94 public:
    95   /** @brief Executes the Evaluater
    96    * @param CallValue the Value that should be converted
    97    * @param defaults the default Values.
    98    */
    99   template <typename ToType, int index>
    100   ToType operator()(const SubString& CallValue, const MultiType* const defaults)
    101   {
    102     return (CallValue.size() > index) ?
    103            fromString<ToType>(CallValue[index], getDefault<ToType>(defaults, index)) :
    104            fromMulti<ToType>(defaults[index]);
    105   }
    106   static const SubString& defaultValue() { return SubString::NullSubString; };
    107 };
    108 
     53  static FromType& defaultValue() { static FromType defaultValue; return defaultValue; };
     54};
    10955#endif /* __EXECUTOR_GENERIC_H_ */
    11056
     57#ifdef __EXECUTOR_FUNCTIONAL_NAME
    11158
    11259///////////
     
    13582   * @brief executes the Functional
    13683   * @param object the Object the action should be executed on.
    137    * @param sub the SubString to get the Parameters from.
    138    */
    139   virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const
     84   * @param eval the CallType to get the Parameters from.
     85   */
     86  virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
    14087  {
    14188    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)();
     
    181128   * @brief executes the Functional
    182129   * @param object the Object the action should be executed on.
    183    * @param sub the SubString to get the Parameters from.
    184    */
    185   virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const
    186   {
    187     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    188       Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue));
     130   * @param eval the CallType to get the Parameters from.
     131   */
     132  virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     133  {
     134    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     135      Evaluater<CallType>().template operator()<type0, 0>(eval, this->defaultValue));
    189136  };
    190137
     
    228175   * @brief executes the Functional
    229176   * @param object the Object the action should be executed on.
    230    * @param sub the SubString to get the Parameters from.
    231    */
    232   virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const
    233   {
    234     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    235       Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue),
    236       Evaluater<CallType>().template operator()<type1, 1>(sub, this->defaultValue));
     177   * @param eval the CallType to get the Parameters from.
     178   */
     179  virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     180  {
     181    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     182      Evaluater<CallType>().template operator()<type0, 0>(eval, this->defaultValue),
     183      Evaluater<CallType>().template operator()<type1, 1>(eval, this->defaultValue));
    237184  };
    238185
     
    276223   * @brief executes the Functional
    277224   * @param object the Object the action should be executed on.
    278    * @param sub the SubString to get the Parameters from.
    279    */
    280   virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const
    281   {
    282     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    283       Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue),
    284       Evaluater<CallType>().template operator()<type1, 1>(sub, this->defaultValue),
    285       Evaluater<CallType>().template operator()<type2, 2>(sub, this->defaultValue));
     225   * @param eval the CallType to get the Parameters from.
     226   */
     227  virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     228  {
     229    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     230      Evaluater<CallType>().template operator()<type0, 0>(eval, this->defaultValue),
     231      Evaluater<CallType>().template operator()<type1, 1>(eval, this->defaultValue),
     232      Evaluater<CallType>().template operator()<type2, 2>(eval, this->defaultValue));
    286233  };
    287234
     
    325272  * @brief executes the Functional
    326273  * @param object the Object the action should be executed on.
    327   * @param sub the SubString to get the Parameters from.
    328    */
    329   virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const
    330   {
    331     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    332       Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue),
    333       Evaluater<CallType>().template operator()<type1, 1>(sub, this->defaultValue),
    334       Evaluater<CallType>().template operator()<type2, 2>(sub, this->defaultValue),
    335       Evaluater<CallType>().template operator()<type3, 3>(sub, this->defaultValue));
     274  * @param eval the CallType to get the Parameters from.
     275   */
     276  virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     277  {
     278    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     279      Evaluater<CallType>().template operator()<type0, 0>(eval, this->defaultValue),
     280      Evaluater<CallType>().template operator()<type1, 1>(eval, this->defaultValue),
     281      Evaluater<CallType>().template operator()<type2, 2>(eval, this->defaultValue),
     282      Evaluater<CallType>().template operator()<type3, 3>(eval, this->defaultValue));
    336283  };
    337284
     
    376323  * @brief executes the Functional
    377324  * @param object the Object the action should be executed on.
    378   * @param sub the SubString to get the Parameters from.
    379    */
    380   virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const
    381   {
    382     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    383       Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue),
    384       Evaluater<CallType>().template operator()<type1, 1>(sub, this->defaultValue),
    385       Evaluater<CallType>().template operator()<type2, 2>(sub, this->defaultValue),
    386       Evaluater<CallType>().template operator()<type3, 3>(sub, this->defaultValue),
    387       Evaluater<CallType>().template operator()<type4, 4>(sub, this->defaultValue));
     325  * @param eval the CallType to get the Parameters from.
     326   */
     327  virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     328  {
     329    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     330      Evaluater<CallType>().template operator()<type0, 0>(eval, this->defaultValue),
     331      Evaluater<CallType>().template operator()<type1, 1>(eval, this->defaultValue),
     332      Evaluater<CallType>().template operator()<type2, 2>(eval, this->defaultValue),
     333      Evaluater<CallType>().template operator()<type3, 3>(eval, this->defaultValue),
     334      Evaluater<CallType>().template operator()<type4, 4>(eval, this->defaultValue));
    388335  };
    389336
     
    398345};
    399346
    400 //#endif /* __EXECUTOR_GENERIC_H_ */
     347#endif /* __EXECUTOR_FUNCTIONAL_NAME */
Note: See TracChangeset for help on using the changeset viewer.