Skip to content
Snippets Groups Projects
Commit 44c1b250 authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

WIP New class StateBlockComposite

parent 3b092975
No related branches found
No related tags found
2 merge requests!358WIP: Resolve "Complete state vector new data structure?",!343WIP: Resolve "Complete state vector new data structure?"
Pipeline #5126 passed
...@@ -18,6 +18,52 @@ namespace wolf ...@@ -18,6 +18,52 @@ namespace wolf
typedef std::unordered_map<std::string, StateBlockPtr> StateBlockMap; 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 class HasStateBlocks
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment