Skip to content

Commit 6348819

Browse files
committed
Renamed Signal to State.
General progress.
1 parent d0e5375 commit 6348819

24 files changed

Lines changed: 1031 additions & 472 deletions

include/react/API.h

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ REACT_DEFINE_BITMASK_OPERATORS(TransactionFlags)
3737
/// API types
3838
///////////////////////////////////////////////////////////////////////////////////////////////////
3939

40-
// Groups
40+
// Group
4141
class Group;
4242

43-
// Signals
43+
// State
4444
template <typename S>
45-
class Signal;
45+
class State;
4646

4747
template <typename S>
48-
class VarSignal;
48+
class StateVar;
4949

5050
template <typename S>
51-
class SignalSlot;
51+
class StateSlot;
5252

5353
template <typename S>
54-
class SignalLink;
54+
class StateLink;
5555

56-
// Events
56+
// Event
5757
enum class Token;
5858

5959
template <typename E = Token>
@@ -65,39 +65,9 @@ class EventSource;
6565
template <typename E>
6666
class EventSlot;
6767

68-
// Observers
68+
// Observer
6969
class Observer;
7070

71-
///////////////////////////////////////////////////////////////////////////////////////////////////
72-
/// Traits
73-
///////////////////////////////////////////////////////////////////////////////////////////////////
74-
template <typename T>
75-
struct IsSignal { static const bool value = false; };
76-
77-
template <typename T>
78-
struct IsSignal<Signal<T>> { static const bool value = true; };
79-
80-
template <typename T>
81-
struct IsSignal<VarSignal<T>> { static const bool value = true; };
82-
83-
template <typename T>
84-
struct IsEvent { static const bool value = false; };
85-
86-
template <typename T>
87-
struct IsEvent<Event<T>> { static const bool value = true; };
88-
89-
template <typename T>
90-
struct IsEvent<EventSource<T>> { static const bool value = true; };
91-
92-
template <typename T>
93-
struct AsNonInputNode { using type = T; };
94-
95-
template <typename T>
96-
struct AsNonInputNode<VarSignal<T>> { using type = Signal<T>; };
97-
98-
template <typename T>
99-
struct AsNonInputNode<EventSource<T>> { using type = Event<T>; };
100-
10171
/******************************************/ REACT_END /******************************************/
10272

10373
#endif // REACT_TYPETRAITS_H_INCLUDED

include/react/Algorithm.h

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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)
@@ -18,52 +18,52 @@
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
///////////////////////////////////////////////////////////////////////////////////////////////////
2929
template <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

4040
template <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
///////////////////////////////////////////////////////////////////////////////////////////////////
4747
template <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

5858
template <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
///////////////////////////////////////////////////////////////////////////////////////////////////
6565
template <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

7979
template <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

9393
template <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

9797
template <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
///////////////////////////////////////////////////////////////////////////////////////////////////
104104
template <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

118118
template <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

132132
template <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

136136
template <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
///////////////////////////////////////////////////////////////////////////////////////////////////
143143
template <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

154154
template <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
///////////////////////////////////////////////////////////////////////////////////////////////////
161161
template <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

172172
template <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

Comments
 (0)