OpenStructure
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
stage
include
ost
info
info_item.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
high level info item interface
24
25
Author: Ansgar Philippsen
26
*/
27
28
#ifndef OST_DATA_INFO_ITEM_H
29
#define OST_DATA_INFO_ITEM_H
30
31
#include <boost/lexical_cast.hpp>
32
33
#include <
ost/geom/geom.hh
>
34
#include <
ost/base.hh
>
35
36
#include "
info_fw.hh
"
37
#include "
info_handle.hh
"
38
#include "
info_group.hh
"
39
#include "
info_impl_fw.hh
"
40
#include "
item_type.hh
"
41
42
namespace
ost {
namespace
info {
43
44
class
DLLEXPORT_OST_INFO
InfoItem
{
45
friend
class
InfoGroup
;
46
public
:
47
48
50
InfoGroup
GetParent()
const
;
51
53
String
GetName()
const
;
55
void
SetName(
const
String
& n);
56
58
61
String
GetValue
()
const
;
62
64
67
void
SetValue(
const
String
& val);
68
70
74
Type
GetType()
const
;
75
77
/*
78
will do internal conversion
79
*/
80
void
SetType(
Type
t);
81
82
void
SetType(
int
t);
83
85
Real
AsFloat()
const
;
87
int
AsInt()
const
;
89
bool
AsBool()
const
;
91
geom::Vec3
AsVector()
const
;
92
94
void
SetFloat(
Real
d);
96
void
SetInt(
int
i);
98
void
SetBool(
bool
b);
100
void
SetVector(
const
geom::Vec3
& v);
101
103
String
GetAttribute(
const
String
& name)
const
;
105
void
SetAttribute(
const
String
& name,
const
String
& value);
107
bool
HasAttribute(
const
String
& name)
const
;
109
void
RemoveAttribute(
const
String
& name);
111
String
GetComment()
const
;
112
114
std::vector<String> GetAttributeList()
const
;
115
116
bool
operator==
(
const
InfoItem
& rhs)
const
;
117
bool
operator!=
(
const
InfoItem
& rhs)
const
;
118
private
:
119
InfoItem
(
const
InfoHandle
& root,
const
ElePtr
& impl,
Type
t=
IT_STRING
);
120
121
InfoHandle
root_;
122
ElePtr
impl_;
123
Type
type_;
124
};
125
127
template
<
typename
T>
128
T
Extract
(
const
info::InfoGroup
& g,
const
String
& n)
129
{
130
return
boost::lexical_cast<T>(g.
GetItem
(n).
GetValue
());
131
}
132
133
// more convenience functions
134
Real
DLLEXPORT_OST_INFO
GetFloatInfoItem
(
const
InfoGroup& ig,
const
InfoPath& path,
Real
def);
135
int
DLLEXPORT_OST_INFO
GetIntInfoItem
(
const
InfoGroup& ig,
const
InfoPath& path,
int
def);
136
bool
DLLEXPORT_OST_INFO
GetBoolInfoItem
(
const
InfoGroup& ig,
const
InfoPath& path,
bool
def);
137
geom::Vec3
DLLEXPORT_OST_INFO
GetVectorInfoItem
(
const
InfoGroup& ig,
const
InfoPath& path,
const
geom::Vec3
& def);
138
String
DLLEXPORT_OST_INFO
GetStringInfoItem
(
const
InfoGroup& ig,
const
InfoPath& path,
const
String
& def);
139
140
void
DLLEXPORT_OST_INFO
SetFloatInfoItem
(InfoGroup ig,
const
InfoPath& path,
Real
val);
141
void
DLLEXPORT_OST_INFO
SetIntInfoItem
(InfoGroup ig,
const
InfoPath& path,
int
val);
142
void
DLLEXPORT_OST_INFO
SetBoolInfoItem
(InfoGroup ig,
const
InfoPath& path,
bool
val);
143
void
DLLEXPORT_OST_INFO
SetVectorInfoItem
(InfoGroup ig,
const
InfoPath& path,
const
geom::Vec3
& val);
144
void
DLLEXPORT_OST_INFO
SetStringInfoItem
(InfoGroup ig,
const
InfoPath& path,
const
String
& val);
145
146
}}
// ns
147
148
#endif
Generated on Mon Nov 11 2013 09:56:12 for OpenStructure by
1.8.1.1