Skip to content

Commit e32118d

Browse files
committed
Refactoring.
1 parent f616980 commit e32118d

29 files changed

Lines changed: 170 additions & 156 deletions

include/react/Defs.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#pragma once
22

33
////////////////////////////////////////////////////////////////////////////////////////
4-
#define REACT_BEGIN_ namespace react {
5-
#define REACT_END_ }
6-
#define REACT_ ::react
4+
#define REACT_BEGIN namespace react {
5+
#define REACT_END }
6+
#define REACT ::react
77

8-
#define REACT_IMPL_BEGIN_ REACT_BEGIN_ namespace impl {
9-
#define REACT_IMPL_END_ REACT_END_ }
10-
#define REACT_IMPL_ REACT_ ::impl
8+
#define REACT_IMPL_BEGIN REACT_BEGIN namespace impl {
9+
#define REACT_IMPL_END REACT_END }
10+
#define REACT_IMPL REACT ::impl
1111

1212
////////////////////////////////////////////////////////////////////////////////////////
13-
REACT_BEGIN_
13+
REACT_BEGIN
1414

1515
typedef unsigned int uint;
1616
typedef unsigned char uchar;
1717

18-
REACT_END_
18+
REACT_END

include/react/EventStream.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "react/graph/EventStreamNodes.h"
1313

1414
////////////////////////////////////////////////////////////////////////////////////////
15-
REACT_BEGIN_
15+
REACT_BEGIN
1616

1717
template <typename T>
1818
class Reactive;
@@ -30,10 +30,10 @@ template
3030
typename D,
3131
typename E = EventToken
3232
>
33-
class REvents : public Reactive<REACT_IMPL_::EventStreamNode<D,E>>
33+
class REvents : public Reactive<REACT_IMPL::EventStreamNode<D,E>>
3434
{
3535
protected:
36-
using NodeT = REACT_IMPL_::EventStreamNode<D, E>;
36+
using NodeT = REACT_IMPL::EventStreamNode<D, E>;
3737

3838
public:
3939
using ValueT = E;
@@ -67,19 +67,19 @@ class REvents : public Reactive<REACT_IMPL_::EventStreamNode<D,E>>
6767
}
6868
};
6969

70-
REACT_END_
70+
REACT_END
7171

72-
REACT_IMPL_BEGIN_
72+
REACT_IMPL_BEGIN
7373

7474
template <typename D, typename L, typename R>
7575
bool Equals(const REvents<D,L>& lhs, const REvents<D,R>& rhs)
7676
{
7777
return lhs.Equals(rhs);
7878
}
7979

80-
REACT_IMPL_END_
80+
REACT_IMPL_END
8181

82-
REACT_BEGIN_
82+
REACT_BEGIN
8383

8484
////////////////////////////////////////////////////////////////////////////////////////
8585
/// REventSource
@@ -92,7 +92,7 @@ template
9292
class REventSource : public REvents<D,E>
9393
{
9494
private:
95-
using NodeT = REACT_IMPL_::EventSourceNode<D, E>;
95+
using NodeT = REACT_IMPL::EventSourceNode<D, E>;
9696

9797
public:
9898
REventSource() :
@@ -144,15 +144,15 @@ inline auto MakeEventSource()
144144
-> REventSource<D,E>
145145
{
146146
return REventSource<D,E>(
147-
std::make_shared<REACT_IMPL_::EventSourceNode<D,E>>(false));
147+
std::make_shared<REACT_IMPL::EventSourceNode<D,E>>(false));
148148
}
149149

150150
template <typename D>
151151
inline auto MakeEventSource()
152152
-> REventSource<D,EventToken>
153153
{
154154
return REventSource<D,EventToken>(
155-
std::make_shared<REACT_IMPL_::EventSourceNode<D,EventToken>>(false));
155+
std::make_shared<REACT_IMPL::EventSourceNode<D,EventToken>>(false));
156156
}
157157

