GroupTreeNode.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 GROUPTREENODE_HPP
21 #define GROUPTREENODE_HPP
22 
23 #include <string>
24 #include <map>
25 #include <memory>
26 
27 namespace Opm {
28 
32  class GroupTreeNode {
33  public:
34  const std::string& name() const;
35  std::shared_ptr<GroupTreeNode> addChildGroup(const std::string& childName);
36  void addChildGroup(std::shared_ptr<GroupTreeNode> childGroup);
37 
38  bool hasChildGroup(const std::string& childName) const;
39  void removeChild(std::shared_ptr<GroupTreeNode> child);
40  std::shared_ptr<GroupTreeNode> getChildGroup(const std::string& childName);
41 
42  static std::shared_ptr<GroupTreeNode> createFieldNode();
43  std::map<std::string, std::shared_ptr<GroupTreeNode> >::const_iterator begin() const;
44  std::map<std::string, std::shared_ptr<GroupTreeNode> >::const_iterator end() const;
45 
46 
47  private:
48  GroupTreeNode(const std::string& name);
49  std::string m_name;
50  std::map<std::string, std::shared_ptr<GroupTreeNode> > m_childGroups;
51  };
52 
53  typedef std::shared_ptr<GroupTreeNode> GroupTreeNodePtr;
54  typedef std::shared_ptr<const GroupTreeNode> GroupTreeNodeConstPtr;
55 }
56 
57 #endif /* GROUPTREENODE_HPP */
58 
bool hasChildGroup(const std::string &childName) const
Definition: Deck.hpp:29
static std::shared_ptr< GroupTreeNode > createFieldNode()
std::shared_ptr< const GroupTreeNode > GroupTreeNodeConstPtr
Definition: GroupTreeNode.hpp:54
std::shared_ptr< GroupTreeNode > addChildGroup(const std::string &childName)
std::map< std::string, std::shared_ptr< GroupTreeNode > >::const_iterator begin() const
std::map< std::string, std::shared_ptr< GroupTreeNode > >::const_iterator end() const
std::shared_ptr< GroupTreeNode > getChildGroup(const std::string &childName)
void removeChild(std::shared_ptr< GroupTreeNode > child)
const std::string & name() const
Definition: GroupTreeNode.hpp:32
std::shared_ptr< GroupTreeNode > GroupTreeNodePtr
Definition: GroupTreeNode.hpp:53