From 126f9363f6c785eb4bf396497096e7f308f04a02 Mon Sep 17 00:00:00 2001 From: Dmitry Ganyushin Date: Tue, 21 Mar 2023 12:39:29 -0400 Subject: [PATCH] Refactoring and clean-up --- bindings/CXX11/adios2/cxx11/Group.cpp | 19 ++--------- bindings/CXX11/adios2/cxx11/Group.h | 17 ---------- source/adios2/core/Group.cpp | 46 ++++----------------------- source/adios2/core/Group.h | 13 +++----- 4 files changed, 13 insertions(+), 82 deletions(-) diff --git a/bindings/CXX11/adios2/cxx11/Group.cpp b/bindings/CXX11/adios2/cxx11/Group.cpp index 160ff4933e..a7220b4c2c 100644 --- a/bindings/CXX11/adios2/cxx11/Group.cpp +++ b/bindings/CXX11/adios2/cxx11/Group.cpp @@ -21,17 +21,6 @@ Group Group::InquireGroup(std::string group_name) auto m = m_Group->InquireGroup(group_name); return Group(m); } -void Group::PrintTree() -{ - m_Group->PrintTree(); - return; -} - -void Group::BuildTree() -{ - m_Group->BuildTree(); - return; -} std::vector Group::AvailableVariables() { return m_Group->AvailableVariables(); @@ -45,11 +34,6 @@ std::vector Group::AvailableGroups() return m_Group->AvailableGroups(); } -std::map> &Group::getTreeMap() -{ - return m_Group->getTreeMap(); -} - std::string Group::InquirePath() { return m_Group->InquirePath(); } void Group::setPath(std::string path) { m_Group->setPath(path); } @@ -64,7 +48,8 @@ DataType Group::AttributeType(const std::string &name) const helper::CheckForNullptr(m_Group, "in call to IO::AttributeType"); return m_Group->InquireAttributeType(name); } -Group::~Group(){}; +Group::~Group() = default; +; // Explicit declaration of the public template methods // Limits the types #define declare_template_instantiation(T) \ diff --git a/bindings/CXX11/adios2/cxx11/Group.h b/bindings/CXX11/adios2/cxx11/Group.h index d1892f1cd5..d54a39b75b 100644 --- a/bindings/CXX11/adios2/cxx11/Group.h +++ b/bindings/CXX11/adios2/cxx11/Group.h @@ -39,23 +39,11 @@ class Group { friend class IO; -private: Group(core::Group *group); core::Group *m_Group = nullptr; public: ~Group(); - /** - * @brief Builds map that represents tree structure from m_Variable and - * m_Attributes from IO class - * @param - */ - void BuildTree(); - /** - * @brief Prints map that represents tree structure - * @param - */ - void PrintTree(); /** * @brief returns available groups on the path set * @param @@ -91,11 +79,6 @@ class Group * @return new group object */ Group InquireGroup(std::string group_name); - /** - * @brief returns a reference to the map representing the tree stucture - * @param delimiter symbol - */ - std::map> &getTreeMap(); /** * @brief Gets an existing variable of primitive type by name. A wrapper for * the corresponding function of the IO class diff --git a/source/adios2/core/Group.cpp b/source/adios2/core/Group.cpp index a257b1d530..a07c718c2f 100644 --- a/source/adios2/core/Group.cpp +++ b/source/adios2/core/Group.cpp @@ -9,7 +9,6 @@ */ #include "Group.h" #include "Group.tcc" -#include #include #include #include @@ -59,16 +58,6 @@ Group *Group::InquireGroup(std::string groupName) m_Gr->mapPtr = this->mapPtr; return m_Gr.get(); } -void Group::PrintTree() -{ - for (auto k : mapPtr->treeMap) - { - std::cout << k.first << "=>"; - for (auto v : k.second) - std::cout << v << " "; - std::cout << std::endl; - } -} void Group::BuildTree() { @@ -83,16 +72,7 @@ void Group::BuildTree() else tokens.insert(tokens.begin(), ADIOS_root); currentPath = ADIOS_root; - - if (tokens.size() == 0) - { - // record = "group". Handled by default case - } - else if (tokens.size() == 1) - { - // case record = "/group1" or "group/" - } - else + if (tokens.size() > 1) { std::string key = tokens[0]; for (size_t level = 1; level < tokens.size(); level++) @@ -112,15 +92,6 @@ void Group::BuildTree() { std::vector tokens = split(attributePair.first, groupDelimiter); - - if (tokens.size() == 0) - { - // record = "group". Handled by default case - } - else if (tokens.size() == 1) - { - // case record = "/group1" or "group/" - } if (tokens.size() > 1) { std::string key = tokens[0]; @@ -141,9 +112,8 @@ std::vector Group::AvailableVariables() { // look into map std::set val = mapPtr->treeMap[currentPath]; - // TODODG check that currentPath exists std::vector available_variables; - for (auto v : val) + for (auto const &v : val) { if (mapPtr->treeMap.find(currentPath + groupDelimiter + v) == mapPtr->treeMap.end()) @@ -168,7 +138,7 @@ std::vector Group::AvailableAttributes() std::set val = mapPtr->treeMap[currentPath]; // TODODG check that currentPath exists std::vector available_attributes; - for (auto v : val) + for (auto const &v : val) { if (mapPtr->treeMap.find(currentPath + groupDelimiter + v) == mapPtr->treeMap.end()) @@ -192,13 +162,11 @@ std::vector Group::AvailableGroups() std::vector available_groups; std::set val = mapPtr->treeMap[currentPath]; + for (auto const &v : val) { - for (auto v : val) - { - if (mapPtr->treeMap.find(currentPath + groupDelimiter + v) != - mapPtr->treeMap.end()) - available_groups.push_back(v); - } + if (mapPtr->treeMap.find(currentPath + groupDelimiter + v) != + mapPtr->treeMap.end()) + available_groups.push_back(v); } return available_groups; } diff --git a/source/adios2/core/Group.h b/source/adios2/core/Group.h index 072bcded90..5bcb41191a 100644 --- a/source/adios2/core/Group.h +++ b/source/adios2/core/Group.h @@ -37,6 +37,10 @@ class Group std::shared_ptr mapPtr = nullptr; /** root of the tree */ const std::string ADIOS_root = "_ADIOS_ROOT_"; + /** a pointer to a Group Object */ + std::shared_ptr m_Gr; + /** reference to object that created current Group */ + IO &m_IO; public: /** @@ -52,19 +56,12 @@ class Group Group(const Group &G); /** destructor */ ~Group(); - /** a pointer to a Group Object */ - std::shared_ptr m_Gr; /** * @brief Builds map that represents tree structure from m_Variable and * m_Attributes from IO class * @param */ void BuildTree(); - /** - * @brief Prints map that represents tree structure - * @param - */ - void PrintTree(); /** * @brief returns available groups on the path set * @param @@ -110,8 +107,6 @@ class Group * @param delimiter symbol */ std::map> &getTreeMap(); - /** reference to object that created current Group */ - IO &m_IO; /** * @brief Gets an existing variable of primitive type by name. A wrapper for * the corresponding function of the IO class