2#ifndef ANCHORS_ANCHORS_H
3#define ANCHORS_ANCHORS_H
48 template <
typename T,
typename InputType1 = T>
67 template <
typename T,
typename InputType1 = T,
typename InputType2 = T>
91 typename InputType1 = T,
92 typename InputType2 = T,
93 typename InputType3 = T>
98 const std::function<T(InputType1 &, InputType2 &, InputType3 &)>
120 template <
typename T,
121 typename InputType1 = T,
122 typename InputType2 = T,
123 typename InputType3 = T,
124 typename InputType4 = T>
131 T(InputType1 &, InputType2 &, InputType3 &, InputType4 &)>
142template <
typename T,
typename InputType1>
152template <
typename T,
typename InputType1,
typename InputType2>
159 anchor1, anchor2, updater));
172 const std::function<T(InputType1 &, InputType2 &, InputType3 &)> &updater) {
173 using PairType = std::pair<InputType1, InputType2>;
175 const auto &anchorOfPair(map2<PairType, InputType1, InputType2>(
176 anchor1, anchor2, [](InputType1 t1, InputType2 t2) {
177 return std::make_pair(t1, t2);
180 const auto &newUpdater = [updater](PairType &pair, InputType3 &anchor3) {
181 return updater(pair.first, pair.second, anchor3);
184 return map2<T, PairType, InputType3>(anchorOfPair, anchor3, newUpdater);
198 T(InputType1 &, InputType2 &, InputType3 &, InputType4 &)> &updater) {
199 using PairType1 = std::pair<InputType1, InputType2>;
200 using PairType2 = std::pair<InputType3, InputType4>;
202 const auto &anchorOfPair1(map2<PairType1, InputType1, InputType2>(
203 anchor1, anchor2, [](InputType1 t1, InputType2 t2) {
204 return std::make_pair(t1, t2);
207 const auto &anchorOfPair2(map2<PairType2, InputType3, InputType4>(
208 anchor3, anchor4, [](InputType1 t1, InputType2 t2) {
209 return std::make_pair(t1, t2);
212 const auto &newUpdater = [updater](PairType1 &firstPair,
213 PairType2 &secondPair) {
214 return updater(firstPair.first,
220 return map2<T, PairType1, PairType2>(
221 anchorOfPair1, anchorOfPair2, newUpdater);
A single node in the computation graph containing a value.
Definition: anchor.h:59
std::function< T(InputType1 &, InputType2 &)> DualInputUpdater
Alias for function that accepts inputs of type InputType1 and InputType2 and returns a value of type ...
Definition: anchor.h:71
std::function< T(InputType1 &)> SingleInputUpdater
Alias for function that accepts an input of type InputType1 and returns a value of type T.
Definition: anchor.h:65
Anchors is an utility class containing functions to simplify creating a shared pointer to an Anchor,...
Definition: anchorutil.h:24
static AnchorPtr< T > map3(const AnchorPtr< InputType1 > &anchor1, const AnchorPtr< InputType2 > &anchor2, const AnchorPtr< InputType3 > &anchor3, const std::function< T(InputType1 &, InputType2 &, InputType3 &)> &updater)
Creates an Anchor from three input Anchors.
Definition: anchorutil.h:168
static AnchorPtr< T > map(const AnchorPtr< InputType1 > &anchor, const typename Anchor< T, InputType1 >::SingleInputUpdater &updater)
Creates an Anchor from an input Anchor.
Definition: anchorutil.h:143
static AnchorPtr< T > map2(const AnchorPtr< InputType1 > &anchor1, const AnchorPtr< InputType2 > &anchor2, const typename Anchor< T, InputType1, InputType2 >::DualInputUpdater &updater)
Creates an Anchor from two input Anchors.
Definition: anchorutil.h:153
static AnchorPtr< T > create(const T &value)
Creates an Anchor containing the given value.
Definition: anchorutil.h:136
static AnchorPtr< T > map4(const AnchorPtr< InputType1 > &anchor1, const AnchorPtr< InputType2 > &anchor2, const AnchorPtr< InputType3 > &anchor3, const AnchorPtr< InputType4 > &anchor4, const std::function< T(InputType1 &, InputType2 &, InputType3 &, InputType4 &)> &updater)
Creates an Anchor from four input Anchors.
Definition: anchorutil.h:192
Main library namespace.
Definition: anchor.h:32
std::shared_ptr< AnchorWrap< T > > AnchorPtr
Alias representing a shared pointer to an Anchor of output type T.
Definition: anchorutil.h:15