OpenStructure
info_group.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 
21 
22 /*
23  info high level group interface
24 
25  Author: Ansgar Philippsen
26 */
27 
28 #ifndef OST_INFO_GROUP_H
29 #define OST_INFO_GROUP_H
30 
31 #include <vector>
32 #include <ost/base.hh>
33 #include <ost/geom/geom.hh>
34 #include "info_fw.hh"
35 #include "info_handle.hh"
36 #include "info_impl_fw.hh"
37 
38 namespace ost { namespace info {
39 
40 class DLLEXPORT InfoGroup {
41  friend class InfoHandle; // ctor access
42  friend class InfoItem; // ctor access
43 public:
44 
46  InfoGroup GetParent() const;
47 
49  void SetName(const String& name);
51  String GetName() const;
52 
54  InfoPath GetPath() const;
55 
56  InfoGroup GetGroup(const InfoPath& path, bool use_defaults=true) const;
57 
58  InfoGroupList GetGroups(const InfoPath& path) const;
59 
60  InfoItemList GetItems(const InfoPath& path) const;
61 
62  InfoGroup CreateGroup(const String& name);
63  bool HasGroup(const InfoPath& name, bool use_defaults=true) const;
64  InfoGroup RetrieveGroup(const InfoPath& path, bool use_defaults=true);
65 
66  InfoItem GetItem(const InfoPath& path, bool use_defaults=true) const;
67  InfoItem CreateItem(const String& name, const String& value);
68  InfoItem CreateItem(const String& name, Real value);
69  InfoItem CreateItem(const String& name, bool value);
70  InfoItem CreateItem(const String& name, int value);
71  InfoItem CreateItem(const String& name, const geom::Vec3& vector);
72  bool HasItem(const InfoPath& path, bool use_defaults=true) const;
73  InfoItem RetrieveItem(const InfoPath& path, bool use_defaults=true);
74 
75  void Remove(const InfoPath& path, bool use_defaults=false);
76  void Remove(const InfoGroup& group);
77 
78 
80  String GetAttribute(const String& name) const;
82  void SetAttribute(const String& name, const String& value);
84  bool HasAttribute(const String& name) const;
86  void RemoveAttribute(const String& name);
87 
88  std::vector<String> GetAttributeList() const;
89 
90  String GetTextData() const;
91  void SetTextData(const String& td);
92 
94 
97  void Apply(InfoVisitor& v, bool visit_this=true);
98  void Apply(InfoConstVisitor& v, bool visit_this=true) const;
99 
100  bool operator==(const InfoGroup& ref) const;
101  bool operator!=(const InfoGroup& ref) const;
102 private:
103  void Swap(InfoGroup& group);
104  InfoGroup(const InfoHandle& root, const ElePtr& impl);
105 
106  bool do_group_lookup(std::vector<String>::const_iterator& pos,
107  const std::vector<String>::const_iterator& end,
108  InfoGroupList& subgroups) const;
109  bool do_group_lookup(std::vector<String>::const_iterator& pos,
110  const std::vector<String>::const_iterator& end,
111  InfoGroup& subgroup) const;
112 
113  InfoGroup group_create(InfoGroup group,
114  std::vector<String>::const_iterator& pos,
115  const std::vector<String>::const_iterator& end);
116 
117  InfoHandle root_;
118  ElePtr impl_;
119 };
120 
121 }} // ns
122 
123 #endif