Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain/src/lib/script_engine/script_class.h @ 8453

Last change on this file since 8453 was 8271, checked in by bensch, 18 years ago

merge

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