BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
InstallArea/include/facilities/facilities/SimpleEvent.h
Go to the documentation of this file.
1//
2#ifndef SIMPLEEVENT_H
3#define SIMPLEEVENT_H
4//## begin module.includes preserve=yes
5#include "ScheduledEvent.h"
6
7//## end module.includes preserve=yes
8template <class Receiver>
9class SimpleEvent : public ScheduledEvent {
10 // A template class for simple events. The template parameter is the
11 // class which is the receiver, i.e the class which actually performs
12 // the operations.
13 // usage: Scheduler::instance()->schedule(time, new SimpleEvent<MyClass>(my_instance, &MyClass::method));
14public:
15//## begin SimpleEvent.initialDeclarations preserve=yes
16public:
17 typedef void (Receiver::* Action)();
18
19//## end SimpleEvent.initialDeclarations
20 SimpleEvent(Receiver* r, Action a)
21//## begin SimpleEvent::SimpleEvent%249491085.initialization preserve=yes
22:m_receiver(r),m_action(a)
23//## end SimpleEvent::SimpleEvent%249491085.initialization
24{
25
26//## begin SimpleEvent::SimpleEvent%249491085.body preserve=yes
27//## end SimpleEvent::SimpleEvent%249491085.body
28}
29;
30 // Constructor needs the receiver class and the method to invoke in that class
31
32SimpleEvent(Receiver*r, Action a, std::string n)
33: m_receiver(r), m_action(a), m_name(n){};
34
35 virtual void execute();
36 // All a command can do - tells the receiver to perform the action.
37
38 virtual std::string name()const {
39 return !m_name.empty()? m_name : ScheduledEvent::name();}
40
41private:
42 Receiver* m_receiver;
43 Action m_action;
44 std::string m_name;
45
46};
47
48template <class Receiver> inline
50//## begin SimpleEvent::execute%478434479.body preserve=yes
51 if (m_receiver) (m_receiver->*m_action)();
52//## end SimpleEvent::execute%478434479.body
53}
54
55
56#endif
const Int_t n
virtual std::string name() const
SimpleEvent(Receiver *r, Action a, std::string n)
virtual void execute()