00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef neo_script_binding_h
00022 #define neo_script_binding_h
00023
00029 #include "../core/platform.h"
00030
00031 #if NEO_ENABLE_SCRIPT
00032
00033 #include "../core/any.h"
00034 #include "../core/hashtable.h"
00035 #include "../core/hashstring.h"
00036 #include "script.h"
00037
00038 namespace neo {
00039 namespace script {
00040
00047 class Binding
00048 {
00049 public:
00050
00052 Script* _p_script;
00053
00055 std::string _method;
00056 };
00057
00064 class Scriptable
00065 {
00066 public:
00067
00069
00073 void bindScriptEvent( const std::string& event, Script* p_script, const std::string& method );
00074
00076
00078 void unbindScriptEvent( const std::string& event );
00079
00081
00082 void callScriptEvent( const core::HashString& event );
00083
00085
00087 void callScriptEvent( const core::HashString& event, const core::Any& arg );
00088
00090
00093 void callScriptEvent( const core::HashString& event, const core::Any& arg0, const core::Any& arg1 );
00094
00096
00100 void callScriptEvent( const core::HashString& event, const core::Any& arg0, const core::Any& arg1, const core::Any& arg2 );
00101
00103
00108 void callScriptEvent( const core::HashString& event, const core::Any& arg0, const core::Any& arg1, const core::Any& arg2, const core::Any& arg3 );
00109
00111
00112 const core::HashTable< std::string, Binding* >& getScriptBindings() const;
00113
00115
00116 static void enableScripting( bool enable );
00117
00119
00121 core::Array< std::string > getEvents();
00122
00123 protected:
00124
00126 core::Any _thisScriptable;
00127
00129 Scriptable();
00130
00132 virtual ~Scriptable();
00133
00134 Scriptable( const Scriptable& );
00135 Scriptable& operator = ( const Scriptable& );
00136 void copyFrom( const Scriptable& );
00137
00139
00141 virtual void getEvents( core::Array< std::string >* p_events ) = 0;
00142
00143 private:
00144
00146 core::HashTable< std::string, Binding* > _scriptBindings;
00147
00149 static bool _enableScripting;
00150 };
00151
00152 }
00153 }
00154
00155 #endif
00156
00157 #endif