CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Signaler.h
Go to the documentation of this file.
1 #ifndef SimG4Core_Notification_Signaler_h
2 #define SimG4Core_Notification_Signaler_h
3 // -*- C++ -*-
4 //
5 // Package: Notification
6 // Class : Signaler
7 //
21 //
22 // Original Author:
23 // Created: Sat Dec 1 10:17:20 EST 2007
24 //
25 
26 // system include files
27 #include <vector>
28 
29 // user include files
31 
32 // forward declarations
33 
34 namespace sim_act {
35  template <typename T>
36  class Signaler : public Observer<const T*> {
37  public:
39  Signaler() {}
40  ~Signaler() override {}
41 
42  // ---------- const member functions ---------------------
43  void operator()(const T* iSignal) const {
44  typedef typename std::vector<Observer<const T*>*>::const_iterator iterator;
45  for (iterator it = observers_.begin(); it != observers_.end(); ++it) {
46  (*it)->slotForUpdate(iSignal);
47  }
48  }
49 
50  // ---------- static member functions --------------------
51 
52  // ---------- member functions ---------------------------
53 
55  void connect(Observer<const T*>* iObs) { observers_.push_back(iObs); }
56 
58  void connect(Observer<const T*>& iObs) { observers_.push_back(&iObs); }
59 
60  Signaler(const Signaler&) = delete; // stop default
61  const Signaler& operator=(const Signaler&) = delete; // stop default
62 
63  private:
64  void update(const T* iData) override { this->operator()(iData); }
65  // ---------- member data --------------------------------
66  std::vector<Observer<const T*>*> observers_;
67  };
68 
69 } // namespace sim_act
70 #endif
void operator()(const T *iSignal) const
Definition: Signaler.h:43
~Signaler() override
Definition: Signaler.h:40
void connect(Observer< const T * > &iObs)
does not take ownership of memory
Definition: Signaler.h:58
void update(const T *iData) override
This routine will be called when the appropriate signal arrives.
Definition: Signaler.h:64
void connect(Observer< const T * > *iObs)
does not take ownership of memory
Definition: Signaler.h:55
const Signaler & operator=(const Signaler &)=delete
Observer< const T * > * slot_type
Definition: Signaler.h:38
std::vector< Observer< const T * > * > observers_
Definition: Signaler.h:66
long double T