- Timestamp:
- May 19, 2006, 4:05:41 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/Makefile.am
r7716 r7721 15 15 util/multi_type.cc \ 16 16 util/executor/executor.cc \ 17 util/executor/executor_functional.cc \ 17 18 \ 18 19 util/loading/resource_manager.cc \ -
trunk/src/lib/util/executor/executor.cc
r7714 r7721 33 33 const MultiType& param4) 34 34 { 35 //this->setClassID(CL_EXECUTOR, "Executor");35 this->setClassID(CL_EXECUTOR, "Executor"); 36 36 37 37 // What Parameters have we got -
trunk/src/lib/util/executor/executor_functional.h
r7720 r7721 23 23 #define __EXECUTOR_FUNCTIONAL_H_ 24 24 25 25 #include "base_object.h" 26 #include "multi_type.h" 27 #include "executor.h" 26 28 27 29 template<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; };30 template<> MT_Type ExecutorParamType<bool>(); 31 template<> MT_Type ExecutorParamType<int>(); 32 template<> MT_Type ExecutorParamType<unsigned int>(); 33 template<> MT_Type ExecutorParamType<float>(); 34 template<> MT_Type ExecutorParamType<char>(); 35 template<> MT_Type ExecutorParamType<const std::string&>(); 34 36 35 37 template<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; };38 template<> bool fromString<bool>(const std::string& input, bool defaultValue); 39 template<> int fromString<int>(const std::string& input, int defaultValue); 40 template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue); 41 template<> float fromString<float>(const std::string& input, float defaultValue); 42 template<> char fromString<char>(const std::string& input, char defaultValue); 43 template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue); 42 44 43 45 template<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; };46 template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i); 47 template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i); 48 template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i); 49 template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i); 50 template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i); 51 template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i); 50 52 51 53 #endif /* __EXECUTOR_FUNCTIONAL_H_ */ -
trunk/src/lib/util/loading/load_param.cc
r7474 r7721 28 28 * @param executor the Executor, that executes the loading procedure. 29 29 */ 30 CLoadParam::CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, const Executor&executor, bool inLoadCycle)30 CLoadParam::CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, Executor* executor, bool inLoadCycle) 31 31 : paramName(paramName), object(object) 32 32 { … … 43 43 44 44 // set the Executor. 45 this->executor = executor .clone();45 this->executor = executor; 46 46 47 47 //if (this->executor) -
trunk/src/lib/util/loading/load_param.h
r7221 r7721 25 25 26 26 #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 27 33 #include "executor/executor_specials.h" 28 34 … … 45 51 */ 46 52 #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) 48 54 49 55 #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) 51 57 52 58 #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) 54 60 55 61 #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) 57 63 58 64 … … 87 93 { 88 94 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); 90 96 virtual ~CLoadParam(); 91 97 -
trunk/src/orxonox.cc
r7720 r7721 414 414 bool showGui = false; 415 415 416 /// HACK HACK TEST417 418 419 #include "executor/executor_functional.h"420 421 #define EXECUTOR_FUNCTIONAL_USE_STATIC422 #include "executor/executor_functional.h"423 424 class TestClass : public BaseObject425 {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 HACK451 452 416 /********************************** 453 417 *** ORXONOX MAIN STARTING POINT *** … … 461 425 int main(int argc, char** argv) 462 426 { 463 TEST();464 427 CmdLinePrefsReader prefs; 465 428
Note: See TracChangeset
for help on using the changeset viewer.