Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9700 was 9003, checked in by bensch, 18 years ago

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

File size: 2.0 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;
[9003]36  virtual int insertObject(Script* L, BaseObject* obj, const std::string& name, bool gc=false) = 0; 
[8250]37
[8408]38  const ScriptMethod* scriptMethods() const { return this->_scriptMethods; }
[8250]39
[8408]40protected:
41  ScriptClass(const std::string& name, ClassID classID, ScriptMethod* scriptMethods);
42
43private:
44  ClassID             _classID;
45  ScriptMethod*       _scriptMethods;
[1853]46};
47
[8193]48
49
50
51template <class T>
[8408]52class tScriptClass : public ScriptClass
[8193]53{
[8408]54public:
55  tScriptClass(const std::string& name, ClassID classID, ScriptMethod* scriptMethods)
56      : ScriptClass(name, classID, scriptMethods)
57  { }
[8193]58
[8408]59  virtual void registerClass(Script* script)
60  {
61    Lunar<T>::Register(script, this->getName(), this->scriptMethods());
62  }
63  virtual int insertObject(Script* L, BaseObject* obj, bool gc=false)
64  {
65    return Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), obj->getName(), gc);
66  }
[9003]67
68  virtual int insertObject(Script* L, BaseObject* obj,const std::string& name, bool gc=false)
69  {
70    return Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), name, gc);
71  }
[8408]72};
[8193]73
74
[8202]75#endif /* _SCRIPT_CLASS_H */
Note: See TracBrowser for help on using the repository browser.