Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
notifier.h
Go to the documentation of this file.
1 
18 #ifndef ION_BASE_NOTIFIER_H_
19 #define ION_BASE_NOTIFIER_H_
20 
21 #include <algorithm>
22 
23 #include "ion/base/lockguards.h"
24 #include "ion/base/readwritelock.h"
26 #include "ion/base/weakreferent.h"
27 #include "ion/port/mutex.h"
28 
29 namespace ion {
30 namespace base {
31 
35 class ION_API Notifier : public WeakReferent {
36  public:
39  void AddReceiver(Notifier* receiver);
40 
43  void RemoveReceiver(Notifier* receiver);
44 
46  size_t GetReceiverCount() const;
47 
48  protected:
51 
54  Notifier() : receivers_(*this) {}
56  ~Notifier() override;
57 
59  const NotifierPtrVector& GetReceivers() const;
60 
63  void Notify() const;
64 
66  virtual void OnNotify(const Notifier* notifier);
67 
68  private:
70  mutable NotifierPtrVector receivers_;
73 };
74 
75 } // namespace base
76 } // namespace ion
77 
78 #endif // ION_BASE_NOTIFIER_H_
Notifier()
The constructor is protected because this is a base class and should not be created on its own...
Definition: notifier.h:54
A Notifier both sends notifications to and receives notifications from other Notifiers.
Definition: notifier.h:35
AllocVector< NotifierPtr > NotifierPtrVector
Definition: notifier.h:50
WeakReferentPtr< Notifier > NotifierPtr
Definition: notifier.h:49
The ReadWriteLock class defines a non-promotable lock that is very fast when only readers try to obta...
Definition: readwritelock.h:51
Abstract base class that inherits from Referent, and adds the ability for instances to be referenced ...
Definition: weakreferent.h:40
port::Mutex mutex_
Protects shared access to the Allocator and FT_Library.
A WeakReferentPtr is a weak reference to an instance of some class derived from Referent.
Definition: weakreferent.h:182