From a13278ce491b9ecd865a6355c34cbd9c0b804a45 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joan=20Sol=C3=A0?= <jsola@iri.upc.edu>
Date: Wed, 25 Mar 2020 19:24:29 +0100
Subject: [PATCH] New state structure and getter

---
 include/core/state_block/has_state_blocks.h | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/core/state_block/has_state_blocks.h b/include/core/state_block/has_state_blocks.h
index 42b8b03a4..76df765d2 100644
--- a/include/core/state_block/has_state_blocks.h
+++ b/include/core/state_block/has_state_blocks.h
@@ -15,6 +15,10 @@
 namespace wolf
 {
 
+/// State of nodes containing several state blocks
+typedef std::unordered_map<std::string, Eigen::VectorXd> State;
+
+
 class HasStateBlocks
 {
     public:
@@ -70,6 +74,8 @@ class HasStateBlocks
         unsigned int getSize(std::string _sub_structure="") const;
         unsigned int getLocalSize(std::string _sub_structure="") const;
 
+        State getStateComposite();
+
     private:
         std::string structure_;
         std::map<std::string, StateBlockPtr> state_block_map_;
@@ -266,6 +272,15 @@ inline Eigen::VectorXd HasStateBlocks::getState(std::string _sub_structure) cons
     return state;
 }
 
+inline State HasStateBlocks::getStateComposite()
+{
+    State state;
+    for (auto& pair_key_kf : state_block_map_)
+    {
+        state.emplace(pair_key_kf.first, pair_key_kf.second->getState());
+    }
+    return state;
+}
 
 inline unsigned int HasStateBlocks::getSize(std::string _sub_structure) const
 {
@@ -303,6 +318,5 @@ inline unsigned int HasStateBlocks::getLocalSize(std::string _sub_structure) con
     return size;
 }
 
-
 } // namespace wolf
 #endif /* STATE_BLOCK_HAS_STATE_BLOCKS_H_ */
-- 
GitLab