Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9748 in orxonox.OLD for branches/new_class_id/src/lib


Ignore:
Timestamp:
Sep 16, 2006, 10:09:59 PM (18 years ago)
Author:
bensch
Message:

completely documented Executors

Location:
branches/new_class_id/src/lib/util
Files:
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/Makefile.am

    r9746 r9748  
    1010                executor/executor_lua_state.cc \
    1111                executor/executor_substring.cc
    12 
    13 #               executor/executor_functional.cc
    1412
    1513libORXlibutil_a_SOURCES = \
  • branches/new_class_id/src/lib/util/executor/executor.cc

    r9733 r9748  
    1818#include "executor.h"
    1919
     20/** @returns the Type of an Argument taken by the Executor in this case MT_BOOL */
    2021template<> MT_Type ExecutorParamType<bool>() { return MT_BOOL; };
     22/** @returns the Type of an Argument taken by the Executor in this case MT_INT*/
    2123template<> MT_Type ExecutorParamType<int>() { return MT_INT; };
     24/** @returns the Type of an Argument taken by the Executor in this case MT_UINT*/
    2225template<> MT_Type ExecutorParamType<unsigned int>() { return MT_UINT; };
     26/** @returns the Type of an Argument taken by the Executor in this case MT_FLOAT*/
    2327template<> MT_Type ExecutorParamType<float>() { return MT_FLOAT; };
     28/** @returns the Type of an Argument taken by the Executor in this case MT_CHAR*/
    2429template<> MT_Type ExecutorParamType<char>() { return MT_CHAR; };
     30/** @returns the Type of an Argument taken by the Executor in this case MT_STRING*/
    2531template<> MT_Type ExecutorParamType<const std::string&>() { return MT_STRING; };
  • branches/new_class_id/src/lib/util/executor/executor.h

    r9737 r9748  
    1616
    1717
    18 
     18/** @returns the Type of an Argument taken by the Executor */
    1919template<typename type> MT_Type ExecutorParamType() { return MT_EXT1; };
    2020template<> MT_Type ExecutorParamType<bool>();
     
    6666  inline bool hasRetVal() const { return bRetVal; };
    6767
    68   /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     68  /** executes a Command. @param object the Object, @param values The Value of type CallType to pass to the Executor. */
    6969  virtual void operator()(BaseClass* object, CallType& values) const = 0;
    7070
     
    7676   * @param value3 the fourth default value
    7777   * @param value4 the fifth default value
     78   * @param value5 the sixth default value
     79   * @param value6 the seventh default value
    7880   * @returns itself
    7981   * @note: THIS FUNCTION WILL BE REPLACED BY A CONFIGURATOR (most probably).
     
    109111protected:
    110112  //! Now follows a List of Executor Constructors, to be fast in creating.
     113  //! Creates an Executor with no Argument.
    111114  Executor(bool hasRetVal, FunctionType functionType = FunctionMember)
    112115  : bRetVal(hasRetVal), paramCount(0), functionType(functionType)
    113116  { };
    114117
     118  //! Creates an Executor with 1 Argument.
    115119  Executor(bool hasRetVal, const MultiType& param0,
    116120           FunctionType functionType = FunctionMember)
     
    120124  };
    121125
     126  //! Creates an Executor with 2 Arguments.
    122127  Executor(bool hasRetVal, const MultiType& param0, const MultiType& param1,
    123128           FunctionType functionType = FunctionMember)
     
    128133  };
    129134
     135  //! Creates an Executor with 3 Arguments.
    130136  Executor(bool hasRetVal, const MultiType& param0, const MultiType& param1,
    131137           const MultiType& param2,
     
    138144  };
    139145
     146  //! Creates an Executor with 4 Arguments.
    140147  Executor(bool hasRetVal, const MultiType& param0, const MultiType& param1,
    141148           const MultiType& param2, const MultiType& param3,
     
    149156  };
    150157
     158  //! Creates an Executor with 5 Arguments.
    151159  Executor(bool hasRetVal, const MultiType& param0, const MultiType& param1,
    152160           const MultiType& param2, const MultiType& param3,
     
    162170  };
    163171
     172  //! Creates an Executor with 6 Arguments.
    164173  Executor(bool hasRetVal, const MultiType& param0, const MultiType& param1,
    165174           const MultiType& param2, const MultiType& param3,
     
    176185  };
    177186
     187  //! Creates an Executor with 7 Arguments.
    178188  Executor(bool hasRetVal, const MultiType& param0, const MultiType& param1,
    179189           const MultiType& param2, const MultiType& param3,
  • branches/new_class_id/src/lib/util/executor/executor_const_member.h

    r9745 r9748  
    11/*!
    2  * @file executor_member.h
     2 * @file executor_const_member.h
    33 * Definition of an Executor to Member Functions
    44 */
  • branches/new_class_id/src/lib/util/executor/executor_generic.h

    r9747 r9748  
    4949  static ToType getValue(FromType& CallValue, const MultiType* const defaults)
    5050  {
    51     assert(0 && "Might be by mistake");
     51    assert(0 && "Might want to extend the ExecutorEvaluater::getValue function in an 'Explicit Specialized Template Class'");
    5252    return defaultValue;
    5353  }
     54  /** @param @storeTo Stores the returned value here. @param value The Value to Store. @note invers of getValue */
     55  static void storeRet(FromType& storeTo, FromType value)
     56  {
     57    assert (0 && "Might want to extend the ExecutorEvaluater::storeRet function in an 'Explicit Specialized Template Class'");
     58  }
     59  /** @returns the Default Value of ToType */
    5460  static FromType& defaultValue() { static FromType defaultValue; return defaultValue; };
    5561};
  • branches/new_class_id/src/lib/util/executor/executor_lua_state.cc

    r9743 r9748  
    2222std::string temp[7];
    2323
     24/**
     25 * @brief Converts a lua_State into any type.
     26 * @param state the State to get the value from.
     27 * @param index the position inside of the lua_State to get the value from.
     28 * @returns The value if found.
     29 */
    2430template<typename type> type fromLua(lua_State* state, int index) { type *obj = Lunar<type>::check(state, 1); lua_remove(state, 1); return obj;};
     31/**
     32 * @brief Converts a lua_State into any type.
     33 * @param state the State to get the value from.
     34 * @param index the position inside of the lua_State to get the value from.
     35 * @returns The value if found.
     36 */
    2537template<> bool fromLua<bool>(lua_State* state, int index) { return lua_toboolean(state, index); };
     38/**
     39 * @brief Converts a lua_State into any type.
     40 * @param state the State to get the value from.
     41 * @param index the position inside of the lua_State to get the value from.
     42 * @returns The value if found.
     43 */
    2644template<> int fromLua<int>(lua_State* state, int index) { return (int)lua_tonumber(state, index); };
     45/**
     46 * @brief Converts a lua_State into any type.
     47 * @param state the State to get the value from.
     48 * @param index the position inside of the lua_State to get the value from.
     49 * @returns The value if found.
     50 */
    2751template<> unsigned int fromLua<unsigned int>(lua_State* state, int index) { return (unsigned int)lua_tonumber(state, index); };
     52/**
     53 * @brief Converts a lua_State into any type.
     54 * @param state the State to get the value from.
     55 * @param index the position inside of the lua_State to get the value from.
     56 * @returns The value if found.
     57 */
    2858template<> float fromLua<float>(lua_State* state, int index) { return (float)lua_tonumber(state, index); };
     59/**
     60 * @brief Converts a lua_State into any type.
     61 * @param state the State to get the value from.
     62 * @param index the position inside of the lua_State to get the value from.
     63 * @returns The value if found.
     64 */
    2965template<> char fromLua<char>(lua_State* state, int index) { return (char)lua_tonumber(state, index); };
     66/**
     67 * @brief Converts a lua_State into any type.
     68 * @param state the State to get the value from.
     69 * @param index the position inside of the lua_State to get the value from.
     70 * @returns The value if found.
     71 */
    3072template<> const std::string& fromLua<const std::string&>(lua_State* state, int index) { temp[index] = lua_tostring(state, index); return temp[index]; };
    3173
    3274
     75
     76
     77/**
     78 * @brief writes a value into a lua_State.
     79 * @param state the state to write into.
     80 * @param value the Value of type to write into the State.
     81 */
    3382template<typename type> void toLua(lua_State* state, type value) { Lunar<type>::push(state, value, false); };
     83/**
     84 * @brief writes a value into a lua_State.
     85 * @param state the state to write into.
     86 * @param value the Value of type to write into the State.
     87 */
    3488template<> void toLua<bool>(lua_State* state, bool value) { lua_pushboolean(state, (int) value); };
     89/**
     90 * @brief writes a value into a lua_State.
     91 * @param state the state to write into.
     92 * @param value the Value of type to write into the State.
     93 */
    3594template<> void toLua<int>(lua_State* state, int value)  { lua_pushnumber(state, (lua_Number) value); };
     95/**
     96 * @brief writes a value into a lua_State.
     97 * @param state the state to write into.
     98 * @param value the Value of type to write into the State.
     99 */
    36100template<> void toLua<unsigned int>(lua_State* state, unsigned int value){ lua_pushnumber(state, (lua_Number) value); };
     101/**
     102 * @brief writes a value into a lua_State.
     103 * @param state the state to write into.
     104 * @param value the Value of type to write into the State.
     105 */
    37106template<> void toLua<float>(lua_State* state, float value) { lua_pushnumber(state, (lua_Number) value); };
     107/**
     108 * @brief writes a value into a lua_State.
     109 * @param state the state to write into.
     110 * @param value the Value of type to write into the State.
     111 */
    38112template<> void toLua<char>(lua_State* state, char value) { lua_pushnumber(state, (lua_Number) value); };
     113/**
     114 * @brief writes a value into a lua_State.
     115 * @param state the state to write into.
     116 * @param value the Value of type to write into the State.
     117 */
    39118template<> void toLua<const std::string&>(lua_State* state, const std::string& value) { lua_pushstring (state, value.c_str()); }
  • branches/new_class_id/src/lib/util/executor/executor_lua_state.h

    r9747 r9748  
    11/*!
    2  * @file executor_generic.h
    3  * Definition of a Generic Executor
     2 * @file executor_lua_state.h
     3 * Definition of a Executor that takes lua_State* as input.
    44 */
    55
     
    3232 #undef FUNCTOR_CALL_TYPE
    3333#endif
     34//! Define the Functor call type as lua_State*.
    3435#define FUNCTOR_CALL_TYPE lua_State*
    35 
    3636
    3737template<typename type> type fromLua(lua_State* state, int index);
     
    6464    return (fromLua<ToType>(CallValue, index+1));
    6565  }
     66  /**
     67   * @param state the state to write into
     68   * @param value the Value to write there.
     69   */
    6670  template <typename FromType>
    6771  static void storeRet(lua_State*& state, FromType value)
     
    6973    toLua<FromType>(state, value);
    7074  }
     75  /** @returns the Null Value of a lua_State*, namely (pointer-type) NULL */
    7176  static lua_State*& defaultValue() { static lua_State* nullState; return nullState; };
    7277};
  • branches/new_class_id/src/lib/util/executor/executor_static.h

    r9745 r9748  
    11/*!
    2  * @file executor_member.h
    3  * Definition of an Executor to Member Functions
     2 * @file executor_static.h
     3 * Definition of an Executor to Static Functions (either Static-Class or C-Style)
    44 */
    55/*
  • branches/new_class_id/src/lib/util/executor/executor_substring.cc

    r9742 r9748  
    1717#include "helper_functions.h"
    1818
     19/**
     20 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     21 * @param input the input as a String.
     22 * @param defaultValue the Default Value set, if the input could not be converted into type.
     23 * @returns either the converted value or defaultValue.
     24 */
    1925template<> bool fromString<bool>(const std::string& input, bool defaultValue) { return isBool(input, defaultValue); };
     26/**
     27 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     28 * @param input the input as a String.
     29 * @param defaultValue the Default Value set, if the input could not be converted into type.
     30 * @returns either the converted value or defaultValue.
     31 */
    2032template<> int fromString<int>(const std::string& input, int defaultValue) { return isInt(input, defaultValue); };
     33/**
     34 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     35 * @param input the input as a String.
     36 * @param defaultValue the Default Value set, if the input could not be converted into type.
     37 * @returns either the converted value or defaultValue.
     38 */
    2139template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue) { return isInt(input, defaultValue); };
     40/**
     41 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     42 * @param input the input as a String.
     43 * @param defaultValue the Default Value set, if the input could not be converted into type.
     44 * @returns either the converted value or defaultValue.
     45 */
    2246template<> float fromString<float>(const std::string& input, float defaultValue) { return isFloat(input, defaultValue); };
     47/**
     48 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     49 * @param input the input as a String.
     50 * @param defaultValue the Default Value set, if the input could not be converted into type.
     51 * @returns either the converted value or defaultValue.
     52 */
    2353template<> char fromString<char>(const std::string& input, char defaultValue) { return isInt(input, defaultValue); };
     54/**
     55 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     56 * @param input the input as a String.
     57 * @param defaultValue the Default Value set, if the input could not be converted into type.
     58 * @returns either the converted value or defaultValue.
     59 */
    2460template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { return (input.size() > 0) ? input : defaultValue; };
    2561
    2662
     63/**
     64 * @brief converts to any type from a MultiType
     65 * @param multi the MultiType to convert.
     66 * @returns the converted Value.
     67 */
    2768template<> bool fromMulti<bool>(const MultiType& multi) { return multi.getBool(); };
     69/**
     70 * @brief converts to any type from a MultiType
     71 * @param multi the MultiType to convert.
     72 * @returns the converted Value.
     73 */
    2874template<> int fromMulti<int>(const MultiType& multi) { return multi.getInt(); }
     75/**
     76 * @brief converts to any type from a MultiType
     77 * @param multi the MultiType to convert.
     78 * @returns the converted Value.
     79 */
    2980template<> unsigned int fromMulti<unsigned int>(const MultiType& multi) { return multi.getInt(); };
     81/**
     82 * @brief converts to any type from a MultiType
     83 * @param multi the MultiType to convert.
     84 * @returns the converted Value.
     85 */
    3086template<> float fromMulti<float>(const MultiType& multi) { return multi.getFloat(); };
     87/**
     88 * @brief converts to any type from a MultiType
     89 * @param multi the MultiType to convert.
     90 * @returns the converted Value.
     91 */
    3192template<> char fromMulti<char>(const MultiType& multi) { return multi.getChar(); };
     93/**
     94 * @brief converts to any type from a MultiType
     95 * @param multi the MultiType to convert.
     96 * @returns the converted Value.
     97 */
    3298template<> const std::string& fromMulti<const std::string&>(const MultiType& multi) { return multi.getConstString(); };
    3399
    34100
     101/**
     102 * @brief retrieves a default value from an array of default values, at possition i.
     103 * @param defaultValues the Array of default values.
     104 * @param i the index.
     105 * @returns the Default Value at Position i
     106 */
    35107template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getBool(); };
     108/**
     109 * @brief retrieves a default value from an array of default values, at possition i.
     110 * @param defaultValues the Array of default values.
     111 * @param i the index.
     112 * @returns the Default Value at Position i
     113 */
    36114template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); };
     115/**
     116 * @brief retrieves a default value from an array of default values, at possition i.
     117 * @param defaultValues the Array of default values.
     118 * @param i the index.
     119 * @returns the Default Value at Position i
     120 */
    37121template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); };
     122/**
     123 * @brief retrieves a default value from an array of default values, at possition i.
     124 * @param defaultValues the Array of default values.
     125 * @param i the index.
     126 * @returns the Default Value at Position i
     127 */
    38128template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getFloat(); };
     129/**
     130 * @brief retrieves a default value from an array of default values, at possition i.
     131 * @param defaultValues the Array of default values.
     132 * @param i the index.
     133 * @returns the Default Value at Position i
     134 */
    39135template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); };
     136/**
     137 * @brief retrieves a default value from an array of default values, at possition i.
     138 * @param defaultValues the Array of default values.
     139 * @param i the index.
     140 * @returns the Default Value at Position i
     141 */
    40142template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getStoredString(); };
    41 
    42 
    43 
    44 
    45 
    46 
    47 
    48 /**
    49  * A LITTLE TESTING SUITE FOR THE EXECUTOR.
    50  *
    51 #include "executor/executor_functional.h"
    52 
    53 #define EXECUTOR_FUNCTIONAL_USE_STATIC
    54 #include "executor/executor_functional.h"
    55 
    56 class TestClass : public BaseObject
    57 {
    58   public:
    59     TestClass() {};
    60 
    61     void printTest() { printf ("TEST\n"); };
    62     void printTestInt(int i) { printf ("%d\n", i); };
    63     void printTestBool(bool b) { printf("%d\n", (int)b); };
    64     void printTwoVals(int b, int i) { printf ("%d %d\n", b, i); };
    65     void printStrings(const std::string& name) { printf("String:: '%s'\n", name.c_str()); };
    66     static void printStatic() { printf("STATIC\n");};
    67 };
    68 
    69 void TEST()
    70 {
    71   TestClass test;
    72   SubString testStrings("1 SCHEISSE, 2, 3", ",", SubString::WhiteSpaces, false);
    73   (*createExecutor<TestClass>(&TestClass::printTest))(&test, testStrings);
    74   (*createExecutor<TestClass>(&TestClass::printTestInt))(&test, testStrings);
    75   (*createExecutor<TestClass>(&TestClass::printTestBool))(&test, testStrings);
    76   (*createExecutor<TestClass>(&TestClass::printTwoVals))(&test, testStrings);
    77   (*createExecutor<TestClass>(&TestClass::printStatic))(&test, testStrings);
    78   (*createExecutor<TestClass>(&TestClass::printStrings))(&test, testStrings);
    79 
    80 }
    81 */
  • branches/new_class_id/src/lib/util/executor/executor_substring.h

    r9747 r9748  
    11/*!
    2  * @file executor_generic.h
     2 * @file executor_substring.h
    33 * Definition of a Generic Executor
    44 */
     
    3030 #undef FUNCTOR_CALL_TYPE
    3131#endif
     32//! Use SubString as the FUNCTION_CALL_TYPE so that we can easily extend the Engine.
    3233#define FUNCTOR_CALL_TYPE const SubString
    3334
     35/**
     36 * @brief converts an input string into a value, if no value was converted, uses defaultValue.
     37 * @param input the input as a String.
     38 * @param defaultValue the Default Value set, if the input could not be converted into type.
     39 * @returns either the converted value or defaultValue.
     40 */
    3441template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; };
    3542template<> bool fromString<bool>(const std::string& input, bool defaultValue);
     
    4047template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue);
    4148
     49/**
     50 * @brief converts to any type from a MultiType
     51 * @param multi the MultiType to convert.
     52 * @returns the converted Value.
     53 */
    4254template<typename type> type fromMulti(const MultiType& multi) { /* return defaultValue; */ };
    4355template<> bool fromMulti<bool>(const MultiType& multi);
     
    4860template<> const std::string& fromMulti<const std::string&>(const MultiType& multi);
    4961
    50 
     62/**
     63 * @brief retrieves a default value from an array of default values, at possition i.
     64 * @param defaultValues the Array of default values.
     65 * @param i the index.
     66 * @returns the Default Value at Position i
     67 */
    5168template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; };
    5269template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i);
     
    7794           fromMulti<ToType>(defaults[index]);
    7895  }
     96  /** @returns the default Value of a SubString, namely NullSubString or SubString() */
    7997  static const SubString& defaultValue() { return SubString::NullSubString; };
    8098};
  • branches/new_class_id/src/lib/util/executor/executor_xml.h

    r9735 r9748  
    5454   * @brief executes the Command on BaseObject
    5555   * @param object the BaseObject to execute this Executor on
    56    * @param root ignored in this case
     56   * @param element ignored in this case
    5757   */
    5858  virtual void operator()(BaseObject* object, const TiXmlElement*& element) const
     
    6464
    6565private:
    66   void    (T::*functionPointer)(const TiXmlElement*);  //!< The functionPointer to the function to be called
     66  void    (T::*functionPointer)(const TiXmlElement*);  //!< The functionPointer to the function to be called.
    6767  const   TiXmlElement* element;                       //!< The XML-element to call.
    68   std::string           paramName;
     68  std::string           paramName;                     //!< The Name of the Parameter this Executor should call.
    6969};
    7070
  • branches/new_class_id/src/lib/util/executor/functor_const_member.h

    r9745 r9748  
    11/*!
    2  * @file functor_member.h
     2 * @file functor_const_member.h
    33 * Definition of an Functor
    44 */
  • branches/new_class_id/src/lib/util/executor/functor_list.h

    r9740 r9748  
     1/*!
     2 * @file functor_list.h
     3 * all the Different types of Functions one can include by using a simple createExecutor call
     4 * with a FunctionPointer as Argument
     5 */
    16/*
    27   orxonox - the future of 3D-vertical-scrollers
     
    1015*/
    1116
    12 /*!
    13  * @file functors_list.h
    14  * all the Different types of Functions one can include by using a simple createExecutor call
    15  * with a FunctionPointer as Argument
    16  */
    1717
    1818#ifdef FUNCTOR_LIST
  • branches/new_class_id/src/lib/util/executor/functor_static.h

    r9745 r9748  
    11/*!
    2  * @file functor_member.h
    3  * Definition of an Functor
     2 * @file functor_static.h
     3 * Definition of Functors to Functions of Static Type
    44 */
    55
Note: See TracChangeset for help on using the changeset viewer.