158158
////////////////////////////////////////////////////////////////////////////////////////
@@ -173,7 +173,7 @@ inline auto Merge(const REvents<D,TArg1>& arg1,
173173

174174
typedef TArg1 E;
175175
return REvents<D,E>(
176-
std::make_shared<REACT_IMPL_::EventMergeNode<D, E, TArg1, TArgs ...>>(
176+
std::make_shared<REACT_IMPL::EventMergeNode<D, E, TArg1, TArgs ...>>(
177177
arg1.GetPtr(), args.GetPtr() ..., false));
178178
}
179179

@@ -203,7 +203,7 @@ inline auto Filter(const REvents<D,E>& src, F&& filter)
203203
-> REvents<D,E>
204204
{
205205
return REvents<D,E>(
206-
std::make_shared<REACT_IMPL_::EventFilterNode<D, E>>(
206+
std::make_shared<REACT_IMPL::EventFilterNode<D, E>>(
207207
src.GetPtr(), std::forward<F>(filter), false));
208208
}
209209

@@ -248,8 +248,8 @@ inline auto Transform(const REvents<D,TIn>& src, F&& func)
248248
typedef decltype(func(src.GetPtr()->Front())) TOut;
249249

250250
return REvents<D,TOut>(
251-
std::make_shared<REACT_IMPL_::EventTransformNode<D, TIn, TOut>>(
251+
std::make_shared<REACT_IMPL::EventTransformNode<D, TIn, TOut>>(
252252
src.GetPtr(), std::forward<F>(func), false));
253253
}
254254

255-
REACT_END_
255+
REACT_END

include/react/Observer.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "react/graph/ObserverNodes.h"
99

1010
////////////////////////////////////////////////////////////////////////////////////////
11-
REACT_BEGIN_
11+
REACT_BEGIN
1212

1313
template <typename T>
1414
class Reactive;
@@ -28,8 +28,8 @@ template <typename D>
2828
class RObserver
2929
{
3030
public:
31-
using SubjectT = REACT_IMPL_::NodeBase<D>;
32-
using ObserverNodeT = REACT_IMPL_::ObserverNode<D>;
31+
using SubjectT = REACT_IMPL::NodeBase<D>;
32+
using ObserverNodeT = REACT_IMPL::ObserverNode<D>;
3333

3434
RObserver() :
3535
ptr_{ nullptr },
@@ -65,9 +65,9 @@ class RObserver
6565
std::shared_ptr<SubjectT> subject_;
6666
};
6767

68-
REACT_END_
68+
REACT_END
6969

70-
REACT_IMPL_BEGIN_
70+
REACT_IMPL_BEGIN
7171

7272
////////////////////////////////////////////////////////////////////////////////////////
7373
/// ObserverRegistry
@@ -135,9 +135,9 @@ class ObserverRegistry
135135
std::unordered_map<IObserverNode*,Entry_> observerMap_;
136136
};
137137

138-
REACT_IMPL_END_
138+
REACT_IMPL_END
139139

140-
REACT_BEGIN_
140+
REACT_BEGIN
141141

142142
////////////////////////////////////////////////////////////////////////////////////////
143143
/// Observe
@@ -151,8 +151,8 @@ template
151151
inline auto Observe(const RSignal<D,TArg>& subject, F&& func)
152152
-> RObserver<D>
153153
{
154-
std::unique_ptr< REACT_IMPL_::ObserverNode<D>> pUnique(
155-
new REACT_IMPL_::SignalObserverNode<D,TArg>(
154+
std::unique_ptr< REACT_IMPL::ObserverNode<D>> pUnique(
155+
new REACT_IMPL::SignalObserverNode<D,TArg>(
156156
subject.GetPtr(), std::forward<F>(func), false));
157157

158158
auto* raw = pUnique.get();
@@ -173,8 +173,8 @@ template
173173
inline auto Observe(const REvents<D,TArg>& subject, F&& func)
174174
-> RObserver<D>
175175
{
176-
std::unique_ptr< REACT_IMPL_::ObserverNode<D>> pUnique(
177-
new REACT_IMPL_::EventObserverNode<D,TArg>(
176+
std::unique_ptr< REACT_IMPL::ObserverNode<D>> pUnique(
177+
new REACT_IMPL::EventObserverNode<D,TArg>(
178178
subject.GetPtr(), std::forward<F>(func), false));
179179

180180
auto* raw = pUnique.get();
@@ -192,8 +192,8 @@ template
192192
inline auto Observe(const REvents<D,EventToken>& subject, F&& func)
193193
-> RObserver<D>
194194
{
195-
std::unique_ptr< REACT_IMPL_::ObserverNode<D>> pUnique(
196-
new REACT_IMPL_::EventObserverNode<D,EventToken>(
195+
std::unique_ptr< REACT_IMPL::ObserverNode<D>> pUnique(
196+
new REACT_IMPL::EventObserverNode<D,EventToken>(
197197
subject.GetPtr(), [func] (EventToken _) { func(); }, false));
198198

199199
auto* raw = pUnique.get();
@@ -222,7 +222,7 @@ inline void DetachAllObservers(const Reactive<TNode<D,TArg>>& subject)
222222
////////////////////////////////////////////////////////////////////////////////////////
223223
inline void DetachThisObserver()
224224
{
225-
REACT_IMPL_::current_observer_state_::shouldDetach = true;
225+
REACT_IMPL::current_observer_state_::shouldDetach = true;
226226
}
227227

228-
REACT_END_
228+
REACT_END

include/react/Operations.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "react/graph/ConversionNodes.h"
1414

1515
////////////////////////////////////////////////////////////////////////////////////////
16-
REACT_BEGIN_
16+
REACT_BEGIN
1717

1818
////////////////////////////////////////////////////////////////////////////////////////
1919
/// Fold
@@ -30,7 +30,7 @@ inline auto Fold(V&& init, const REvents<D,E>& events, F&& func)
3030
-> RSignal<D,S>
3131
{
3232
return RSignal<D,S>(
33-
std::make_shared<REACT_IMPL_::FoldNode<D,S,E>>(
33+
std::make_shared<REACT_IMPL::FoldNode<D,S,E>>(
3434
std::forward<V>(init), events.GetPtr(), std::forward<F>(func), false));
3535
}
3636

@@ -49,7 +49,7 @@ inline auto Iterate(V&& init, const REvents<D,E>& events, F&& func)
4949
-> RSignal<D,S>
5050
{
5151
return RSignal<D,S>(
52-
std::make_shared<REACT_IMPL_::IterateNode<D,S,E>>(
52+
std::make_shared<REACT_IMPL::IterateNode<D,S,E>>(
5353
std::forward<V>(init), events.GetPtr(), std::forward<F>(func), false));
5454
}
5555

@@ -66,7 +66,7 @@ inline auto Hold(V&& init, const REvents<D,T>& events)
6666
-> RSignal<D,T>
6767
{
6868
return RSignal<D,T>(
69-
std::make_shared<REACT_IMPL_::HoldNode<D,T>>(
69+
std::make_shared<REACT_IMPL::HoldNode<D,T>>(
7070
std::forward<V>(init), events.GetPtr(), false));
7171
}
7272

@@ -83,7 +83,7 @@ inline auto Snapshot(const RSignal<D,S>& target, const REvents<D,E>& trigger)
8383
-> RSignal<D,S>
8484
{
8585
return RSignal<D,S>(
86-
std::make_shared<REACT_IMPL_::SnapshotNode<D,S,E>>(
86+
std::make_shared<REACT_IMPL::SnapshotNode<D,S,E>>(
8787
target.GetPtr(), trigger.GetPtr(), false));
8888
}
8989

@@ -112,7 +112,7 @@ inline auto Monitor(const RSignal<D,S>& target)
112112
-> REvents<D,S>
113113
{
114114
return REvents<D,S>(
115-
std::make_shared<REACT_IMPL_::MonitorNode<D, S>>(
115+
std::make_shared<REACT_IMPL::MonitorNode<D, S>>(
116116
target.GetPtr(), false));
117117
}
118118

@@ -161,7 +161,7 @@ inline auto Pulse(const RSignal<D,S>& target, const REvents<D,E>& trigger)
161161
-> REvents<D,S>
162162
{
163163
return REvents<D,S>(
164-
std::make_shared<REACT_IMPL_::PulseNode<D,S,E>>(
164+
std::make_shared<REACT_IMPL::PulseNode<D,S,E>>(
165165
target.GetPtr(), trigger.GetPtr(), false));
166166
}
167167

@@ -181,7 +181,7 @@ inline auto Flatten(const RSignal<D,THandle<D,TInnerValue>>& node)
181181
-> REvents<D,TInnerValue>
182182
{
183183
return REvents<D,TInnerValue>(
184-
std::make_shared<REACT_IMPL_::EventFlattenNode<D, REvents<D,TInnerValue>, TInnerValue>>(
184+
std::make_shared<REACT_IMPL::EventFlattenNode<D, REvents<D,TInnerValue>, TInnerValue>>(
185185
node.GetPtr(), node().GetPtr(), false));
186186
}
187187

@@ -203,4 +203,4 @@ struct Decrementer : public std::unary_function<T,T>
203203
T operator() (T v) { return v-1; }
204204
};
205205

206-
REACT_END_
206+
REACT_END

include/react/ReactiveBase.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <memory>
77

88
////////////////////////////////////////////////////////////////////////////////////////
9-
REACT_BEGIN_
9+
REACT_BEGIN
1010

1111
////////////////////////////////////////////////////////////////////////////////////////
1212
/// Reactive
@@ -46,14 +46,14 @@ class Reactive
4646
std::shared_ptr<T> ptr_;
4747
};
4848

49-
REACT_END_
49+
REACT_END
5050

51-
REACT_IMPL_BEGIN_
51+
REACT_IMPL_BEGIN
5252

5353
template <typename L, typename R>
5454
bool Equals(L lhs, R rhs)
5555
{
5656
return lhs == rhs;
5757
}
5858

59-
REACT_IMPL_END_
59+
REACT_IMPL_END

include/react/ReactiveDomain.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "react/logging/EventRecords.h"
1616

1717
////////////////////////////////////////////////////////////////////////////////////////
18-
REACT_BEGIN_
18+
REACT_BEGIN
1919

2020
template <typename D, typename S>
2121
class RSignal;
@@ -40,9 +40,9 @@ template
4040
inline auto MakeSignal(TFunc func, const RSignal<D,TArgs>& ... args)
4141
-> RSignal<D,decltype(func(args() ...))>;
4242

43-
REACT_END_
43+
REACT_END
4444

45-
REACT_IMPL_BEGIN_
45+
REACT_IMPL_BEGIN
4646

4747
////////////////////////////////////////////////////////////////////////////////////////
4848
/// ContinuationInput
@@ -84,9 +84,9 @@ class ContinuationInput
8484
std::unique_ptr<InputVectT> bufferedInputsPtr_ = nullptr;
8585
};
8686

87-
REACT_IMPL_END_
87+
REACT_IMPL_END
8888

89-
REACT_BEGIN_
89+
REACT_BEGIN
9090

9191
////////////////////////////////////////////////////////////////////////////////////////
9292
/// CommitFlags
@@ -96,9 +96,9 @@ enum ETurnFlags
9696
enable_input_merging = 1 << 0
9797
};
9898

99-
REACT_END_
99+
REACT_END
100100

101-
REACT_IMPL_BEGIN_
101+
REACT_IMPL_BEGIN
102102

103103
////////////////////////////////////////////////////////////////////////////////////////
104104
/// EngineInterface
@@ -572,8 +572,8 @@ class DomainInitializer
572572
}
573573
};
574574

575-
REACT_IMPL_END_
575+
REACT_IMPL_END
576576

577577
#define REACTIVE_DOMAIN(name, ...) \
578-
struct name : public REACT_IMPL_::DomainBase<name, REACT_IMPL_::DomainPolicy<__VA_ARGS__ >> {}; \
579-
REACT_IMPL_::DomainInitializer< name > name ## _initializer_;
578+
struct name : public REACT_IMPL::DomainBase<name, REACT_IMPL::DomainPolicy<__VA_ARGS__ >> {}; \
579+
REACT_IMPL::DomainInitializer< name > name ## _initializer_;

0 commit comments

Comments
 (0)