Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9730 in orxonox.OLD for branches/new_class_id/src/lib/util/executor


Ignore:
Timestamp:
Sep 15, 2006, 12:09:12 PM (18 years ago)
Author:
bensch
Message:

cleaner executor with evaluate function, that will be made an Object Soon.

Location:
branches/new_class_id/src/lib/util/executor
Files:
4 edited

Legend:

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

    r9728 r9730  
    6161      break;
    6262    }
     63    else
     64      this->defaultValue[i].storeString();
    6365  }
    6466}
     
    106108    {
    107109      this->defaultValue[i].setValueOf(*value[i]);
     110      this->defaultValue[i].storeString();
    108111    }
    109112  }
  • branches/new_class_id/src/lib/util/executor/executor.h

    r9728 r9730  
    1515//! an enumerator for the definition of the Type.
    1616typedef enum {
    17   Executor_Objective         = 1,
    18   Executor_Static            = 2,
     17  Executor_Objective,
     18  Executor_Static,
    1919} Executor_Type;
    2020
     
    5151  inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; };
    5252
    53   // EXECUTE
    54   /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    55   //     virtual void operator()(BaseObject* object, int& count, void* values) const = 0;
    56   /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
    57   //     virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0;
    58 
    5953  // RETRIEVE INFORMATION
    6054  /** @returns the Type of this Function (either static or objective) */
    61   inline long getType() const { return this->functorType; };
     55  inline Executor_Type getType() const { return this->functorType; };
     56
    6257  /** @returns the Count of Parameters this Executor takes */
    6358  inline unsigned int getParamCount() const { return this->paramCount; };
     
    8479
    8580protected:
    86   short                       functorType;      //!< The type of Function we've got (either static or objective).
     81  Executor_Type               functorType;      //!< The type of Function we've got (either static or objective).
    8782  unsigned int                paramCount;       //!< the count of parameters.
    8883  MultiType                   defaultValue[7];  //!< Default Values.
    8984
    90   bool                        bRetVal;          //!< True if the Executor has a return Value.
     85  const bool                  bRetVal;          //!< True if the Executor has a return Value.
    9186};
    9287
  • branches/new_class_id/src/lib/util/executor/executor_functional.cc

    r9728 r9730  
    1515
    1616#include "executor_functional.h"
    17 std::string ExecutorFunctional_returningString_from[7];
    18 
    1917
    2018template<> bool fromString<bool>(const std::string& input, bool defaultValue) { return isBool(input, defaultValue); };
     
    3937template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getFloat(); };
    4038template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); };
    41 template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { return ExecutorFunctional_returningString_from[i] = defaultValues[i].getString(); };
     39template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getStoredString(); };
    4240
    4341
  • branches/new_class_id/src/lib/util/executor/executor_functional.h

    r9728 r9730  
    5151template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i);
    5252template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i);
     53
     54
     55/**
     56 * @brief to remove writing errors, this function is Used.
     57 * @param sub The SubString to use
     58 * @param default The default Values.
     59 */
     60template<typename type, int index> type Evaluate(const SubString& sub, const MultiType* const defaults)
     61{
     62  return (sub.size() > index) ?
     63      fromString<type>(sub[index], getDefault<type>(defaults, index)) :
     64      fromMulti<type>(defaults[index]);
     65};
     66
    5367
    5468#endif /* __EXECUTOR_FUNCTIONAL_H_ */
     
    8094 #endif
    8195
    82   #ifdef __EXECUTOR_FUNCTIONAL_STATIC_INCLUDED
     96#ifdef __EXECUTOR_FUNCTIONAL_STATIC_INCLUDED
    8397   #define __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
    8498  #else
     
    103117
    104118#ifndef __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
     119
    105120///////////
    106121//// 0 ////
     
    177192  {
    178193    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    179       (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])));
     194      Evaluate<type0, 0>(sub, this->defaultValue));
    180195  };
    181196
     
    220235  {
    221236    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    222       (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
    223       (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])));
     237      Evaluate<type0, 0>(sub, this->defaultValue),
     238      Evaluate<type1, 1>(sub, this->defaultValue));
    224239  };
    225240
     
    265280  {
    266281    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    267       (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
    268       (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])),
    269       (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])));
     282      Evaluate<type0, 0>(sub, this->defaultValue),
     283      Evaluate<type1, 1>(sub, this->defaultValue),
     284      Evaluate<type2, 2>(sub, this->defaultValue));
    270285  };
    271286
     
    312327  {
    313328    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    314       (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
    315       (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])),
    316       (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])),
    317       (sub.size() > 3) ? fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)) : (fromMulti<type3>(this->defaultValue[3])));
     329      Evaluate<type0, 0>(sub, this->defaultValue),
     330      Evaluate<type1, 1>(sub, this->defaultValue),
     331      Evaluate<type2, 2>(sub, this->defaultValue),
     332      Evaluate<type3, 3>(sub, this->defaultValue));
    318333  };
    319334
     
    360375  {
    361376    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    362       (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])),
    363       (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])),
    364       (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])),
    365       (sub.size() > 3) ? fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)) : (fromMulti<type3>(this->defaultValue[3])),
    366       (sub.size() > 4) ? fromString<type4>(sub[4], getDefault<type4>(this->defaultValue, 4)) : (fromMulti<type4>(this->defaultValue[4])));
     377      Evaluate<type0, 0>(sub, this->defaultValue),
     378      Evaluate<type1, 1>(sub, this->defaultValue),
     379      Evaluate<type2, 2>(sub, this->defaultValue),
     380      Evaluate<type3, 3>(sub, this->defaultValue),
     381      Evaluate<type4, 4>(sub, this->defaultValue));
    367382  };
    368383
Note: See TracChangeset for help on using the changeset viewer.