Crazy Eddie's GUI System  0.8.7
MemberFunctionSlot.h
1 /************************************************************************
2  created: Tue Feb 28 2006
3  author: Paul D Turner <paul@cegui.org.uk>
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2014 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIMemberFunctionSlot_h_
28 #define _CEGUIMemberFunctionSlot_h_
29 
30 #include "CEGUI/SlotFunctorBase.h"
31 
32 // Start of CEGUI namespace section
33 namespace CEGUI
34 {
40 template<typename T>
42 {
43 public:
45  typedef bool(T::*MemberFunctionType)(const EventArgs&);
46 
48  d_function(func),
49  d_object(obj)
50  {}
51 
52  virtual bool operator()(const EventArgs& args)
53  {
54  return (d_object->*d_function)(args);
55  }
56 
57 private:
58  MemberFunctionType d_function;
59  T* d_object;
60 };
61 
71 template<typename T>
73 {
74 public:
76  typedef void(T::*MemberFunctionType)(const EventArgs&);
77 
79  d_function(func),
80  d_object(obj)
81  {}
82 
83  virtual bool operator()(const EventArgs& args)
84  {
85  (d_object->*d_function)(args);
86 
87  return true;
88  }
89 
90 private:
91  MemberFunctionType d_function;
92  T* d_object;
93 };
94 
100 template<typename T>
102 {
103 public:
105  typedef bool(T::*MemberFunctionType)();
106 
108  d_function(func),
109  d_object(obj)
110  {}
111 
112  virtual bool operator()(const EventArgs& /*args*/)
113  {
114  return (d_object->*d_function)();
115  }
116 
117 private:
118  MemberFunctionType d_function;
119  T* d_object;
120 };
121 
132 template<typename T>
134 {
135 public:
137  typedef void(T::*MemberFunctionType)();
138 
140  d_function(func),
141  d_object(obj)
142  {}
143 
144  virtual bool operator()(const EventArgs& /*args*/)
145  {
146  (d_object->*d_function)();
147 
148  return true;
149  }
150 
151 private:
152  MemberFunctionType d_function;
153  T* d_object;
154 };
155 
156 }
157 
158 #endif // end of guard _CEGUIMemberFunctionSlot_h_
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
void(T::* MemberFunctionType)(const EventArgs &)
Member function slot type.
Definition: MemberFunctionSlot.h:76
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:49
bool(T::* MemberFunctionType)(const EventArgs &)
Member function slot type.
Definition: MemberFunctionSlot.h:45
bool(T::* MemberFunctionType)()
Member function slot type.
Definition: MemberFunctionSlot.h:105
Slot template class that creates a functor that calls back via a class member function.
Definition: MemberFunctionSlot.h:41
Defines abstract interface which will be used when constructing various functor objects that bind slo...
Definition: SlotFunctorBase.h:43
Slot template class that creates a functor that calls back via a class member function. This variant doesn't require a handler that returns bool.
Definition: MemberFunctionSlot.h:72
void(T::* MemberFunctionType)()
Member function slot type.
Definition: MemberFunctionSlot.h:137
Slot template class that creates a functor that calls back via a class member function. This variant ignores passed EventArgs.
Definition: MemberFunctionSlot.h:101
Slot template class that creates a functor that calls back via a class member function. This variant ignores passed EventArgs and the handler doesn't have to return a bool.
Definition: MemberFunctionSlot.h:133