Skip to content
Snippets Groups Projects

WIP: Resolve "Complete state vector new data structure?"

Closed Joan Solà Ortega requested to merge 287-complete-state-vector-new-data-structure into devel
1 file
+ 46
0
Compare changes
  • Side-by-side
  • Inline
@@ -18,6 +18,52 @@ namespace wolf
typedef std::unordered_map<std::string, StateBlockPtr> StateBlockMap;
class StateBlockComposite
{
public:
StateBlockComposite() = default;
virtual ~StateBlockComposite() = default;
const StateBlockMap& getStateBlockMap() const;
// These act on all state blocks. Per-block action must be done through state_block.fix() or through extended API in derived classes of this.
virtual void fix();
virtual void unfix();
virtual bool isFixed() const;
virtual StateBlockPtr emplace(const std::string& _sb_type, const StateBlockPtr& _sb);
virtual unsigned int erase(const std::string& _sb_type);
virtual unsigned int erase(const char _sb_type);
unsigned int count(const std::string& _sb_type) const { return state_block_map_.count(_sb_type); }
unsigned int count(const StateBlockPtr& _sb) const;
StateBlockPtr at(const std::string& _sb_type) const;
bool set(const std::string _sb_type, const StateBlockPtr& _sb);
bool key(const StateBlockPtr& _sb, std::string& _key) const;
StateBlockMap::const_iterator find(const StateBlockPtr& _sb) const;
// Emplace derived state blocks (angle, quaternion, etc).
template<typename SB, typename ... Args>
std::shared_ptr<SB> emplace(const std::string& _sb_type, ProblemPtr _problem, Args&&... _args_of_derived_state_block_constructor);
// Emplace base state blocks.
template<typename ... Args>
inline StateBlockPtr emplace(const std::string& _sb_type, ProblemPtr _problem, Args&&... _args_of_base_state_block_constructor);
// Perturb state with noise
void perturb(double amplitude = 0.01);
// Plus operator
void plus(const VectorComposite& _dx);
// Get composite of state vectors (not blocks)
VectorComposite getStateComposite() const;
bool getStateComposite(VectorComposite& _state) const;
void setStateComposite(const VectorComposite& _state);
private:
StateBlockMap state_block_map_;
};
class HasStateBlocks
{
Loading