Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 31, 2006, 4:20:51 PM (18 years ago)
Author:
bensch
Message:

gui: merged the gui back to the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/executor/executor_functional.h

    r7725 r8035  
    3333template<> MT_Type ExecutorParamType<const std::string&>();
    3434
    35 template<typename type> type fromString(const std::string& input, type defaultValue) {return defaultValue; };
     35template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; };
    3636template<> bool fromString<bool>(const std::string& input, bool defaultValue);
    3737template<> int fromString<int>(const std::string& input, int defaultValue);
     
    4040template<> char fromString<char>(const std::string& input, char defaultValue);
    4141template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue);
     42
     43template<typename type> type fromMulti(const MultiType& multi) { /* return defaultValue; */ };
     44template<> bool fromMulti<bool>(const MultiType& multi);
     45template<> int fromMulti<int>(const MultiType& multi);
     46template<> unsigned int fromMulti<unsigned int>(const MultiType& multi);
     47template<> float fromMulti<float>(const MultiType& multi);
     48template<> char fromMulti<char>(const MultiType& multi);
     49template<> const std::string& fromMulti<const std::string&>(const MultiType& multi);
     50
    4251
    4352template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; };
     
    8190#endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */
    8291
     92///////////
     93//// 0 ////
     94///////////
    8395//! @brief ExecutorClass, that can execute Functions without any parameters.
    8496template<class T> class __EXECUTOR_FUNCTIONAL_NAME(0) : public Executor
     
    110122  };
    111123
     124  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     125  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     126  {
     127    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)();
     128  }
     129
    112130  /**
    113131   * @brief copies the Executor
     
    120138};
    121139
     140
     141
     142///////////
     143//// 1 ////
     144///////////
    122145//! @brief ExecutorClass, that can execute Functions with one parameter.
    123146template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor
     
    139162  };
    140163
     164  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     165  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     166  {
     167    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     168             fromMulti<type0>((count > 0)? values[0] : this->defaultValue[0]) );
     169  }
     170
     171
    141172  /**
    142173   * @brief executes the Functional
     
    146177  virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const
    147178  {
    148 
    149     /* // THE VERY COOL DEBUG
    150       printf("SUB[0] : %s\n", sub[0].c_str());
    151       printf("getDefault<type0>(this->defaultValue, 0):::: %d\n", getDefault<type0>(this->defaultValue, 0));
    152       printf("VALUE: %d\n", fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)));
    153     */
    154179    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    155180      fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) );
     
    166191};
    167192
     193///////////
     194//// 2 ////
     195///////////
    168196//! @brief ExecutorClass, that can execute Functions with two parameters.
    169197template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor
     
    197225  };
    198226
     227  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     228  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     229  {
     230    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     231             fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]),
     232             fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]) );
     233  }
     234
    199235  /**
    200236   * @brief copies the Executor
     
    208244
    209245
     246///////////
     247//// 3 ////
     248///////////
    210249//! @brief ExecutorClass, that can execute Functions with three parameters.
    211250template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor
     
    240279  };
    241280
     281  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     282  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     283  {
     284    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     285             fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]),
     286             fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]),
     287             fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]) );
     288  }
     289
    242290  /**
    243291   * @brief copies the Executor
     
    252300
    253301
     302///////////
     303//// 4 ////
     304///////////
    254305//! @brief ExecutorClass, that can execute Functions with four parameters.
    255306template<class T, typename type0, typename type1, typename type2, typename type3> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor
     
    285336  };
    286337
     338  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     339  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     340  {
     341    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     342             fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]),
     343             fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]),
     344             fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]),
     345             fromMulti<type3>((count > 3) ? values[3] : this->defaultValue[3]) );
     346  }
     347
    287348  /**
    288349   * @brief copies the Executor
     
    295356};
    296357
     358
     359
     360///////////
     361//// 5 ////
     362///////////
    297363//! @brief ExecutorClass, that can execute Functions with five parameters.
    298364template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor
     
    329395  };
    330396
     397  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     398  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     399  {
     400    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     401             fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]),
     402             fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]),
     403             fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]),
     404             fromMulti<type3>((count > 3) ? values[3] : this->defaultValue[3]),
     405             fromMulti<type4>((count > 4) ? values[4] : this->defaultValue[4]) );
     406  }
     407
    331408  /**
    332409   * @brief copies the Executor
     
    344421 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    345422 */
    346 #define EXECUTOR_FUNCTIONAL_CREATOR0() \
    347 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \
     423#define EXECUTOR_FUNCTIONAL_CREATOR0(ret) \
     424template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \
    348425{ \
    349426  return new __EXECUTOR_FUNCTIONAL_NAME(0)<T>(functionPointer); \
     
    354431 * @param type0 for internal usage: the first Argument
    355432 */
    356 #define EXECUTOR_FUNCTIONAL_CREATOR1(type0) \
    357 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     433#define EXECUTOR_FUNCTIONAL_CREATOR1(ret, type0) \
     434template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    358435{ \
    359436  return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, type0##_TYPE>(functionPointer); \
     
    365442 * @param type1 for internal usage: the second Argument
    366443 */
    367 #define EXECUTOR_FUNCTIONAL_CREATOR2(type0, type1) \
    368 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     444#define EXECUTOR_FUNCTIONAL_CREATOR2(ret, type0, type1) \
     445template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    369446{ \
    370447  return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, type0##_TYPE, type1##_TYPE>(functionPointer); \
     
    377454 * @param type2 for internal usage: the third Argument
    378455 */
    379 #define EXECUTOR_FUNCTIONAL_CREATOR3(type0, type1, type2) \
    380 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     456#define EXECUTOR_FUNCTIONAL_CREATOR3(ret, type0, type1, type2) \
     457template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    381458{ \
    382459  return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE>(functionPointer); \
     
    390467 * @param type3 for internal usage: the fourth Argument
    391468 */
    392 #define EXECUTOR_FUNCTIONAL_CREATOR4(type0, type1, type2, type3) \
    393 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     469#define EXECUTOR_FUNCTIONAL_CREATOR4(ret, type0, type1, type2, type3) \
     470template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    394471{ \
    395472  return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE>(functionPointer); \
     
    404481 * @param type4 for internal usage: the fifth Argument
    405482 */
    406 #define EXECUTOR_FUNCTIONAL_CREATOR5(type0, type1, type2, type3, type4) \
    407 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     483#define EXECUTOR_FUNCTIONAL_CREATOR5(ret, type0, type1, type2, type3, type4) \
     484template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    408485{ \
    409486    return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE>(functionPointer); \
Note: See TracChangeset for help on using the changeset viewer.