33 #ifndef STATE_NESTED_VECTOR_H 34 #define STATE_NESTED_VECTOR_H 48 template <
typename SubState>
50 template <
typename SubState>
52 template <
typename SubState>
54 template <
typename SubState>
56 template <
typename SubState>
58 template <
typename SubState>
107 double&
value(
const std::size_t& _i)
override 113 const double&
value(
const std::size_t& _i)
const override 130 stateI->updateSize();
134 size_t valueSizeI, valueSizeSum = 0;
135 for (
auto& stateI : states_)
137 valueSizeI = stateI->valueSize();
138 for (
size_t i = 0; i < valueSizeI; ++i)
140 values_[valueSizeSum + i] = &(stateI->value(i));
142 valueSizeSum += valueSizeI;
157 for (
size_t i =
states_.size(); i < _i; ++i)
159 states_.emplace_back(std::shared_ptr<SubState>(
new SubState(
this)));
179 std::vector<std::shared_ptr<SubState> >
states_;
200 const std::shared_ptr<SubState>&
at(
size_t i)
const 206 std::shared_ptr<SubState>&
at(
size_t i)
213 #endif // STATE_NESTED_ARRAY_H
std::unique_ptr< StateNestedVector< SubState > > StateNestedVectorUPtr
StateSPtr & state(const std::size_t &_i) override
Access sub-state based on index _i.
std::shared_ptr< State > StateSPtr
size_t stateSize() const override
Size of the sub-states.
size_t valueSize() const override
Size of the state variables.
SubState & operator[](size_t i)
std::shared_ptr< SubState > & at(size_t i)
void resize(const size_t &_i) override
Resizes the array.
const SubState & operator[](size_t i) const
virtual StateSPtr cloneState() const override
Clone-to-base-class-ptr function.
std::shared_ptr< SubState > & stateScoped(const size_t &_i)
returns pointer to the extended class of the sub-state at index _i.
std::shared_ptr< StateNestedVector< SubState > > StateNestedVectorSPtr
std::vector< StateSPtr > statesBase_
virtual ~StateNestedVector()=default
const std::shared_ptr< SubState > & at(size_t i) const
Generic tree-like recursive structure that allows sub-structure access as well as ordered (array-like...
std::vector< std::shared_ptr< SubState > > states_
StateNestedVector & operator=(const StateNestedVector &)=default
double & value(const std::size_t &_i) override
Access state variable based on index _i.
StateNestedVector(State *_parent)
std::shared_ptr< StateNestedVector< SubState > const > StateNestedVectorConstSPtr
std::vector< double * > values_
void updateSize() override
Performs internal manipulation when any of the underlying arrays are being resized.
void callRootUpdateSize()
Calls (if present) the parent updateSize procedure. Otherwise performs root updateSize.
std::unique_ptr< StateNestedVector< SubState > const > StateNestedVectorConstUPtr
const double & value(const std::size_t &_i) const override
Const access state variable based on index _i.