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-2020 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 
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 
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 
91  void SetTextData(const String& td);
92 
94  String GetComment() const;
95 
96 
98 
101  void Apply(InfoVisitor& v, bool visit_this=true);
102  void Apply(InfoConstVisitor& v, bool visit_this=true) const;
103 
104  bool operator==(const InfoGroup& ref) const;
105  bool operator!=(const InfoGroup& ref) const;
106 private:
107  void Swap(InfoGroup& group);
108  InfoGroup(const InfoHandle& root, const ElePtr& impl);
109 
110  bool do_group_lookup(std::vector<String>::const_iterator& pos,
111  const std::vector<String>::const_iterator& end,
112  InfoGroupList& subgroups) const;
113  bool do_group_lookup(std::vector<String>::const_iterator& pos,
114  const std::vector<String>::const_iterator& end,
115  InfoGroup& subgroup) const;
116 
117  InfoGroup group_create(InfoGroup group,
118  std::vector<String>::const_iterator& pos,
119  const std::vector<String>::const_iterator& end);
120 
121  InfoHandle root_;
122  ElePtr impl_;
123 };
124 
125 }} // ns
126 
127 #endif
Three dimensional vector class, using Real precision.
Definition: vec3.hh:48
void Remove(const InfoGroup &group)
String GetTextData() const
bool HasAttribute(const String &name) const
returns true if attribute of this names exists
std::vector< String > GetAttributeList() const
String GetName() const
retrieve name
bool HasGroup(const InfoPath &name, bool use_defaults=true) const
InfoGroup GetGroup(const InfoPath &path, bool use_defaults=true) const
InfoItem CreateItem(const String &name, bool value)
bool HasItem(const InfoPath &path, bool use_defaults=true) const
InfoGroup RetrieveGroup(const InfoPath &path, bool use_defaults=true)
String GetComment() const
get comment just above item
void SetTextData(const String &td)
void RemoveAttribute(const String &name)
remove attribute of given name
bool operator!=(const InfoGroup &ref) const
InfoGroup GetParent() const
retrieve parent group
InfoItem CreateItem(const String &name, Real value)
void Remove(const InfoPath &path, bool use_defaults=false)
bool operator==(const InfoGroup &ref) const
void Apply(InfoVisitor &v, bool visit_this=true)
Apply visitor.
InfoGroupList GetGroups(const InfoPath &path) const
String GetAttribute(const String &name) const
return attribute of given name
InfoPath GetPath() const
retrieve path
void Apply(InfoConstVisitor &v, bool visit_this=true) const
InfoItem GetItem(const InfoPath &path, bool use_defaults=true) const
InfoGroup CreateGroup(const String &name)
void SetName(const String &name)
set name
void SetAttribute(const String &name, const String &value)
set attribute of given name, will be created if it does not yet exist
InfoItemList GetItems(const InfoPath &path) const
InfoItem CreateItem(const String &name, const String &value)
InfoItem CreateItem(const String &name, const geom::Vec3 &vector)
InfoItem CreateItem(const String &name, int value)
InfoItem RetrieveItem(const InfoPath &path, bool use_defaults=true)
main info handle
Definition: info_handle.hh:54
encapsulates path to info groups and items
Definition: info_path.hh:44
float Real
Definition: base.hh:44
std::string String
Definition: base.hh:54
std::vector< InfoGroup > InfoGroupList
Definition: info_fw.hh:47
boost::shared_ptr< detail::EleImpl > ElePtr
Definition: info_impl_fw.hh:42
std::vector< InfoItem > InfoItemList
Definition: info_fw.hh:44
pointer_it< T > end(const std::vector< T > &values)
Definition: base.dox:1