Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/script_engine/script_class.h @ 10549

Last change on this file since 10549 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 1.9 KB
RevLine 
[4838]1/*!
[8202]2 * @file script_class.h
[4838]3 * @brief Definition of ...
[3245]4*/
[1853]5
[8202]6#ifndef _SCRIPT_CLASS_H
7#define _SCRIPT_CLASS_H
[1853]8
[3543]9#include "base_object.h"
[1853]10
[8193]11#include "script.h"
12#include "lunar.h"
[8408]13#include "script_method.h"
[8193]14
[3543]15
[8193]16/**
17 * Creates a factory to a Loadable Class.
18 * this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
19 */
[9869]20#define CREATE_SCRIPTABLE_CLASS(CLASS_NAME, SCRIPT_METHODS) \
21    tScriptClass<CLASS_NAME> global_##CLASS_NAME##_ScriptableClass(#CLASS_NAME, CLASS_NAME::staticClassID(), (new ScriptMethod)->SCRIPT_METHODS)
[2036]22
[8193]23
[3955]24//! A class for ...
[9869]25class ScriptClass : public BaseObject
[8193]26{
[9869]27  ObjectListDeclaration(ScriptClass);
[1853]28
[8408]29public:
30  virtual ~ScriptClass();
[1853]31
[8408]32  virtual void registerClass(Script* script) = 0;
33  virtual int insertObject(Script* L, BaseObject* obj, bool gc=false) = 0;
[9869]34  virtual int insertObject(Script* L, BaseObject* obj, const std::string& name, bool gc=false) = 0;
[8250]35
[8408]36  const ScriptMethod* scriptMethods() const { return this->_scriptMethods; }
[8250]37
[8408]38protected:
[9869]39  ScriptClass(const std::string& name, const ClassID& classID, ScriptMethod* scriptMethods);
[8408]40
41private:
42  ClassID             _classID;
43  ScriptMethod*       _scriptMethods;
[1853]44};
45
[8193]46
47
48
49template <class T>
[8408]50class tScriptClass : public ScriptClass
[8193]51{
[8408]52public:
53  tScriptClass(const std::string& name, ClassID classID, ScriptMethod* scriptMethods)
54      : ScriptClass(name, classID, scriptMethods)
55  { }
[8193]56
[8408]57  virtual void registerClass(Script* script)
58  {
59    Lunar<T>::Register(script, this->getName(), this->scriptMethods());
60  }
61  virtual int insertObject(Script* L, BaseObject* obj, bool gc=false)
62  {
63    return Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), obj->getName(), gc);
64  }
[9003]65
66  virtual int insertObject(Script* L, BaseObject* obj,const std::string& name, bool gc=false)
67  {
68    return Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), name, gc);
69  }
[8408]70};
[8193]71
72
[8202]73#endif /* _SCRIPT_CLASS_H */
Note: See TracBrowser for help on using the repository browser.