Changeset 9769 in orxonox.OLD for branches/new_class_id/src/lib/util/loading/load_param.h
- Timestamp:
- Sep 19, 2006, 9:35:11 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/loading/load_param.h
r9765 r9769 45 45 */ 46 46 #define LoadParam(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \ 47 CLoadParam (ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS>(&CLASS::FUNCTION), false)47 CLoadParam<CLASS>(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS, CLASS>(&CLASS::FUNCTION), false) 48 48 49 49 /** … … 56 56 */ 57 57 #define LoadParam_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \ 58 CLoadParam (ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS>(&CLASS::FUNCTION), true)58 CLoadParam<CLASS>(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS, CLASS>(&CLASS::FUNCTION), true) 59 59 60 60 /** … … 89 89 { 90 90 protected: 91 LoadParamBase(const TiXmlElement* root, const std::string& paramName, BaseObject* object,bool inLoadCycle = false);91 LoadParamBase(const TiXmlElement* root, const std::string& paramName, bool inLoadCycle = false); 92 92 93 93 protected: … … 95 95 96 96 protected: 97 BaseObject* object; //!< The Object to work on98 97 const std::string paramName; //!< The Name of the Parameter this LoadParams applies to. 99 98 bool inLoadCycle; //!< If the Parameter is in a LoadCycle. … … 104 103 105 104 //! The Loading Class of the LoadParam, that acctually executes the loading process. 106 class CLoadParam : public LoadParamBase105 template <class OperateClass> class CLoadParam : public LoadParamBase 107 106 { 108 107 public: 109 CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, Executor<const SubString>* executor, bool inLoadCycle = false); 110 virtual ~CLoadParam(); 111 108 /** 109 * @brief generates a LoadParam based on 110 * @param root the Root Element to load onto the object. 111 * @param paramName the Parameter name that is loaded. 112 * @param object the Object to apply the changes on. 113 * @param executor the Functional Object, that actually executes the function Call. 114 * @param inLoadCycle If we are inside of a loading cycle. (Loading will be different here) 115 */ 116 CLoadParam(const TiXmlElement* root, const std::string& paramName, OperateClass* object, Executor<const SubString, OperateClass>* executor, bool inLoadCycle = false) 117 : LoadParamBase(root, paramName, inLoadCycle) 118 { 119 assert (executor != NULL); 120 this->object = object; 121 this->executor = executor; 122 } 123 virtual ~CLoadParam() 124 { 125 std::string loadString; 126 if (this->loadElem != NULL && this->loadElem->ToText()) 127 { 128 loadString = this->loadElem->Value(); 129 if (!loadString.empty()) 130 { 131 /* PRINTF(4)("Loading value '%s' with Parameters '%s' onto: %s::%s\n", 132 this->paramName.c_str(), loadString.c_str(), this->object->getClassCName(), this->object->getCName());*/ 133 (*this->executor)(this->object, SubString(loadString, ",", SubString::WhiteSpaces, false, '\\')); 134 } 135 } 136 delete this->executor; 137 } 138 /** 139 * @brief set the default values of the executor 140 * @param value0 the first default value @param value1 the second default value 141 * @param value2 the third default value @param value3 the fourth default value 142 * @param value4 the fifth default value 143 */ 112 144 CLoadParam& defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL, 113 145 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL, 114 const MultiType& value4 = MT_NULL); 146 const MultiType& value4 = MT_NULL) 147 { this->executor->defaultValues(value0, value1, value2, value3, value4); return *this; }; 115 148 CLoadParam& describe(const std::string& descriptionText) { LoadParamBase::describe(descriptionText); return *this; }; 116 149 // CLoadParam& attribute(const std::string& attributeName, const Executor<SubString>& executor); … … 118 151 119 152 private: 120 Executor<const SubString>* executor; //!< The Executor, that actually executes the Loading process. 153 Executor<const SubString, OperateClass>* executor; //!< The Executor, that actually executes the Loading process. 154 OperateClass* object; 121 155 }; 122 156
Note: See TracChangeset
for help on using the changeset viewer.