CMS 3D CMS Logo

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  {
38 
39  public:
41  Signaler() {}
42  virtual ~Signaler() {}
43 
44  // ---------- const member functions ---------------------
45  void operator()(const T* iSignal) const {
46  typedef typename std::vector<Observer<const T*>* >::const_iterator iterator;
47  for( iterator it = observers_.begin();
48  it != observers_.end();
49  ++it) {
50  (*it)->slotForUpdate(iSignal);
51  }
52  }
53 
54  // ---------- static member functions --------------------
55 
56  // ---------- member functions ---------------------------
57 
60  observers_.push_back(iObs);
61  }
62 
65  observers_.push_back(&iObs);
66  }
67 
68  private:
69  Signaler(const Signaler&); // stop default
70 
71  const Signaler& operator=(const Signaler&); // stop default
72 
73  void update(const T* iData) {
74  this->operator()(iData);
75  }
76  // ---------- member data --------------------------------
77  std::vector<Observer<const T*>* > observers_;
78  };
79 
80 }
81 #endif
std::vector< Observer< const T * > * > observers_
Definition: Signaler.h:77
void operator()(const T *iSignal) const
Definition: Signaler.h:45
virtual ~Signaler()
Definition: Signaler.h:42
void connect(Observer< const T * > &iObs)
does not take ownership of memory
Definition: Signaler.h:64
void connect(Observer< const T * > *iObs)
does not take ownership of memory
Definition: Signaler.h:59
Observer< const T * > * slot_type
Definition: Signaler.h:40
void update(const T *iData)
This routine will be called when the appropriate signal arrives.
Definition: Signaler.h:73
long double T
const Signaler & operator=(const Signaler &)