BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Calibration/facilities/include/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> class SimpleEvent : public ScheduledEvent {
9 // A template class for simple events. The template parameter is the
10 // class which is the receiver, i.e the class which actually performs
11 // the operations.
12 // usage: Scheduler::instance()->schedule(time, new SimpleEvent<MyClass>(my_instance,
13 // &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 )
23 , m_action( a )
24 // ## end SimpleEvent::SimpleEvent%249491085.initialization
25 {
26
27 // ## begin SimpleEvent::SimpleEvent%249491085.body preserve=yes
28 // ## end SimpleEvent::SimpleEvent%249491085.body
29 };
30 // Constructor needs the receiver class and the method to invoke in that class
31
32 SimpleEvent( 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 }
41
42private:
43 Receiver* m_receiver;
44 Action m_action;
45 std::string m_name;
46};
47
48template <class Receiver> inline void SimpleEvent<Receiver>::execute() {
49 // ## begin SimpleEvent::execute%478434479.body preserve=yes
50 if ( m_receiver ) ( m_receiver->*m_action )();
51 // ## end SimpleEvent::execute%478434479.body
52}
53
54#endif
const Int_t n
virtual std::string name() const
SimpleEvent(Receiver *r, Action a, std::string n)