Emergency 20 Dokumentation  4.2.0
MessageObserver.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
14 
16 
17 
18 //[-------------------------------------------------------]
19 //[ Namespace ]
20 //[-------------------------------------------------------]
21 namespace em5
22 {
23 
24 
25  //[-------------------------------------------------------]
26  //[ Classes ]
27  //[-------------------------------------------------------]
34  {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Public definitions ]
39  //[-------------------------------------------------------]
40  public:
41  static const uint32 GAMELOGIC_TYPE_ID; // "em5::MessageObserver" game logic type ID
42 
43  enum LogicType
44  {
45  OR_LOGIC = 0, // ObserverMessage when Message1 OR Message2
46  AND_LOGIC // ObserverMessage when Message1 AND Message2
47  };
48 
50  {
51  FALSE_CHECK = 0, // Only used to check for the expression
52  TRUE_REACT, // Create an ObserverMessage if the expression is true
53  TRUE_CHECK, // Only used to check for the expression
54  };
55 
56  // bool parameter: true = second message, false = first message
57  typedef boost::function<bool (const qsf::MessageParameters&, bool)> CustomFilterCallback;
58 
59 
60  //[-------------------------------------------------------]
61  //[ Public methods ]
62  //[-------------------------------------------------------]
63  public:
69 
81  void initialize(const qsf::MessageConfiguration& message1, const qsf::MessageConfiguration& message2, LogicType logicType);
82 
96  void initialize(const qsf::MessageConfiguration& message1, const qsf::MessageConfiguration& message2, LogicType logicType, MessageTypeForAnd messageType2);
97 
105  void setCustomMessageFilter(const CustomFilterCallback& customFilterCallback);
106 
107 
108  //[-------------------------------------------------------]
109  //[ Public virtual qsf::GameLogic methods ]
110  //[-------------------------------------------------------]
111  public:
112  virtual bool onStartup() override;
113  virtual void onShutdown() override;
114  virtual void serialize(qsf::BinarySerializer& serializer) override;
115 
116 
117  //[-------------------------------------------------------]
118  //[ Private methods ]
119  //[-------------------------------------------------------]
120  private:
121  void onMessage1(const qsf::MessageParameters& parameters);
122  void onMessage2(const qsf::MessageParameters& parameters);
123 
124 
125  //[-------------------------------------------------------]
126  //[ Private data ]
127  //[-------------------------------------------------------]
128  private:
129  LogicType mLogicType;
130  qsf::MessageProxy mMessageProxy1;
131  qsf::MessageProxy mMessageProxy2;
132  bool mActivatedMessage1;
133  bool mActivatedMessage2;
134  MessageTypeForAnd mMessageType2;
135  CustomFilterCallback mCustomMessageFilter;
136 
137 
138  //[-------------------------------------------------------]
139  //[ CAMP reflection system ]
140  //[-------------------------------------------------------]
141  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
142 
143 
144  };
145 
146 
147 //[-------------------------------------------------------]
148 //[ Namespace ]
149 //[-------------------------------------------------------]
150 } // em5
151 
152 
153 //[-------------------------------------------------------]
154 //[ CAMP reflection system ]
155 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
EMERGENCY 5 observer base class.
Definition: Observer.h:41
Message parameters class.
Definition: MessageParameters.h:34
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
EMERGENCY 5 logic message observer.
Definition: MessageObserver.h:33
Message listener proxy class.
Definition: MessageProxy.h:47
Definition: MessageObserver.h:52
void serialize(BinarySerializer &serializer, BitFlagSet< STORAGE, ENUM > &bitFlagSet)
Definition: BitFlagSet.h:359
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Message configuration class.
Definition: MessageConfiguration.h:44
MessageTypeForAnd
Definition: MessageObserver.h:49
static const uint32 GAMELOGIC_TYPE_ID
Definition: MessageObserver.h:41
Definition: MessageObserver.h:53
LogicType
Definition: MessageObserver.h:43
boost::function< bool(const qsf::MessageParameters &, bool)> CustomFilterCallback
Definition: MessageObserver.h:57
Binary serializer class.
Definition: BinarySerializer.h:35