OpenStructure
Loading...
Searching...
No Matches
info_impl.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 low level info implementation
23
24 Author: Ansgar Philippsen
25*/
26
27#ifndef OST_DATA_INFO_IMPL_H
28#define OST_DATA_INFO_IMPL_H
29
30#include <ost/message.hh>
31#include <utility>
32#include <vector>
33#include <iostream>
34
35#include <QtXml/QDomElement>
36#include <QtXml/QDomDocument>
37#include <QtXml/QDomAttr>
38#include <QtXml/QDomText>
39
40#include <ost/base.hh>
41#include <ost/geom/geom.hh>
42
43#include <ost/ptr_observer.hh>
44
45#include "info_impl_fw.hh"
46#include "item_type.hh"
47
48namespace ost { namespace info { namespace detail {
49
50typedef std::vector<ElePtr> EleList;
51/*
52 wraps a DomElement, to be used by the high level item and group class
53*/
54class EleImpl {
55public:
56 EleImpl(const QDomElement& e);
57
58 // tag name access
59 String GetName() const;
60 void SetName(const String& n);
61
62 // get full path
63 String GetPath() const;
64
65
66 // attribute access
67 void SetAttribute(const String& name, const String& value);
68 String GetAttribute(const String& name) const;
69 bool HasAttribute(const String& name) const;
70 void RemoveAttribute(const String& name);
71
72 std::vector<String> GetAttributeList() const;
73
75 void SetTextData(const String& td);
76
78
82 EleList GetSubs(const String& name) const;
83
86 ElePtr GetSub(const String& name) const;
87 ElePtr CreateSub(const String& name);
88 bool HasSub(const String& name) const;
89
90 void RemoveSub(const String& name);
91
92 void RemoveSub(const ElePtr& ele);
93
94 QDomElement& GetElement();
95 const QDomElement& GetElement() const;
96
98 InfoImpl& GetRoot() const;
99
100 std::vector<ElePtr> GetSubList() const;
101
103
104 bool operator==(const EleImpl& ref) const;
105
106 Type GetType() const;
107 void SetType(Type t);
108
109 void SetNewType(int t);
110
111 void SetStringRepr(const String& v, bool settype);
113 void SetIntRepr(int repr);
114 int GetIntRepr() const;
115 void SetFloatRepr(float repr);
116 float GetFloatRepr() const;
117 void SetBoolRepr(bool repr);
118 bool GetBoolRepr() const;
119 void SetVecRepr(const geom::Vec3& repr);
121
122private:
123 QDomElement ele_;
124
125 Type type_;
126
127 String String_repr_;
128 int int_repr_;
129 float float_repr_;
130 bool bool_repr_;
131 geom::Vec3 vec_repr_;
132};
133
134
135class InfoImpl {
136public:
138 InfoImpl(const String& file);
139 InfoImpl(bool dummy,const String& text);
140
141 RootPtr Copy() const;
142
143 void Import(const String& file);
144 void Export(const String& file);
145
147
148 RootPtrList& DefList() {return def_list_;}
149 const RootPtrList& DefList() const {return def_list_;}
150
151 QDomDocument& GetDocument() {return document_;}
152 const QDomDocument& GetDocument() const {return document_;}
153
154private:
155 QDomDocument document_;
156
157 RootPtrList def_list_;
158};
159
160}}} // ns
161
162#endif
Three dimensional vector class, using Real precision.
Definition vec3.hh:48
String GetTextData() const
ElePtr GetSub(const String &name) const
get single sub elements with specified name throws if no element is found
bool HasAttribute(const String &name) const
std::vector< String > GetAttributeList() const
geom::Vec3 GetVecRepr() const
void SetName(const String &n)
QDomElement & GetElement()
void SetVecRepr(const geom::Vec3 &repr)
void SetFloatRepr(float repr)
EleList GetSubs(const String &name) const
get sub elements with specified element name
void SetTextData(const String &td)
ElePtr CreateSub(const String &name)
bool HasSub(const String &name) const
void SetBoolRepr(bool repr)
void RemoveAttribute(const String &name)
void SetStringRepr(const String &v, bool settype)
void RemoveSub(const ElePtr &ele)
EleImpl(const QDomElement &e)
bool operator==(const EleImpl &ref) const
void RemoveSub(const String &name)
const QDomElement & GetElement() const
String GetAttribute(const String &name) const
String GetStringRepr() const
std::vector< ElePtr > GetSubList() const
void SetAttribute(const String &name, const String &value)
InfoImpl & GetRoot() const
void Import(const String &file)
InfoImpl(bool dummy, const String &text)
const QDomDocument & GetDocument() const
Definition info_impl.hh:152
const RootPtrList & DefList() const
Definition info_impl.hh:149
QDomDocument & GetDocument()
Definition info_impl.hh:151
InfoImpl(const String &file)
void Export(const String &file)
std::string String
Definition base.hh:54
std::vector< ElePtr > EleList
Definition info_impl.hh:50
std::vector< RootPtr > RootPtrList
boost::shared_ptr< detail::EleImpl > ElePtr
boost::shared_ptr< detail::InfoImpl > RootPtr
Definition base.dox:1