Crazy Eddie's GUI System  0.8.3
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
ScriptModule.h
1 /***********************************************************************
2  filename: CEGUIScriptModule.h
3  created: 16/7/2004
4  author: Paul D Turner
5 
6  purpose: Abstract class interface for scripting support
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIScriptModule_h_
31 #define _CEGUIScriptModule_h_
32 
33 #include "CEGUI/Base.h"
34 #include "CEGUI/String.h"
35 #include "CEGUI/Event.h"
36 
37 
38 // Start of CEGUI namespace section
39 namespace CEGUI
40 {
46 class CEGUIEXPORT ScriptModule :
47  public AllocatedObject<ScriptModule>
48 {
49 public:
50  /*************************************************************************
51  Construction and Destruction
52  *************************************************************************/
57  ScriptModule(void);
58 
59 
64  virtual ~ScriptModule(void) {}
65 
66 
67  /*************************************************************************
68  Abstract interface
69  *************************************************************************/
80  virtual void executeScriptFile(const String& filename, const String& resourceGroup = "") = 0;
81 
82 
94  virtual int executeScriptGlobal(const String& function_name) = 0;
95 
96 
113  virtual bool executeScriptedEventHandler(const String& handler_name, const EventArgs& e) = 0;
114 
115 
126  virtual void executeString(const String& str) = 0;
127 
128 
137  virtual void createBindings(void) {}
138 
139 
149  virtual void destroyBindings(void) {}
150 
159  const String& getIdentifierString() const;
160 
179  virtual Event::Connection subscribeEvent(EventSet* target, const String& name, const String& subscriber_name) = 0;
180 
202  virtual Event::Connection subscribeEvent(EventSet* target, const String& name, Event::Group group, const String& subscriber_name) = 0;
203 
214  static void setDefaultResourceGroup(const String& resourceGroup)
215  { d_defaultResourceGroup = resourceGroup; }
216 
224  static const String& getDefaultResourceGroup()
225  { return d_defaultResourceGroup; }
226 
227 protected:
232 };
233 
234 
239 class CEGUIEXPORT ScriptFunctor :
240  public AllocatedObject<ScriptFunctor>
241 {
242 public:
243  ScriptFunctor(const String& functionName) : scriptFunctionName(functionName) {}
244  ScriptFunctor(const ScriptFunctor& obj) : scriptFunctionName(obj.scriptFunctionName) {}
245  bool operator()(const EventArgs& e) const;
246 
247 private:
248  // no assignment possible
249  ScriptFunctor& operator=(const ScriptFunctor& rhs);
250 
251  const String scriptFunctionName;
252 };
253 
254 } // End of CEGUI namespace section
255 
256 
257 #endif // end of guard _CEGUIScriptModule_h_