HoverRace  2.0
Handlers.h
Go to the documentation of this file.
1 
2 // Handlers.h
3 //
4 // Copyright (c) 2010, 2013, 2014 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include <luabind/object.hpp>
25 
26 #include "RegistryRef.h"
27 
28 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
29 # ifdef MR_ENGINE
30 # define MR_DllDeclare __declspec( dllexport )
31 # else
32 # define MR_DllDeclare __declspec( dllimport )
33 # endif
34 #else
35 # define MR_DllDeclare
36 #endif
37 
38 namespace HoverRace {
39 namespace Script {
40 
41 class Core;
42 
48 {
49 public:
50  Handlers(Core &scripting);
51  Handlers(const Handlers&) = default;
52  Handlers(Handlers&&) = default;
53  virtual ~Handlers() { }
54 
55  Handlers &operator=(const Handlers&) = default;
56  Handlers &operator=(Handlers&&) = default;
57 
58 protected:
59  void Call(int numParams) const;
60 public:
61  void CallHandlers() const;
62  void CallHandlers(const luabind::object &p1) const;
63  void CallHandlers(const luabind::object &p1,
64  const luabind::object &p2) const;
65 
66  void AddHandler(const luabind::object &fn);
67  void AddHandler(const std::string &name, const luabind::object &fn);
68 
69 private:
71  int seq;
73 };
74 
75 } // namespace Script
76 } // namespace HoverRace
77 
78 #undef MR_DllDeclare
virtual ~Handlers()
Definition: Handlers.h:53
Encapsulates a ref to the registry.
Definition: RegistryRef.h:50
Core * scripting
Definition: Handlers.h:70
Tracks event handlers registered in scripts.
Definition: Handlers.h:47
#define MR_DllDeclare
Definition: Handlers.h:35
RegistryRef ref
Definition: Handlers.h:72
Definition: Announcement.h:24
int seq
Definition: Handlers.h:71
A script environment.
Definition: Core.h:66