Spinning Topp Logo BlackTopp Studios
inc
eventsubscriberslot.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _eventsubscriberslot_cpp
41 #define _eventsubscriberslot_cpp
42 
43 #include "eventsubscriberslot.h"
44 #include "eventsubscriber.h"
45 
46 namespace Mezzanine
47 {
48  ///////////////////////////////////////////////////////////////////////////////
49  // EventSubscriberSlot Methods
50 
52  SubbedEvent(Ev)
53  { }
54 
56  { }
57 
58  ///////////////////////////////////////////////////////////////////////////////
59  // Utility
60 
62  { return this->SubbedEvent; }
63 
64  ///////////////////////////////////////////////////////////////////////////////
65  // Internal Methods
66 
67  ///////////////////////////////////////////////////////////////////////////////
68  // CustomEventSubscriberSlot Methods
69 
72  Subscriber(Sub)
73  { }
74 
76  { }
77 
78  ///////////////////////////////////////////////////////////////////////////////
79  // Utility
80 
82  { return this->Subscriber; }
83 
85  { return EventSubscriberSlot::ST_Custom; }
86 
87  ///////////////////////////////////////////////////////////////////////////////
88  // Internal Methods
89 
91  { this->Subscriber->_NotifyEvent(Args); }
92 
93  ///////////////////////////////////////////////////////////////////////////////
94  // FunctorSubscriberSlot Methods
95 
98  Functor(Funct),
99  CleanUp(CleanUpAfter)
100  { }
101 
103  { }
104 
105  ///////////////////////////////////////////////////////////////////////////////
106  // Utility
107 
109  { return this->Functor; }
110 
112  { return EventSubscriberSlot::ST_Functor; }
113 
114  ///////////////////////////////////////////////////////////////////////////////
115  // Internal Methods
116 
118  { this->Functor->operator()(Args); }
119 
120  ///////////////////////////////////////////////////////////////////////////////
121  // CFunctionSubscriberSlot Methods
122 
123  CFunctionSubscriberSlot::CFunctionSubscriberSlot(Event* Ev, SubscriberFunction* Funct) :
125  Function(Funct)
126  { }
127 
129  { }
130 
131  ///////////////////////////////////////////////////////////////////////////////
132  // Utility
133 
135  { return this->Function; }
136 
138  { return EventSubscriberSlot::ST_CFunction; }
139 
140  ///////////////////////////////////////////////////////////////////////////////
141  // Internal Methods
142 
144  { this->Function(Args); }
145 
146  ///////////////////////////////////////////////////////////////////////////////
147  // ScriptSubscriberSlot Methods
148 
151  SubscriberScript(SubScript)
152  { }
153 
155  { }
156 
157  ///////////////////////////////////////////////////////////////////////////////
158  // Utility
159 
161  { return this->SubscriberScript; }
162 
164  { return EventSubscriberSlot::ST_Script; }
165 
166  ///////////////////////////////////////////////////////////////////////////////
167  // Internal Methods
168 
170  {
171  /// @todo This needs to be implemented.
172  }
173 }//Mezzanine
174 
175 #endif
CFunctionSubscriberSlot(Event *Ev, SubscriberFunction *Funct)
Class constructor.
virtual ~FunctorSubscriberSlot()
Class destructor.
Basic class definition for functors used by a FunctorSubscriberSlot.
FunctorEventSubscriber * Functor
A pointer to the functor to be called when the event is fired.
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
virtual SlotType GetType() const
Gets the type of subscriber slot this is.
SubscriberFunction * Function
A pointer to the c-style function to be called when the event is fired.
Scripting::iScript * GetScript() const
Gets a pointer to the function used by this subscriber slot.
FunctorSubscriberSlot(Event *Ev, FunctorEventSubscriber *Funct, Boole CleanUpAfter)
Class constructor.
This class represents a given event that can be subscribed to and/or fired.
Definition: event.h:52
virtual void _NotifyEvent(EventArgumentsPtr Args)
Notifies this subscriber of an event being fired.
virtual void _NotifyEvent(EventArgumentsPtr Args)
Notifies this subscriber of an event being fired.
This is a base class for all classes that subscribe to events.
virtual SlotType GetType() const
Gets the type of subscriber slot this is.
virtual ~ScriptSubscriberSlot()
Class destructor.
SubscriberFunction * GetFunction() const
Gets a pointer to the function used by this subscriber slot.
A simple reference counting pointer.
Definition: countedptr.h:70
Event * SubbedEvent
A pointer to the connected event.
Event * GetEvent() const
Gets the set of events the subscriber is subscribed to.
The interface for a script.
Definition: script.h:70
virtual ~EventSubscriberSlot()
Class destructor.
virtual ~CustomSubscriberSlot()
Class destructor.
void( SubscriberFunction)(EventArgumentsPtr Args)
This is a convenience typedef for a c-style method that accepts EventArguments.
virtual void _NotifyEvent(EventArgumentsPtr Args)=0
Notifies this subscriber of an event being fired.
CustomSubscriberSlot(Event *Ev, EventSubscriber *Sub)
Class constructor.
ScriptSubscriberSlot(Event *Ev, Scripting::iScript *SubScript)
Class constructor.
EventSubscriber * GetSubscriber() const
Gets a pointer to the subscriber used by this subscriber slot.
EventSubscriber * Subscriber
A pointer to the custom subscriber that the event will be passed on to.
virtual void _NotifyEvent(EventArgumentsPtr Args)
Notifies this subscriber of an event being fired.
This class represents a slot in an event that can be subscribed to via subscribers, functors, or methods.
Scripting::iScript * SubscriberScript
A pointer to the script to be executed when the event is fired.
EventSubscriberSlot(Event *Ev)
Class constructor.
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
virtual SlotType GetType() const
Gets the type of subscriber slot this is.
FunctorEventSubscriber * GetFunctor() const
Gets a pointer to the functor used by this subscriber slot.
virtual SlotType GetType() const
Gets the type of subscriber slot this is.
SlotType
This enum is used to describe the type of SubscriberSlot an instance is, to be used for casting...
virtual void _NotifyEvent(EventArgumentsPtr Args)
Notifies this subscriber of an event being fired.
virtual ~CFunctionSubscriberSlot()
Class destructor.