Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8810 was 8408, checked in by bensch, 19 years ago

trunk: merged the script_engine branche back here
merged with command
svn merge https://svn.orxonox.net/orxonox/branches/script_engine . -r8284:HEAD
no conflicts

File size: 1.7 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 */
[8408]20#define CREATE_SCRIPTABLE_CLASS(CLASS_NAME, CLASS_ID, SCRIPT_METHODS) \
21    tScriptClass<CLASS_NAME> global_##CLASS_NAME##_ScriptableClass(#CLASS_NAME, CLASS_ID, (new ScriptMethod)->SCRIPT_METHODS)
[2036]22
[8193]23
[3955]24//! A class for ...
[8202]25class ScriptClass : protected BaseObject
[8193]26{
[1853]27
[8408]28public:
29  virtual ~ScriptClass();
[1853]30
[8408]31  bool operator==(const std::string& name) { return (this->getName() == name); }
32  bool operator==(ClassID classID) { return (this->_classID == classID); }
[3245]33
[8408]34  virtual void registerClass(Script* script) = 0;
35  virtual int insertObject(Script* L, BaseObject* obj, bool gc=false) = 0;
[8250]36
[8408]37  const ScriptMethod* scriptMethods() const { return this->_scriptMethods; }
[8250]38
[8408]39protected:
40  ScriptClass(const std::string& name, ClassID classID, ScriptMethod* scriptMethods);
41
42private:
43  ClassID             _classID;
44  ScriptMethod*       _scriptMethods;
[1853]45};
46
[8193]47
48
49
50template <class T>
[8408]51class tScriptClass : public ScriptClass
[8193]52{
[8408]53public:
54  tScriptClass(const std::string& name, ClassID classID, ScriptMethod* scriptMethods)
55      : ScriptClass(name, classID, scriptMethods)
56  { }
[8193]57
[8408]58  virtual void registerClass(Script* script)
59  {
60    Lunar<T>::Register(script, this->getName(), this->scriptMethods());
61  }
62  virtual int insertObject(Script* L, BaseObject* obj, bool gc=false)
63  {
64    return Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), obj->getName(), gc);
65  }
66};
[8193]67
68
[8202]69#endif /* _SCRIPT_CLASS_H */
Note: See TracBrowser for help on using the repository browser.