Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7721 in orxonox.OLD


Ignore:
Timestamp:
May 19, 2006, 4:05:41 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: introduced the absolutely new, much faster, more templated, and easier to look at Executor, and use it directly inside the LoadParam-Class

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/Makefile.am

    r7716 r7721  
    1515                util/multi_type.cc \
    1616                util/executor/executor.cc \
     17                util/executor/executor_functional.cc \
    1718                \
    1819                util/loading/resource_manager.cc \
  • trunk/src/lib/util/executor/executor.cc

    r7714 r7721  
    3333                   const MultiType& param4)
    3434{
    35 //  this->setClassID(CL_EXECUTOR, "Executor");
     35  this->setClassID(CL_EXECUTOR, "Executor");
    3636
    3737  // What Parameters have we got
  • trunk/src/lib/util/executor/executor_functional.h

    r7720 r7721  
    2323#define __EXECUTOR_FUNCTIONAL_H_
    2424
    25 
     25#include "base_object.h"
     26#include "multi_type.h"
     27#include "executor.h"
    2628
    2729template<typename type> MT_Type ExecutorParamType() { return MT_EXT1; };
    28 template<> MT_Type ExecutorParamType<bool>() { return MT_EXT1; };
    29 template<> MT_Type ExecutorParamType<int>() { return MT_INT; };
    30 template<> MT_Type ExecutorParamType<unsigned int>() { return MT_UINT; };
    31 template<> MT_Type ExecutorParamType<float>() { return MT_FLOAT; };
    32 template<> MT_Type ExecutorParamType<char>() { return MT_CHAR; };
    33 template<> MT_Type ExecutorParamType<const std::string&>() { return MT_STRING; };
     30template<> MT_Type ExecutorParamType<bool>();
     31template<> MT_Type ExecutorParamType<int>();
     32template<> MT_Type ExecutorParamType<unsigned int>();
     33template<> MT_Type ExecutorParamType<float>();
     34template<> MT_Type ExecutorParamType<char>();
     35template<> MT_Type ExecutorParamType<const std::string&>();
    3436
    3537template<typename type> type fromString(const std::string& input, type defaultValue) {return defaultValue; };
    36 template<> bool fromString<bool>(const std::string& input, bool defaultValue) { return isBool(input, defaultValue); };
    37 template<> int fromString<int>(const std::string& input, int defaultValue) { return isInt(input, defaultValue); };
    38 template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue) { return isInt(input, defaultValue); };
    39 template<> float fromString<float>(const std::string& input, float defaultValue) { return isFloat(input, defaultValue); };
    40 template<> char fromString<char>(const std::string& input, char defaultValue) { return isInt(input, defaultValue); };
    41 template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { static std::string retVal = isString(input, defaultValue); return retVal; };
     38template<> bool fromString<bool>(const std::string& input, bool defaultValue);
     39template<> int fromString<int>(const std::string& input, int defaultValue);
     40template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue);
     41template<> float fromString<float>(const std::string& input, float defaultValue);
     42template<> char fromString<char>(const std::string& input, char defaultValue);
     43template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue);
    4244
    4345template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; };
    44 template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getBool(); };
    45 template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); };
    46 template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); };
    47 template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getFloat(); };
    48 template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); };
    49 template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { static std::string retVal = defaultValues[i].getString(); return retVal; };
     46template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i);
     47template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i);
     48template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i);
     49template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i);
     50template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i);
     51template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i);
    5052
    5153#endif /* __EXECUTOR_FUNCTIONAL_H_ */
  • trunk/src/lib/util/loading/load_param.cc

    r7474 r7721  
    2828 * @param executor the Executor, that executes the loading procedure.
    2929 */
    30 CLoadParam::CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, const Executor& executor, bool inLoadCycle)
     30CLoadParam::CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, Executor* executor, bool inLoadCycle)
    3131  :  paramName(paramName), object(object)
    3232{
     
    4343
    4444  // set the Executor.
    45   this->executor = executor.clone();
     45  this->executor = executor;
    4646
    4747  //if (this->executor)
  • trunk/src/lib/util/loading/load_param.h

    r7221 r7721  
    2525
    2626#include "executor/executor.h"
     27
     28/// HACK HACK TAKE THIS INTO THE EXECUTOR
     29#include "executor/executor_functional.h"
     30#define EXECUTOR_FUNCTIONAL_USE_STATIC
     31#include "executor/executor_functional.h"
     32
    2733#include "executor/executor_specials.h"
    2834
     
    4551 */
    4652#define LoadParam(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    47          CLoadParam(ROOT, PARAMETER_NAME, OBJECT, ExecutorObjective<CLASS>(&CLASS::FUNCTION), false)
     53         CLoadParam(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS>(&CLASS::FUNCTION), false)
    4854
    4955#define LoadParam_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    50          CLoadParam(ROOT, PARAMETER_NAME, OBJECT, ExecutorObjective<CLASS>(&CLASS::FUNCTION), true)
     56         CLoadParam(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS>(&CLASS::FUNCTION), true)
    5157
    5258#define LoadParamXML(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    53          CLoadParam(ROOT, PARAMETER_NAME, OBJECT, ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), false)
     59         CLoadParam(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), false)
    5460
    5561#define LoadParamXML_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    56          CLoadParam(ROOT, PARAMETER_NAME, OBJECT, ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), true)
     62         CLoadParam(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), true)
    5763
    5864
     
    8793{
    8894  public:
    89     CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, const Executor& executor, bool inLoadCycle = false);
     95    CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, Executor* executor, bool inLoadCycle = false);
    9096    virtual ~CLoadParam();
    9197
  • trunk/src/orxonox.cc

    r7720 r7721  
    414414bool showGui = false;
    415415
    416 /// HACK HACK TEST
    417 
    418 
    419 #include "executor/executor_functional.h"
    420 
    421 #define EXECUTOR_FUNCTIONAL_USE_STATIC
    422 #include "executor/executor_functional.h"
    423 
    424 class TestClass : public BaseObject
    425 {
    426 public:
    427   TestClass() {};
    428 
    429   void printTest() { printf ("TEST\n"); };
    430   void printTestInt(int i) { printf ("%d\n", i); };
    431   void printTestBool(bool b) { printf("%d\n", (int)b); };
    432   void printTwoVals(int b, int i) { printf ("%d %d\n", b, i); };
    433   void printStrings(const std::string& name) { printf("String:: '%s'\n", name.c_str()); };
    434   static void printStatic() { printf("STATIC\n");};
    435 };
    436 
    437 void TEST()
    438 {
    439   TestClass test;
    440   SubString testStrings("1, 2, 3", ",", SubString::WhiteSpaces, false);
    441   (*createExecutor<TestClass>(&TestClass::printTest))(&test, testStrings);
    442   (*createExecutor<TestClass>(&TestClass::printTestInt))(&test, testStrings);
    443   (*createExecutor<TestClass>(&TestClass::printTestBool))(&test, testStrings);
    444   (*createExecutor<TestClass>(&TestClass::printTwoVals))(&test, testStrings);
    445   (*createExecutor<TestClass>(&TestClass::printStatic))(&test, testStrings);
    446   (*createExecutor<TestClass>(&TestClass::printStrings))(&test, testStrings);
    447 
    448 }
    449 
    450 //// HACK HACK
    451 
    452416/**********************************
    453417*** ORXONOX MAIN STARTING POINT ***
     
    461425int main(int argc, char** argv)
    462426{
    463   TEST();
    464427  CmdLinePrefsReader prefs;
    465428
Note: See TracChangeset for help on using the changeset viewer.