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

new typedef StateBlockMap

parent 38b69508
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?"
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
namespace wolf namespace wolf
{ {
typedef std::unordered_map<std::string, StateBlockPtr> StateBlockMap;
class HasStateBlocks class HasStateBlocks
{ {
...@@ -28,7 +30,7 @@ class HasStateBlocks ...@@ -28,7 +30,7 @@ class HasStateBlocks
void appendToStructure(const std::string& _frame_type){ structure_ += _frame_type; } void appendToStructure(const std::string& _frame_type){ structure_ += _frame_type; }
bool isInStructure(const std::string& _sb_type) { return structure_.find(_sb_type) != std::string::npos; } bool isInStructure(const std::string& _sb_type) { return structure_.find(_sb_type) != std::string::npos; }
const std::unordered_map<std::string, StateBlockPtr>& getStateBlockMap() const; const StateBlockMap& getStateBlockMap() const;
std::vector<StateBlockPtr> getStateBlockVec() const; std::vector<StateBlockPtr> getStateBlockVec() const;
// Some typical shortcuts -- not all should be coded here, see notes below. // Some typical shortcuts -- not all should be coded here, see notes below.
...@@ -52,7 +54,7 @@ class HasStateBlocks ...@@ -52,7 +54,7 @@ class HasStateBlocks
bool setStateBlock(const std::string _sb_type, const StateBlockPtr& _sb); bool setStateBlock(const std::string _sb_type, const StateBlockPtr& _sb);
bool setStateBlock(const char _sb_type, const StateBlockPtr& _sb) { return setStateBlock(std::string(1, _sb_type), _sb); } bool setStateBlock(const char _sb_type, const StateBlockPtr& _sb) { return setStateBlock(std::string(1, _sb_type), _sb); }
bool stateBlockKey(const StateBlockPtr& _sb, std::string& _key) const; bool stateBlockKey(const StateBlockPtr& _sb, std::string& _key) const;
std::unordered_map<std::string, StateBlockPtr>::const_iterator find(const StateBlockPtr& _sb) const; StateBlockMap::const_iterator find(const StateBlockPtr& _sb) const;
// Emplace derived state blocks (angle, quaternion, etc). // Emplace derived state blocks (angle, quaternion, etc).
template<typename SB, typename ... Args> template<typename SB, typename ... Args>
...@@ -85,8 +87,8 @@ class HasStateBlocks ...@@ -85,8 +87,8 @@ class HasStateBlocks
private: private:
StateStructure structure_; // TBR StateStructure structure_; // TBR
std::unordered_map<std::string, StateBlockPtr> state_block_map_; StateBlockMap state_block_map_;
}; };
...@@ -111,7 +113,7 @@ inline HasStateBlocks::~HasStateBlocks() ...@@ -111,7 +113,7 @@ inline HasStateBlocks::~HasStateBlocks()
// //
} }
inline const std::unordered_map<std::string, StateBlockPtr>& HasStateBlocks::getStateBlockMap() const inline const StateBlockMap& HasStateBlocks::getStateBlockMap() const
{ {
return state_block_map_; return state_block_map_;
} }
...@@ -266,7 +268,7 @@ inline Eigen::VectorXd HasStateBlocks::getState(const StateStructure& _sub_struc ...@@ -266,7 +268,7 @@ inline Eigen::VectorXd HasStateBlocks::getState(const StateStructure& _sub_struc
return state; return state;
} }
inline std::unordered_map<std::string, StateBlockPtr>::const_iterator HasStateBlocks::find(const StateBlockPtr& _sb) const inline StateBlockMap::const_iterator HasStateBlocks::find(const StateBlockPtr& _sb) const
{ {
const auto& it = std::find_if(state_block_map_.begin(), const auto& it = std::find_if(state_block_map_.begin(),
state_block_map_.end(), state_block_map_.end(),
......
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