- Timestamp:
- Aug 25, 2006, 12:03:59 AM (18 years ago)
- Location:
- branches/new_class_id/src/lib
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/Makefile.am
r9668 r9699 18 18 SUBDIRS = \ 19 19 . \ 20 \ 21 shell \ 22 parser \ 23 script_engine 24 #\ 20 25 math \ 21 26 lang \ … … 29 34 collision_reaction \ 30 35 gui \ 31 network \ 32 parser \ 33 shell \ 34 script_engine 36 network -
branches/new_class_id/src/lib/script_engine/script.cc
r9692 r9699 23 23 #include "parser/tinyxml/tinyxml.h" 24 24 25 #include "class_list.h"26 25 CREATE_SCRIPTABLE_CLASS(Script, Script::classID(), 27 26 addMethod("addObject", ExecutorLua2<Script,const std::string&, const std::string& >(&Script::addObject)) … … 54 53 Script::Script(const std::string& filename) 55 54 { 56 this-> setClassID(CL_SCRIPT, "Script");55 this->registerObject(this, Script::_objectList); 57 56 58 57 returnCount = argumentCount = 0; … … 144 143 //printf(("Script %s: I am about to add %s of class %s\n",this->getName(),objectName.c_str(),className.c_str()); 145 144 146 BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);145 ScriptClass* scriptClass = ScriptClass::objectList().getObject(className); 147 146 // printf(("The script class for %s is at %p \n",className.c_str(),scriptClass); 148 147 WorldObject tmpObj; … … 152 151 if( !classIsRegistered(className) ) 153 152 { 154 static_cast<ScriptClass*>(scriptClass)->registerClass(this);155 } 156 157 BaseObject* object = ClassList::getObject(objectName, className);153 scriptClass->registerClass(this); 154 } 155 156 BaseObject* object = NewObjectListBase::getBaseObject(objectName, className); 158 157 // printf(("%s is at %p \n",objectName.c_str(),object); 159 158 if (object != NULL && !objectIsAdded(objectName)) 160 159 { 161 s tatic_cast<ScriptClass*>(scriptClass)->insertObject(this, object, false);160 scriptClass->insertObject(this, object, false); 162 161 tmpObj.name = objectName; 163 162 registeredObjects.push_back(tmpObj); … … 354 353 void Script::addThisScript() 355 354 { 356 BaseObject* scriptClass = ClassList::getObject("Script", CL_SCRIPT_CLASS); 357 if (scriptClass != NULL) 358 { 359 static_cast<ScriptClass*>(scriptClass)->registerClass(this); 360 static_cast<ScriptClass*>(scriptClass)->insertObject(this, this,"thisscript", false); 355 ScriptClass* scriptClass = ScriptClass::objectList().getObject("Script"); 356 357 if (scriptClass != NULL) 358 { 359 scriptClass->registerClass(this); 360 scriptClass->insertObject(this, this,"thisscript", false); 361 361 } 362 362 } … … 388 388 void Script::registerClass( const std::string& className) 389 389 { 390 BaseObject* scriptClass = ClassList::getObject(className, CL_SCRIPT_CLASS);390 ScriptClass* scriptClass = ScriptClass::objectList().getObject(className); 391 391 //printf(("The script class for %s is at %p \n",className.c_str(),scriptClass); 392 392 393 WorldObject tmpObj; 393 394 if (scriptClass != NULL) -
branches/new_class_id/src/lib/script_engine/script_class.cc
r9692 r9699 24 24 * @todo this constructor is not jet implemented - do it 25 25 */ 26 ScriptClass::ScriptClass(const std::string& name, ClassIDclassID, ScriptMethod* scriptMethods)27 : BaseObject(name) 26 ScriptClass::ScriptClass(const std::string& name, const NewClassID& classID, ScriptMethod* scriptMethods) 27 : BaseObject(name), _classID(classID) 28 28 { 29 29 assert(scriptMethods != NULL); 30 this->registerObject(this, S hell::_objectList);30 this->registerObject(this, ScriptClass::_objectList); 31 31 32 32 this->_classID = classID; -
branches/new_class_id/src/lib/script_engine/script_class.h
r9686 r9699 23 23 24 24 //! A class for ... 25 class ScriptClass : p rotectedBaseObject25 class ScriptClass : public BaseObject 26 26 { 27 NewObjectListDeclaration(ScriptClass); 27 28 28 29 public: 29 30 virtual ~ScriptClass(); 30 31 31 bool operator==(const std::string& name) { return (this->getName() == name); } 32 bool operator==(NewClassID classID) { return (this->_classID == classID); } 32 const std::string& getName() const { return this->getName(); } 33 bool operator==(const std::string& name) const { return (this->getName() == name); } 34 bool operator==(NewClassID classID) const { return (this->_classID == classID); } 33 35 34 36 virtual void registerClass(Script* script) = 0; … … 39 41 40 42 protected: 41 ScriptClass(const std::string& name, NewClassIDclassID, ScriptMethod* scriptMethods);43 ScriptClass(const std::string& name, const NewClassID& classID, ScriptMethod* scriptMethods); 42 44 43 45 private: 44 const NewClassID&_classID;46 NewClassID _classID; 45 47 ScriptMethod* _scriptMethods; 46 48 }; -
branches/new_class_id/src/lib/script_engine/script_manager.cc
r9003 r9699 24 24 #include "lunar.h" 25 25 26 #include "class_list.h"27 28 26 #include "script.h" 29 27 #include "script_trigger.h" … … 37 35 { 38 36 this->setName("ScriptManager"); 39 this->scripts = NULL;40 this->triggers = NULL;41 37 42 38 if (root != NULL) … … 62 58 63 59 // fill the scripts and triggers (doing that on runtime is very slow!) 64 getTriggers();65 getScripts();66 60 } 67 61 … … 71 65 { 72 66 //Delete all scripts as they aren't deleted automatically 73 if(this->getScripts()) 74 while(!scripts->empty()) 75 delete scripts->front(); 67 while(!Script::objectList().empty()) 68 delete Script::objectList().front(); 76 69 //Delete all triggers 77 if(this->getTriggers()) 78 while(!triggers->empty()) 79 delete triggers->front(); 80 70 while(!ScriptTrigger::objectList().empty()) 71 delete ScriptTrigger::objectList().front(); 72 81 73 } 82 74 … … 105 97 Script* ScriptManager::getScriptByFile(const std::string& file) 106 98 { 107 if(getScripts()) 108 for(std::list<BaseObject*>::const_iterator it = scripts->begin(); it != scripts->end(); it++ ) 109 { 110 if( (dynamic_cast<Script*>(*it))->getFileName().compare(file) == 0) 111 { 112 return dynamic_cast<Script*>(*it); 113 } 114 } 99 for (NewObjectList<Script>::const_iterator it = Script::objectList().begin(); 100 it != Script::objectList().end(); 101 ++it) 102 if( ((*it))->getFileName().compare(file) == 0) 103 return (*it); 115 104 116 105 return NULL; 117 106 118 107 } 119 120 121 bool ScriptManager::getScripts()122 {123 return (this->scripts != NULL || (this->scripts = ClassList::getList(CL_SCRIPT)) != NULL);124 }125 126 bool ScriptManager::getTriggers()127 {128 return (this->triggers != NULL || (this->triggers = ClassList::getList(CL_SCRIPT_TRIGGER)) != NULL);129 }130 131 132 -
branches/new_class_id/src/lib/script_engine/script_manager.h
r8894 r9699 34 34 void createTriggers(const TiXmlElement* triggers); 35 35 36 bool getTriggers();37 bool getScripts();38 39 36 static ScriptManager* singletonRef; //!< Reference to this class 40 41 const std::list<BaseObject*>* triggers; //!< A list of all the triggers in the world42 43 const std::list<BaseObject*>* scripts; //!< A list of all the scripts in the world44 45 46 37 }; 47 38 #endif
Note: See TracChangeset
for help on using the changeset viewer.