Last change
on this file since 8211 was
8202,
checked in by snellen, 18 years ago
|
renamed scriptable to scriptclass, made ScriptManager create the script triggers
|
File size:
1.4 KB
|
Rev | Line | |
---|
[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" |
---|
| 13 | |
---|
[4838] | 14 | // FORWARD DECLARATION |
---|
[3543] | 15 | |
---|
| 16 | |
---|
[8193] | 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) |
---|
[2036] | 23 | |
---|
[8193] | 24 | |
---|
| 25 | |
---|
[3955] | 26 | //! A class for ... |
---|
[8202] | 27 | class ScriptClass : protected BaseObject |
---|
[8193] | 28 | { |
---|
[1853] | 29 | |
---|
[8193] | 30 | public: |
---|
[8202] | 31 | ScriptClass(const std::string& name, ClassID classID); |
---|
| 32 | virtual ~ScriptClass(); |
---|
[1853] | 33 | |
---|
[8193] | 34 | bool operator==(const std::string& name) { return (this->getName() == name); } |
---|
| 35 | bool operator==(ClassID classID) { return (this->classID == classID); } |
---|
| 36 | |
---|
| 37 | virtual void registerClass(Script* script) = 0; |
---|
| 38 | virtual int insertObject(Script* L, BaseObject* obj, const std::string& name, bool gc=false) = 0; |
---|
[3245] | 39 | |
---|
[8193] | 40 | private: |
---|
| 41 | ClassID classID; |
---|
[1853] | 42 | }; |
---|
| 43 | |
---|
[8193] | 44 | |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | template <class T> |
---|
[8202] | 48 | class tScriptable : public ScriptClass |
---|
[8193] | 49 | { |
---|
| 50 | tScriptable(const std::string& name, ClassID classID) |
---|
[8202] | 51 | : ScriptClass(name, classID) |
---|
[8193] | 52 | { } |
---|
| 53 | |
---|
| 54 | virtual void registerClass(Script* script) |
---|
| 55 | { |
---|
| 56 | Lunar<T>::Register(script); |
---|
| 57 | } |
---|
[8197] | 58 | virtual int insertObject(Script* L, BaseObject* obj, bool gc=false) |
---|
[8193] | 59 | { |
---|
[8197] | 60 | Lunar<T>::insertObject(L, dynamic_cast<T*>(obj), obj->getName(), gc); |
---|
[8193] | 61 | } |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | } |
---|
| 66 | ; |
---|
| 67 | |
---|
| 68 | |
---|
[8202] | 69 | #endif /* _SCRIPT_CLASS_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.