Free Electron
ChainSignaler.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __signal_ChainSignaler_h__
8 #define __signal_ChainSignaler_h__
9 
10 //#if FE_CODEGEN<FE_OPTIMIZE
11 //#ifndef FE_CHAINSIGNALER_PROFILING
12 //#define FE_CHAINSIGNALER_PROFILING
13 //#endif
14 //#endif
15 
16 namespace fe
17 {
18 namespace ext
19 {
20 
21 /** @brief SignalerI that calls registered HandlerI instances in order
22 
23  @ingroup signal
24 
25  If a signal has an <int> attribute named _TTL and its value is greater
26  than zero, it is decremented by 1. If it is zero the handlers are not
27  called (the signal is in effect killed). This is useful in breaking cycles.
28  */
29 class FE_DL_EXPORT ChainSignaler:
30  virtual public SignalerI,
31  public ObjectSafe<ChainSignaler>,
32  public CastableAs<ChainSignaler>
33 {
34  public:
35  ChainSignaler(void);
36 virtual ~ChainSignaler(void);
37 
38 virtual void signal(Record &signal);
39 virtual void insert(sp<HandlerI> spHandlerI, sp<Layout> spLayout,
40  IWORD clue = -1);
41 virtual void remove(sp<HandlerI> spHandlerI, sp<Layout> spLayout);
42 virtual bool contains(sp<HandlerI> spHandlerI, sp<Layout> spLayout);
43 virtual void peek(Peeker &peeker);
44 #ifdef MODAL_SIGNALER
45 virtual void setMode(const String &aMode, bool aIsActive);
46 virtual bool getMode(const String &aMode);
47 virtual void insert(sp<HandlerI> spHandlerI, sp<Layout> spLayout,
48  const String &aMode, IWORD clue = -1);
49 #endif
50 
51  protected:
52 
53  class Entry
54  {
55  public:
56  Entry(void);
57  virtual ~Entry(void);
58  sp<Component> m_component;
59 #ifdef MODAL_SIGNALER
60  unsigned int m_mode;
61 #endif
62  };
63 
64  typedef std::map< sp<Layout>, List< Entry* > > t_entrymap;
65 
66 virtual void signalEntries(Record &signal, t_entrymap *a_entryMap);
67 
68  void signalHandler(Record &signal,
69  const sp<HandlerI> &spHandler);
70 
71  private:
72 
73  t_entrymap m_entryMap;
74  Accessor<int> m_aTTL;
75 #ifdef MODAL_SIGNALER
76  Array<bool> m_modeSwitch;
77  std::map<String, unsigned int> m_modes;
78 #endif
79 
80 #ifdef FE_CHAINSIGNALER_PROFILING
81  class Profile
82  {
83  public:
84  Profile(void)
85  {
86  m_count = 0;
87  m_ms = 0;
88  m_us = 0;
89  }
90  FE_UWORD m_count;
91  FE_UWORD m_ms;
92  FE_UWORD m_us;
93  };
94  std::map< sp<Layout>, Profile > m_layoutProfiles;
95  std::map< sp<Layout>, std::map<String, Profile> > m_componentProfiles;
96 
97  SystemTicker* m_pTicker;
98 #endif
99 };
100 
101 } /* namespace ext */
102 } /* namespace fe */
103 
104 #endif /* __signal_ChainSignaler_h__ */
105 
Object level locking for thread safety.
Definition: Safe.h:216
kernel
Definition: namespace.dox:3
Selective record broadcaster.
Definition: SignalerI.h:20
High precision timer.
Definition: SystemTicker.h:174
Automatically reference-counted string container.
Definition: String.h:128
Wrapper for std::vector.
Definition: Array.h:21
Reference to an instance of a Layout.
Definition: RecordSB.h:35
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
SignalerI that calls registered HandlerI instances in order.
Definition: ChainSignaler.h:29
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192