@@ -34,31 +34,25 @@ template
3434class EventStreamNode : public ReactiveNode <D,E,void >
3535{
3636public:
37- typedef std::vector<E> EventListT ;
38- typedef tbb::spin_mutex EventMutexT ;
37+ using EventListT = std::vector<E>;
38+ using EventMutexT = tbb::spin_mutex ;
3939
40- typedef std::shared_ptr<EventStreamNode> NodePtrT ;
41- typedef std::weak_ptr<EventStreamNode> NodeWeakPtrT ;
40+ using PtrT = std::shared_ptr<EventStreamNode>;
41+ using WeakPtrT = std::weak_ptr<EventStreamNode>;
4242
43- typedef typename D::Engine EngineT ;
44- typedef typename EngineT::TurnInterface TurnInterface;
43+ using EngineT = typename D::Engine;
44+ using TurnT = typename EngineT::TurnInterface;
4545
4646 explicit EventStreamNode (bool registered) :
47- ReactiveNode(true ),
48- curTurnId_{ INT_MAX }
47+ ReactiveNode(true )
4948 {
5049 if (!registered)
5150 registerNode ();
5251 }
5352
5453 virtual const char * GetNodeType () const override { return " EventStreamNode" ; }
5554
56- EventListT& Events ()
57- {
58- return events_;
59- }
60-
61- void SetCurrentTurn (const TurnInterface& turn, bool forceUpdate = false , bool noClear = false )
55+ void SetCurrentTurn (const TurnT& turn, bool forceUpdate = false , bool noClear = false )
6256 {// eventMutex_
6357 EventMutexT::scoped_lock lock (eventMutex_);
6458
@@ -70,21 +64,21 @@ class EventStreamNode : public ReactiveNode<D,E,void>
7064 }
7165 }// ~eventMutex_
7266
73- void ClearEvents () { events_.clear (); }
74-
75- const E& Front () { events_.front (); }
67+ EventListT& Events () { return events_; }
68+ void ClearEvents () { events_.clear (); }
7669
7770protected:
78- EventListT events_;
79- EventMutexT eventMutex_;
80- uint curTurnId_;
71+ EventListT events_;
72+ EventMutexT eventMutex_;
73+
74+ uint curTurnId_ = INT_MAX;
8175};
8276
8377template <typename D, typename E>
84- using EventStreamNodePtr = typename EventStreamNode<D,E>::NodePtrT ;
78+ using EventStreamNodePtr = typename EventStreamNode<D,E>::PtrT ;
8579
8680template <typename D, typename E>
87- using EventStreamNodeWeakPtr = typename EventStreamNode<D,E>::NodeWeakPtrT ;
81+ using EventStreamNodeWeakPtr = typename EventStreamNode<D,E>::WeakPtrT ;
8882
8983// /////////////////////////////////////////////////////////////////////////////////////////////////
9084// / EventSourceNode
@@ -110,8 +104,8 @@ class EventSourceNode : public EventStreamNode<D,E>
110104 {
111105 if (events_.size () > 0 && !changedFlag_)
112106 {
113- typedef typename D::Engine::TurnInterface TurnInterface;
114- TurnInterface & turn = *static_cast <TurnInterface*>(turnPtr);
107+ using TurnT = typename D::Engine::TurnInterface;
108+ TurnT & turn = *static_cast <TurnInterface*>(turnPtr);
115109
116110 SetCurrentTurn (turn, true , true );
117111 changedFlag_ = true ;
@@ -155,9 +149,6 @@ template
155149class EventMergeNode : public EventStreamNode <D, E>
156150{
157151public:
158- typedef typename D::Engine EngineT;
159- typedef typename EngineT::TurnInterface TurnInterface;
160-
161152 EventMergeNode (const EventStreamNodePtr<D, TArgs>& ... args, bool registered) :
162153 EventStreamNode<D, E>(true ),
163154 deps_{ make_tuple (args ...) },
@@ -185,8 +176,8 @@ class EventMergeNode : public EventStreamNode<D, E>
185176
186177 virtual ETickResult Tick (void * turnPtr) override
187178 {
188-
189- TurnInterface & turn = *static_cast <TurnInterface *>(turnPtr);
179+ using TurnT = typename D::Engine::TurnInterface;
180+ TurnT & turn = *static_cast <TurnT *>(turnPtr);
190181
191182 // printf("EventMergeNode: Tick %08X by thread %08X\n", this, std::this_thread::get_id().hash());
192183
@@ -211,8 +202,8 @@ class EventMergeNode : public EventStreamNode<D, E>
211202 virtual int DependencyCount () const override { return sizeof ... (TArgs); }
212203
213204private:
214- std::tuple<EventStreamNodePtr<D, TArgs> ...> deps_;
215- std::function<void (const TurnInterface&)> func_;
205+ const std::tuple<EventStreamNodePtr<D, TArgs> ...> deps_;
206+ const std::function<void (const TurnInterface&)> func_;
216207
217208 inline void expand (const TurnInterface& turn, const EventStreamNodePtr<D, TArgs>& ... args)
218209 {
@@ -260,9 +251,8 @@ class EventFilterNode : public EventStreamNode<D, E>
260251
261252 virtual ETickResult Tick (void * turnPtr) override
262253 {
263- typedef typename D::Engine EngineT;
264- typedef typename EngineT::TurnInterface TurnInterface;
265- TurnInterface& turn = *static_cast <TurnInterface*>(turnPtr);
254+ using TurnT = typename D::Engine::TurnInterface;
255+ TurnT& turn = *static_cast <TurnT*>(turnPtr);
266256
267257 SetCurrentTurn (turn, true );
268258
@@ -285,9 +275,8 @@ class EventFilterNode : public EventStreamNode<D, E>
285275 virtual int DependencyCount () const override { return 1 ; }
286276
287277private:
288- EventStreamNodePtr<D,E> src_;
289-
290- std::function<bool (const E&)> filter_;
278+ const EventStreamNodePtr<D,E> src_;
279+ const std::function<bool (const E&)> filter_;
291280};
292281
293282// /////////////////////////////////////////////////////////////////////////////////////////////////
@@ -323,9 +312,8 @@ class EventTransformNode : public EventStreamNode<D,TOut>
323312
324313 virtual ETickResult Tick (void * turnPtr) override
325314 {
326- typedef typename D::Engine EngineT;
327- typedef typename EngineT::TurnInterface TurnInterface;
328- TurnInterface& turn = *static_cast <TurnInterface*>(turnPtr);
315+ using TurnT = typename D::Engine::TurnInterface;
316+ TurnT& turn = *static_cast <TurnT*>(turnPtr);
329317
330318 SetCurrentTurn (turn, true );
331319
@@ -348,9 +336,8 @@ class EventTransformNode : public EventStreamNode<D,TOut>
348336 virtual int DependencyCount () const override { return 1 ; }
349337
350338private:
351- EventStreamNodePtr<D,TIn> src_;
352-
353- std::function<TOut(const TIn&)> func_;
339+ const EventStreamNodePtr<D,TIn> src_;
340+ const std::function<TOut(const TIn&)> func_;
354341};
355342
356343/* ***************************************/ REACT_IMPL_END /* **************************************/
0 commit comments