GroupTree.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2013 Statoil ASA.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef GROUPTREE_HPP
21 #define GROUPTREE_HPP
22 
24 
25 #include <string>
26 #include <map>
27 #include <memory>
28 #include <vector>
29 
30 namespace Opm {
31 
32  class GroupTree {
33  public:
34  GroupTree();
35  void updateTree(const std::string& childName);
36  void updateTree(const std::string& childName, const std::string& parentName);
37 
38  GroupTreeNodePtr getNode(const std::string& nodeName) const;
39  std::vector<GroupTreeNodeConstPtr> getNodes() const;
40  GroupTreeNodePtr getParent(const std::string& childName) const;
41 
42  std::shared_ptr<GroupTree> deepCopy() const;
43  void printTree(std::ostream &os) const;
44 
45 
46  private:
47  GroupTreeNodePtr m_root;
48  GroupTreeNodePtr getNode(const std::string& nodeName, GroupTreeNodePtr current) const;
49  GroupTreeNodePtr getParent(const std::string& childName, GroupTreeNodePtr currentChild, GroupTreeNodePtr parent) const;
50 
51  void getNodes(GroupTreeNodePtr fromNode, std::vector<GroupTreeNodeConstPtr>& nodes) const;
52  void deepCopy(GroupTreeNodePtr origin, GroupTreeNodePtr copy) const;
53  void printTree(std::ostream &os , GroupTreeNodePtr fromNode) const;
54  };
55 
56  typedef std::shared_ptr<GroupTree> GroupTreePtr;
57  typedef std::shared_ptr<const GroupTree> GroupTreeConstPtr;
58 }
59 
60 #endif /* GROUPTREE_HPP */
61 
std::shared_ptr< GroupTree > GroupTreePtr
Definition: GroupTree.hpp:56
Definition: Deck.hpp:29
void updateTree(const std::string &childName)
std::vector< GroupTreeNodeConstPtr > getNodes() const
void printTree(std::ostream &os) const
GroupTreeNodePtr getParent(const std::string &childName) const
std::shared_ptr< GroupTree > deepCopy() const
GroupTreeNodePtr getNode(const std::string &nodeName) const
std::shared_ptr< const GroupTree > GroupTreeConstPtr
Definition: GroupTree.hpp:57
Definition: GroupTree.hpp:32
std::shared_ptr< GroupTreeNode > GroupTreeNodePtr
Definition: GroupTreeNode.hpp:53