CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 // $Id$
25 //
26 
27 // system include files
28 #include <vector>
29 
30 // user include files
32 
33 // forward declarations
34 
35 namespace sim_act {
36  template <typename T>
37  class Signaler : public Observer<const T*>
38  {
39 
40  public:
42  Signaler() {}
43  virtual ~Signaler() {}
44 
45  // ---------- const member functions ---------------------
46  void operator()(const T* iSignal) const {
47  typedef typename std::vector<Observer<const T*>* >::const_iterator iterator;
48  for( iterator it = observers_.begin();
49  it != observers_.end();
50  ++it) {
51  (*it)->slotForUpdate(iSignal);
52  }
53  }
54 
55  // ---------- static member functions --------------------
56 
57  // ---------- member functions ---------------------------
58 
61  observers_.push_back(iObs);
62  }
63 
66  observers_.push_back(&iObs);
67  }
68 
69  private:
70  Signaler(const Signaler&); // stop default
71 
72  const Signaler& operator=(const Signaler&); // stop default
73 
74  void update(const T* iData) {
75  this->operator()(iData);
76  }
77  // ---------- member data --------------------------------
78  std::vector<Observer<const T*>* > observers_;
79  };
80 
81 }
82 #endif
std::vector< Observer< const T * > * > observers_
Definition: Signaler.h:78
void operator()(const T *iSignal) const
Definition: Signaler.h:46
virtual ~Signaler()
Definition: Signaler.h:43
void connect(Observer< const T * > &iObs)
does not take ownership of memory
Definition: Signaler.h:65
void connect(Observer< const T * > *iObs)
does not take ownership of memory
Definition: Signaler.h:60
Observer< const T * > * slot_type
Definition: Signaler.h:41
void update(const T *iData)
This routine will be called when the appropriate signal arrives.
Definition: Signaler.h:74
const Signaler & operator=(const Signaler &)