Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8197 in orxonox.OLD


Ignore:
Timestamp:
Jun 7, 2006, 3:25:04 PM (18 years ago)
Author:
snellen
Message:

scriptengine integrated

Location:
branches/script_engine/src/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/lib/lang/class_list.cc

    r7429 r8197  
    221221          return (*bo);
    222222    }
     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 */
     235BaseObject* 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);
    223244  }
    224245  return NULL;
  • branches/script_engine/src/lib/lang/class_list.h

    r7429 r8197  
    4242    static const std::list<BaseObject*>*  getList(const std::string& className); // { return (ClassList* fl = ClassList::getClassList(className) != NULL)? &(fl->objectList) : NULL;  };
    4343    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);
    4546    static bool                           exists(const BaseObject* object, ClassID classID = CL_NULL);
    4647    static bool                           exists(const std::string& className, const std::string& objectName);
  • branches/script_engine/src/lib/script_engine/script.cc

    r8193 r8197  
    11#include "script.h"
     2#include "scriptable.h"
     3
    24#include "loading/load_param.h"
    3 
     5#include "parser/tinyxml/tinyxml.h"
     6
     7#include "class_list.h"
    48
    59Script::Script(const TiXmlElement* root)
     
    3337void Script::loadParams(const TiXmlElement* root)
    3438{
    35   LOAD_PARAM_START_CYCLE(root, objectElement);
     39  LOAD_PARAM_START_CYCLE(root, object);
    3640  {
    37     LoadParam_CYCLE(objectElement, "object", this, Script, addObject)
     41    LoadParam_CYCLE(object, "object", this, Script, addObject)
    3842        .describe("The name of an object that is needed by a script");
    3943  }
    40   LOAD_PARAM_END_CYCLE(objectElement);
     44  LOAD_PARAM_END_CYCLE(object);
    4145
    4246
     
    8589 void Script::addObject(const std::string& className, const std::string& objectName)
    8690 {
    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   }
    88102 }
    89103
  • branches/script_engine/src/lib/script_engine/scriptable.h

    r8193 r8197  
    2525
    2626//! A class for ...
    27 class Scriptable : virtual protected BaseObject
     27class Scriptable : protected BaseObject
    2828{
    2929
     
    5656    Lunar<T>::Register(script);
    5757  }
    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)
    5959  {
    60     Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), name, gc);
     60    Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), obj->getName(), gc);
    6161  }
    6262 
Note: See TracChangeset for help on using the changeset viewer.