Changeset 8197 in orxonox.OLD
- Timestamp:
- Jun 7, 2006, 3:25:04 PM (18 years ago)
- Location:
- branches/script_engine/src/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/lang/class_list.cc
r7429 r8197 221 221 return (*bo); 222 222 } 223 } 224 return NULL; 225 } 226 227 228 /** 229 * @brief checks if the BaseObject* object exists. 230 * @param objectName the name of the BaseObject to look for 231 * @param classID if not CL_NULL it will only search through a specific type of Objects. Otherwise it will be searched everywhere. 232 * @return true, if the Object Exists in the specified ClassID, false otherwise 233 * @todo: speed this up!! 234 */ 235 BaseObject* ClassList::getObject(const std::string& objectName, const std::string& className) 236 { 237 ClassList* cl = ClassList::getClassList(className); 238 if (cl != NULL) 239 { 240 std::list<BaseObject*>::iterator bo; 241 for (bo = cl->objectList.begin(); bo != cl->objectList.end(); bo++) 242 if ((*bo)->getName() != NULL && objectName == (*bo)->getName()) 243 return (*bo); 223 244 } 224 245 return NULL; -
branches/script_engine/src/lib/lang/class_list.h
r7429 r8197 42 42 static const std::list<BaseObject*>* getList(const std::string& className); // { return (ClassList* fl = ClassList::getClassList(className) != NULL)? &(fl->objectList) : NULL; }; 43 43 static const std::list<std::string>* getClassNames(); 44 static BaseObject* getObject(const std::string& name, ClassID classID = CL_NULL); 44 static BaseObject* getObject(const std::string& objectName, ClassID classID = CL_NULL); 45 static BaseObject* getObject(const std::string& objectName, const std::string& className); 45 46 static bool exists(const BaseObject* object, ClassID classID = CL_NULL); 46 47 static bool exists(const std::string& className, const std::string& objectName); -
branches/script_engine/src/lib/script_engine/script.cc
r8193 r8197 1 1 #include "script.h" 2 #include "scriptable.h" 3 2 4 #include "loading/load_param.h" 3 5 #include "parser/tinyxml/tinyxml.h" 6 7 #include "class_list.h" 4 8 5 9 Script::Script(const TiXmlElement* root) … … 33 37 void Script::loadParams(const TiXmlElement* root) 34 38 { 35 LOAD_PARAM_START_CYCLE(root, object Element);39 LOAD_PARAM_START_CYCLE(root, object); 36 40 { 37 LoadParam_CYCLE(object Element, "object", this, Script, addObject)41 LoadParam_CYCLE(object, "object", this, Script, addObject) 38 42 .describe("The name of an object that is needed by a script"); 39 43 } 40 LOAD_PARAM_END_CYCLE(object Element);44 LOAD_PARAM_END_CYCLE(object); 41 45 42 46 … … 85 89 void Script::addObject(const std::string& className, const std::string& objectName) 86 90 { 87 91 BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPTABLE); 92 if (scriptClass != NULL) 93 { 94 static_cast<Scriptable*>(scriptClass)->registerClass(this); 95 96 BaseObject* object = ClassList::getObject(objectName, className); 97 if (object != NULL) 98 { 99 static_cast<Scriptable*>(scriptClass)->insertObject(this, object, false); 100 } 101 } 88 102 } 89 103 -
branches/script_engine/src/lib/script_engine/scriptable.h
r8193 r8197 25 25 26 26 //! A class for ... 27 class Scriptable : virtualprotected BaseObject27 class Scriptable : protected BaseObject 28 28 { 29 29 … … 56 56 Lunar<T>::Register(script); 57 57 } 58 virtual int insertObject(Script* L, BaseObject* obj, const std::string& name,bool gc=false)58 virtual int insertObject(Script* L, BaseObject* obj, bool gc=false) 59 59 { 60 Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), name, gc);60 Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), obj->getName(), gc); 61 61 } 62 62
Note: See TracChangeset
for help on using the changeset viewer.