11
2- // Copyright Sebastian Jeckel 2016 .
2+ // Copyright Sebastian Jeckel 2017 .
33// Distributed under the Boost Software License, Version 1.0.
44// (See accompanying file LICENSE_1_0.txt or copy at
55// http://www.boost.org/LICENSE_1_0.txt)
1818#include " react/API.h"
1919#include " react/detail/algorithm_nodes.h"
2020
21+ #include " react/state.h"
2122#include " react/event.h"
22- #include " react/signal.h"
2323
2424/* ****************************************/ REACT_BEGIN /* ****************************************/
2525
2626// /////////////////////////////////////////////////////////////////////////////////////////////////
27- // / Hold the most recent event in a signal
27+ // / Hold the most recent event in a state
2828// /////////////////////////////////////////////////////////////////////////////////////////////////
2929template <typename T, typename E>
30- auto Hold (const Group& group, T&& initialValue, const Event<E>& evnt) -> Signal <E>
30+ auto Hold (const Group& group, T&& initialValue, const Event<E>& evnt) -> State <E>
3131{
3232 using REACT_IMPL ::HoldNode;
3333 using REACT_IMPL ::SameGroupOrLink;
3434 using REACT_IMPL ::CreateWrappedNode;
3535
36- return CreateWrappedNode<Signal <E>, HoldNode<E>>(
36+ return CreateWrappedNode<State <E>, HoldNode<E>>(
3737 group, std::forward<T>(initialValue), SameGroupOrLink (group, evnt));
3838}
3939
4040template <typename T, typename E>
41- auto Hold (T&& initialValue, const Event<E>& evnt) -> Signal <E>
41+ auto Hold (T&& initialValue, const Event<E>& evnt) -> State <E>
4242 { return Hold (evnt.GetGroup (), std::forward<T>(initialValue), evnt); }
4343
4444// /////////////////////////////////////////////////////////////////////////////////////////////////
45- // / Emits value changes of target signal .
45+ // / Emits value changes of target state .
4646// /////////////////////////////////////////////////////////////////////////////////////////////////
4747template <typename S>
48- auto Monitor (const Group& group, const Signal <S>& signal ) -> Event<S>
48+ auto Monitor (const Group& group, const State <S>& state ) -> Event<S>
4949{
5050 using REACT_IMPL ::MonitorNode;
5151 using REACT_IMPL ::SameGroupOrLink;
5252 using REACT_IMPL ::CreateWrappedNode;
5353
5454 return CreateWrappedNode<Event<S>, MonitorNode<S>>(
55- group, SameGroupOrLink (group, signal ));
55+ group, SameGroupOrLink (group, state ));
5656}
5757
5858template <typename S>
59- auto Monitor (const Signal <S>& signal ) -> Event<S>
60- { return Monitor (signal .GetGroup (), signal ); }
59+ auto Monitor (const State <S>& state ) -> Event<S>
60+ { return Monitor (state .GetGroup (), state ); }
6161
6262// /////////////////////////////////////////////////////////////////////////////////////////////////
63- // / Iterate - Iteratively combines signal value with values from event stream (aka Fold)
63+ // / Iterate - Iteratively combines state value with values from event stream (aka Fold)
6464// /////////////////////////////////////////////////////////////////////////////////////////////////
6565template <typename S, typename T, typename F, typename E>
66- auto Iterate (const Group& group, T&& initialValue, F&& func, const Event<E>& evnt) -> Signal <S>
66+ auto Iterate (const Group& group, T&& initialValue, F&& func, const Event<E>& evnt) -> State <S>
6767{
6868 using REACT_IMPL ::IterateNode;
6969 using REACT_IMPL ::IsCallableWith;
@@ -72,12 +72,12 @@ auto Iterate(const Group& group, T&& initialValue, F&& func, const Event<E>& evn
7272
7373 using FuncType = typename std::decay<F>::type;
7474
75- return CreateWrappedNode<Signal <S>, IterateNode<S, FuncType, E>>(
75+ return CreateWrappedNode<State <S>, IterateNode<S, FuncType, E>>(
7676 group, std::forward<T>(initialValue), std::forward<F>(func), SameGroupOrLink (group, evnt));
7777}
7878
7979template <typename S, typename T, typename F, typename E>
80- auto IterateByRef (const Group& group, T&& initialValue, F&& func, const Event<E>& evnt) -> Signal <S>
80+ auto IterateByRef (const Group& group, T&& initialValue, F&& func, const Event<E>& evnt) -> State <S>
8181{
8282 using REACT_IMPL ::IterateByRefNode;
8383 using REACT_IMPL ::IsCallableWith;
@@ -86,23 +86,23 @@ auto IterateByRef(const Group& group, T&& initialValue, F&& func, const Event<E>
8686
8787 using FuncType = typename std::decay<F>::type;
8888
89- return CreateWrappedNode<Signal <S>, IterateByRefNode<S, FuncType, E>>(
89+ return CreateWrappedNode<State <S>, IterateByRefNode<S, FuncType, E>>(
9090 group, std::forward<T>(initialValue), std::forward<F>(func), SameGroupOrLink (group, evnt));
9191}
9292
9393template <typename S, typename T, typename F, typename E>
94- auto Iterate (T&& initialValue, F&& func, const Event<E>& evnt) -> Signal <S>
94+ auto Iterate (T&& initialValue, F&& func, const Event<E>& evnt) -> State <S>
9595 { return Iterate<S>(evnt.GetGroup (), std::forward<T>(initialValue), std::forward<F>(func), evnt); }
9696
9797template <typename S, typename T, typename F, typename E>
98- auto IterateByRef (T&& initialValue, F&& func, const Event<E>& evnt) -> Signal <S>
98+ auto IterateByRef (T&& initialValue, F&& func, const Event<E>& evnt) -> State <S>
9999 { return IterateByRef<S>(evnt.GetGroup (), std::forward<T>(initialValue), std::forward<F>(func), evnt); }
100100
101101// /////////////////////////////////////////////////////////////////////////////////////////////////
102102// / Iterate - Synced
103103// /////////////////////////////////////////////////////////////////////////////////////////////////
104104template <typename S, typename T, typename F, typename E, typename ... Us>
105- auto Iterate (const Group& group, T&& initialValue, F&& func, const Event<E>& evnt, const Signal <Us>& ... signals ) -> Signal <S>
105+ auto Iterate (const Group& group, T&& initialValue, F&& func, const Event<E>& evnt, const State <Us>& ... states ) -> State <S>
106106{
107107 using REACT_IMPL ::SyncedIterateNode;
108108 using REACT_IMPL ::IsCallableWith;
@@ -111,12 +111,12 @@ auto Iterate(const Group& group, T&& initialValue, F&& func, const Event<E>& evn
111111
112112 using FuncType = typename std::decay<F>::type;
113113
114- return CreateWrappedNode<Signal <S>, SyncedIterateNode<S, FuncType, E, Us ...>>(
115- group, std::forward<T>(initialValue), std::forward<F>(func), SameGroupOrLink (group, evnt), SameGroupOrLink (group, signals ) ...);
114+ return CreateWrappedNode<State <S>, SyncedIterateNode<S, FuncType, E, Us ...>>(
115+ group, std::forward<T>(initialValue), std::forward<F>(func), SameGroupOrLink (group, evnt), SameGroupOrLink (group, states ) ...);
116116}
117117
118118template <typename S, typename T, typename F, typename E, typename ... Us>
119- auto IterateByRef (const Group& group, T&& initialValue, F&& func, const Event<E>& evnt, const Signal <Us>& ... signals ) -> Signal <S>
119+ auto IterateByRef (const Group& group, T&& initialValue, F&& func, const Event<E>& evnt, const State <Us>& ... states ) -> State <S>
120120{
121121 using REACT_IMPL ::SyncedIterateByRefNode;
122122 using REACT_IMPL ::IsCallableWith;
@@ -125,53 +125,53 @@ auto IterateByRef(const Group& group, T&& initialValue, F&& func, const Event<E>
125125
126126 using FuncType = typename std::decay<F>::type;
127127
128- return CreateWrappedNode<Signal <S>, SyncedIterateByRefNode<S, FuncType, E, Us ...>>(
129- group, std::forward<T>(initialValue), std::forward<F>(func), SameGroupOrLink (group, evnt), SameGroupOrLink (group, signals ) ...);
128+ return CreateWrappedNode<State <S>, SyncedIterateByRefNode<S, FuncType, E, Us ...>>(
129+ group, std::forward<T>(initialValue), std::forward<F>(func), SameGroupOrLink (group, evnt), SameGroupOrLink (group, states ) ...);
130130}
131131
132132template <typename S, typename T, typename F, typename E, typename ... Us>
133- auto Iterate (T&& initialValue, F&& func, const Event<E>& evnt, const Signal <Us>& ... signals ) -> Signal <S>
134- { return Iterate<S>(evnt.GetGroup (), std::forward<T>(initialValue), std::forward<F>(func), evnt, signals ...); }
133+ auto Iterate (T&& initialValue, F&& func, const Event<E>& evnt, const State <Us>& ... states ) -> State <S>
134+ { return Iterate<S>(evnt.GetGroup (), std::forward<T>(initialValue), std::forward<F>(func), evnt, states ...); }
135135
136136template <typename S, typename T, typename F, typename E, typename ... Us>
137- auto IterateByRef (T&& initialValue, F&& func, const Event<E>& evnt, const Signal <Us>& ... signals ) -> Signal <S>
138- { return IterateByRef<S>(evnt.GetGroup (), std::forward<T>(initialValue), std::forward<F>(func), evnt, signals ...); }
137+ auto IterateByRef (T&& initialValue, F&& func, const Event<E>& evnt, const State <Us>& ... states ) -> State <S>
138+ { return IterateByRef<S>(evnt.GetGroup (), std::forward<T>(initialValue), std::forward<F>(func), evnt, states ...); }
139139
140140// /////////////////////////////////////////////////////////////////////////////////////////////////
141- // / Snapshot - Sets signal value to value of other signal when event is received
141+ // / Snapshot - Sets state value to value of other state when event is received
142142// /////////////////////////////////////////////////////////////////////////////////////////////////
143143template <typename S, typename E>
144- auto Snapshot (const Group& group, const Signal <S>& signal , const Event<E>& evnt) -> Signal <S>
144+ auto Snapshot (const Group& group, const State <S>& state , const Event<E>& evnt) -> State <S>
145145{
146146 using REACT_IMPL ::SnapshotNode;
147147 using REACT_IMPL ::SameGroupOrLink;
148148 using REACT_IMPL ::CreateWrappedNode;
149149
150- return CreateWrappedNode<Signal <S>, SnapshotNode<S, E>>(
151- group, SameGroupOrLink (group, signal ), SameGroupOrLink (group, evnt));
150+ return CreateWrappedNode<State <S>, SnapshotNode<S, E>>(
151+ group, SameGroupOrLink (group, state ), SameGroupOrLink (group, evnt));
152152}
153153
154154template <typename S, typename E>
155- auto Snapshot (const Signal <S>& signal , const Event<E>& evnt) -> Signal <S>
156- { return Snapshot (signal .GetGroup (), signal , evnt); }
155+ auto Snapshot (const State <S>& state , const Event<E>& evnt) -> State <S>
156+ { return Snapshot (state .GetGroup (), state , evnt); }
157157
158158// /////////////////////////////////////////////////////////////////////////////////////////////////
159- // / Pulse - Emits value of target signal when event is received
159+ // / Pulse - Emits value of target state when event is received
160160// /////////////////////////////////////////////////////////////////////////////////////////////////
161161template <typename S, typename E>
162- auto Pulse (const Group& group, const Signal <S>& signal , const Event<E>& evnt) -> Event<S>
162+ auto Pulse (const Group& group, const State <S>& state , const Event<E>& evnt) -> Event<S>
163163{
164164 using REACT_IMPL ::PulseNode;
165165 using REACT_IMPL ::SameGroupOrLink;
166166 using REACT_IMPL ::CreateWrappedNode;
167167
168168 return CreateWrappedNode<Event<S>, PulseNode<S, E>>(
169- group, SameGroupOrLink (group, signal ), SameGroupOrLink (group, evnt));
169+ group, SameGroupOrLink (group, state ), SameGroupOrLink (group, evnt));
170170}
171171
172172template <typename S, typename E>
173- auto Pulse (const Signal <S>& signal , const Event<E>& evnt) -> Event<S>
174- { return Pulse (signal .GetGroup (), signal , evnt); }
173+ auto Pulse (const State <S>& state , const Event<E>& evnt) -> Event<S>
174+ { return Pulse (state .GetGroup (), state , evnt); }
175175
176176/* *****************************************/ REACT_END /* *****************************************/
177177
0 commit comments