Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9728 in orxonox.OLD for branches


Ignore:
Timestamp:
Sep 14, 2006, 10:31:40 PM (18 years ago)
Author:
bensch
Message:

cleanup

Location:
branches/new_class_id/src/lib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/shell/shell_command.cc

    r9727 r9728  
    4444    // copy the executor:
    4545    this->executor = executor;
    46     this->executor->setName(commandName);
    4746
    4847    for (unsigned int i = 0; i < this->executor->getParamCount(); i++)
  • branches/new_class_id/src/lib/shell/shell_command.h

    r9727 r9728  
    1010
    1111#include "executor/executor.h"
     12
     13/// THIS IS USED TO LOAD CONSTANT AND STATIC FUNCTIONS EASILY.
     14#include "executor/executor_functional.h"
     15#define EXECUTOR_FUNCTIONAL_USE_CONST
     16#include "executor/executor_functional.h"
     17#define EXECUTOR_FUNCTIONAL_USE_STATIC
     18#include "executor/executor_functional.h"
     19
     20
    1221#include "shell_completion_plugin.h"
    1322
  • branches/new_class_id/src/lib/util/executor/executor.cc

    r9727 r9728  
    1919
    2020
    21 ObjectListDefinition(ExecutorBase);
     21template<> MT_Type ExecutorParamType<bool>() { return MT_BOOL; };
     22template<> MT_Type ExecutorParamType<int>() { return MT_INT; };
     23template<> MT_Type ExecutorParamType<unsigned int>() { return MT_UINT; };
     24template<> MT_Type ExecutorParamType<float>() { return MT_FLOAT; };
     25template<> MT_Type ExecutorParamType<char>() { return MT_CHAR; };
     26template<> MT_Type ExecutorParamType<const std::string&>() { return MT_STRING; };
     27
     28
    2229
    2330/**
     
    3744  : bRetVal(hasRetVal)
    3845{
    39   this->registerObject(this, ExecutorBase::_objectList);
    40 
    4146  // What Parameters have we got
    4247  this->defaultValue[0] = param0;
  • branches/new_class_id/src/lib/util/executor/executor.h

    r9727 r9728  
    1111#include "helper_functions.h"
    1212#include "multi_type.h"
    13 #include "substring.h"
    1413#include "functor_list.h" //< MUST BE INCLUDED HERE AT LEAST ONCE.
    1514
     
    1918  Executor_Static            = 2,
    2019} Executor_Type;
     20
     21
     22
     23template<typename type> MT_Type ExecutorParamType() { return MT_EXT1; };
     24template<> MT_Type ExecutorParamType<bool>();
     25template<> MT_Type ExecutorParamType<int>();
     26template<> MT_Type ExecutorParamType<unsigned int>();
     27template<> MT_Type ExecutorParamType<float>();
     28template<> MT_Type ExecutorParamType<char>();
     29template<> MT_Type ExecutorParamType<const std::string&>();
    2130
    2231////////////////
     
    3443 *  Functions with many types (@see functor_list.h)
    3544 */
    36 class ExecutorBase : public BaseObject
     45class ExecutorBase
    3746{
    38   ObjectListDeclaration(ExecutorBase);
    3947public:
    4048  //    virtual bool operator==(const Executor* executor) const = 0;
     
    6068
    6169protected:
     70  virtual ~ExecutorBase() {};
    6271  ExecutorBase(bool hasRetVal = false,
    6372               const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
     
    109118  }
    110119
    111 
    112 
    113120protected:
    114121  Executor(bool hasRetVal,
    115            const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
     122           const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
    116123           const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
    117124           const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL,
    118125           const MultiType& param6 = MT_NULL)
    119126      : ExecutorBase(hasRetVal, param0, param1, param2, param3, param4, param5, param6)
    120   {}
    121 };
    122 
    123 
    124 
    125 #include "executor/executor_functional.h"
    126 #define EXECUTOR_FUNCTIONAL_USE_CONST
    127 #include "executor/executor_functional.h"
    128 #define EXECUTOR_FUNCTIONAL_USE_STATIC
    129 #include "executor/executor_functional.h"
     127{}}
     128;
    130129
    131130#endif /* _EXECUTOR_H */
  • branches/new_class_id/src/lib/util/executor/executor_functional.cc

    r8894 r9728  
    1414*/
    1515
    16 #include "executor.h"
     16#include "executor_functional.h"
    1717std::string ExecutorFunctional_returningString_from[7];
    1818
    19 
    20 template<> MT_Type ExecutorParamType<bool>() { return MT_BOOL; };
    21 template<> MT_Type ExecutorParamType<int>() { return MT_INT; };
    22 template<> MT_Type ExecutorParamType<unsigned int>() { return MT_UINT; };
    23 template<> MT_Type ExecutorParamType<float>() { return MT_FLOAT; };
    24 template<> MT_Type ExecutorParamType<char>() { return MT_CHAR; };
    25 template<> MT_Type ExecutorParamType<const std::string&>() { return MT_STRING; };
    2619
    2720template<> bool fromString<bool>(const std::string& input, bool defaultValue) { return isBool(input, defaultValue); };
  • branches/new_class_id/src/lib/util/executor/executor_functional.h

    r9727 r9728  
    2424
    2525#include "executor.h"
    26 
    27 template<typename type> MT_Type ExecutorParamType() { return MT_EXT1; };
    28 template<> MT_Type ExecutorParamType<bool>();
    29 template<> MT_Type ExecutorParamType<int>();
    30 template<> MT_Type ExecutorParamType<unsigned int>();
    31 template<> MT_Type ExecutorParamType<float>();
    32 template<> MT_Type ExecutorParamType<char>();
    33 template<> MT_Type ExecutorParamType<const std::string&>();
     26#include "substring.h"
     27
    3428
    3529template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; };
     
    7064
    7165#ifdef EXECUTOR_FUNCTIONAL_USE_CONST
     66 #ifdef __EXECUTOR_FUNCTIONAL_CONST_INCLUDED
     67  #define __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
     68 #else
     69  #define __EXECUTOR_FUNCTIONAL_CONST_INCLUDED
     70 #endif
    7271 #undef __EXECUTOR_FUNCTIONAL_CONST
    7372 #define __EXECUTOR_FUNCTIONAL_CONST const
    7473 #undef __EXECUTOR_FUNCTIONAL_NAME
    7574 #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount) Executor##ParamCount##Params_const
    76 #endif
    77 
    78 #ifdef EXECUTOR_FUNCTIONAL_USE_STATIC
     75//#endif /* EXECUTOR_FUNCTIONAL_USE_CONST */
     76
     77#elif defined EXECUTOR_FUNCTIONAL_USE_STATIC
    7978 #ifdef EXECUTOR_FUNCTIONAL_USE_CONST
    8079  #error you obviously do not know what you are doing !! ask the bensch
    81  #endif /* EXECUTOR_FUNCTIONAL_USE_CONST */
     80 #endif
     81
     82  #ifdef __EXECUTOR_FUNCTIONAL_STATIC_INCLUDED
     83   #define __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
     84  #else
     85   #define __EXECUTOR_FUNCTIONAL_STATIC_INCLUDED
     86  #endif
    8287
    8388#undef __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC
     
    8893 #define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER    *functionPointer
    8994
    90 #endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */
    91 
     95//#endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */
     96#else
     97 #ifdef __EXECUTOR_FUNCTIONAL_PLAIN_INCLUDED
     98  #define __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
     99 #else
     100  #define __EXECUTOR_FUNCTIONAL_PLAIN_INCLUDED
     101 #endif
     102#endif
     103
     104#ifndef __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
    92105///////////
    93106//// 0 ////
     
    122135  };
    123136
    124   /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    125   virtual void operator()(BaseObject* object, int& count, void* values) const
    126   {
    127     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)();
    128   }
    129 
    130137  /**
    131138   * @brief copies the Executor
     
    161168    this->functionPointer = functionPointer;
    162169  };
    163 
    164   /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    165   virtual void operator()(BaseObject* object, int& count, void* values) const
    166   {
    167     const MultiType* mt = (const MultiType*)values;
    168     return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    169              fromMulti<type0>((count > 0)? mt[0] : this->defaultValue[0]) );
    170   }
    171 
    172170
    173171  /**
     
    225223      (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])));
    226224  };
    227 
    228   /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    229   virtual void operator()(BaseObject* object, int& count, void* values) const
    230   {
    231     const MultiType* mt = (const MultiType*)values;
    232     return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    233              fromMulti<type0>((count > 0) ? mt[0] : this->defaultValue[0]),
    234              fromMulti<type1>((count > 1) ? mt[1] : this->defaultValue[1]) );
    235   }
    236225
    237226  /**
     
    280269      (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])));
    281270  };
    282 
    283   /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    284   virtual void operator()(BaseObject* object, int& count, void* values) const
    285   {
    286     const MultiType* mt = (const MultiType*)values;
    287     return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    288              fromMulti<type0>((count > 0) ? mt[0] : this->defaultValue[0]),
    289              fromMulti<type1>((count > 1) ? mt[1] : this->defaultValue[1]),
    290              fromMulti<type2>((count > 2) ? mt[2] : this->defaultValue[2]) );
    291   }
    292271
    293272  /**
     
    338317      (sub.size() > 3) ? fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)) : (fromMulti<type3>(this->defaultValue[3])));
    339318  };
    340 
    341   /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    342   virtual void operator()(BaseObject* object, int& count, void* values) const
    343   {
    344     const MultiType* mt = (const MultiType*)values;
    345     return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    346              fromMulti<type0>((count > 0) ? mt[0] : this->defaultValue[0]),
    347              fromMulti<type1>((count > 1) ? mt[1] : this->defaultValue[1]),
    348              fromMulti<type2>((count > 2) ? mt[2] : this->defaultValue[2]),
    349              fromMulti<type3>((count > 3) ? mt[3] : this->defaultValue[3]) );
    350   }
    351319
    352320  /**
     
    399367  };
    400368
    401   /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    402   virtual void operator()(BaseObject* object, int& count, void* values) const
    403   {
    404     const MultiType* mt = (const MultiType*)values;
    405     return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    406              fromMulti<type0>((count > 0) ? mt[0] : this->defaultValue[0]),
    407              fromMulti<type1>((count > 1) ? mt[1] : this->defaultValue[1]),
    408              fromMulti<type2>((count > 2) ? mt[2] : this->defaultValue[2]),
    409              fromMulti<type3>((count > 3) ? mt[3] : this->defaultValue[3]),
    410              fromMulti<type4>((count > 4) ? mt[4] : this->defaultValue[4]) );
    411   }
    412 
    413369  /**
    414370   * @brief copies the Executor
     
    513469 #undef EXECUTOR_FUNCTIONAL_USE_STATIC
    514470#endif
     471
     472
     473#endif /* __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS */
     474#undef __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
  • branches/new_class_id/src/lib/util/executor/executor_lua.h

    r9727 r9728  
    127127  }
    128128
    129   /**
    130    * @brief executes the Command on BaseObject
    131    * @param object the BaseObject to execute this Executor on
    132    * @param loadString ignored in this case
    133    */
    134   virtual void operator()(BaseObject* object, const SubString& = SubString()) const
    135   {
    136     PRINTF(1)("no usefull executor\n");
    137   }
    138 
    139129  virtual void operator()(BaseObject* object, lua_State*& state) const
    140130  {
     
    174164  }
    175165
    176   /**
    177    * @brief executes the Command on BaseObject
    178    * @param object the BaseObject to execute this Executor on
    179    * @param loadString ignored in this case
    180    */
    181   virtual void operator()(BaseObject* object, const SubString& = SubString()) const
    182   {
    183     PRINTF(1)("no usefull executor\n");
    184   }
    185166
    186167  virtual void operator()(BaseObject* object, lua_State*& state) const
     
    374355    this->functionPointer = function;
    375356    this->functorType = Executor_Objective;
    376   }
    377 
    378   /**
    379    * @brief executes the Command on BaseObject
    380    * @param object the BaseObject to execute this Executor on
    381    * @param loadString ignored in this case
    382    */
    383   virtual void operator()(BaseObject* object, const SubString& = SubString()) const
    384   {
    385     PRINTF(1)("no usefull executor\n");
    386357  }
    387358
  • branches/new_class_id/src/lib/util/loading/load_param.h

    r9727 r9728  
    2525
    2626#include "executor/executor.h"
     27#include "executor/executor_functional.h"
     28
    2729#include "parser/tinyxml/tinyxml.h"
    2830
     
    3032class LoadClassDescription;
    3133class LoadParamDescription;
     34class TiXmlElement;
    3235
    3336/**
Note: See TracChangeset for help on using the changeset viewer.