33 #ifndef STATE_NESTED_ARRAY_H 34 #define STATE_NESTED_ARRAY_H 49 template <
typename SubState,
size_t N>
51 template <
typename SubState,
size_t N>
53 template <
typename SubState,
size_t N>
55 template <
typename SubState,
size_t N>
57 template <
typename SubState,
size_t N>
59 template <
typename SubState,
size_t N>
65 for (
size_t i = 0; i < N; ++i)
67 states_[i] = std::shared_ptr<SubState>(
new SubState(
this));
76 for (
size_t i = 0; i < N; ++i)
78 states_[i] = std::shared_ptr<SubState>(
new SubState(
this));
118 double&
value(
const std::size_t& _i)
override 124 const double&
value(
const std::size_t& _i)
const override 147 stateI->updateSize();
151 size_t valueSizeI, valueSizeSum = 0;
152 for (
auto& stateI : states_)
154 valueSizeI = stateI->valueSize();
155 for (
size_t i = 0; i < valueSizeI; ++i)
157 values_[valueSizeSum + i] = &(stateI->value(i));
159 valueSizeSum += valueSizeI;
170 std::array<std::shared_ptr<SubState>, N>
states_;
185 template <
typename EnumStateVals,
typename SubState>
222 std::shared_ptr<StateNestedArrayScoped<EnumStateVals, SubState>>
cloneStateExt()
const 232 template <EnumStateVals _i>
233 typename std::shared_ptr<SubState>&
state()
244 template <
typename... NestedStates1>
246 template <
typename EnumStateVals1,
typename... NestedStates1>
248 template <
typename SubState1>
253 #endif // STATE_NESTED_ARRAY_H
std::array< StateSPtr, N > statesBase_
const double & value(const std::size_t &_i) const override
Const access state variable based on index _i.
std::shared_ptr< State > StateSPtr
double & value(const std::size_t &_i) override
Access state variable based on index _i.
size_t stateSize() const override
Size of the sub-states.
std::vector< double * > values_
constexpr auto asInt(Enumeration const value) -> typename std::underlying_type< Enumeration >::type
std::shared_ptr< SubState > & stateScoped(const size_t &_i)
StateNestedArray(State *_parent)
size_t valueSize() const override
Size of the state variables.
Extension of StateNestedSet providing sub-state access based on a scoped enumeration (compile-time)...
StateNestedArrayScoped(State *_parent)
std::shared_ptr< StateNestedArray< SubState, N >> StateNestedArraySPtr
Implementation of State being formed by tuple of substates.
Generic tree-like recursive structure that allows sub-structure access as well as ordered (array-like...
void updateSize() override
Performs internal manipulation when any of the underlying arrays are being resized.
std::unique_ptr< StateNestedArray< SubState, N >> StateNestedArrayUPtr
std::shared_ptr< SubState > & state()
Scoped access (compile-time) to the sub-states of the state object.
std::array< std::shared_ptr< SubState >, N > states_
virtual StateSPtr cloneState() const override
Clone-to-base-class-ptr function.
std::unique_ptr< StateNestedArray< SubState, N > const > StateNestedArrayConstUPtr
virtual StateSPtr cloneState() const override
Clone-to-base-class-ptr function.
StateSPtr & state(const std::size_t &_i) override
Access sub-state based on index _i.
StateNestedArray & operator=(const StateNestedArray &)=default
void callRootUpdateSize()
Calls (if present) the parent updateSize procedure. Otherwise performs root updateSize.
Extension of StateNestedArray providing sub-state access based on a scoped enumeration (compile-time)...
std::shared_ptr< StateNestedArrayScoped< EnumStateVals, SubState > > cloneStateExt() const
Clone-to-this-class-ptr function.
Implementation of State being formed by an array of substates.
virtual ~StateNestedArray()=default
std::shared_ptr< StateNestedArray< SubState, N > const > StateNestedArrayConstSPtr