binding.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 by Reality Rift Studios                       *
00003  *   http://www.realityrift.com  -  mattias@realityrift.com                *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
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

Generated on Sat Feb 17 20:50:47 2007 for NeoEngine 2 - Evolution by  doxygen 1.5.1