OpenStructure
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
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);
110
112
std::vector<String> GetAttributeList()
const
;
113
114
bool
operator==
(
const
InfoItem
& rhs)
const
;
115
bool
operator!=(
const
InfoItem
& rhs)
const
;
116
private
:
117
InfoItem
(
const
InfoHandle
& root,
const
ElePtr
& impl,
Type
t=
IT_STRING
);
118
119
InfoHandle
root_;
120
ElePtr
impl_;
121
Type
type_;
122
};
123
125
template
<
typename
T>
126
T
Extract
(
const
info::InfoGroup
& g,
const
String
& n)
127
{
128
return
boost::lexical_cast<T>(g.
GetItem
(n).
GetValue
());
129
}
130
131
// more convenience functions
132
Real
DLLEXPORT_OST_INFO
GetFloatInfoItem
(
const
InfoGroup& ig,
const
InfoPath& path,
Real
def);
133
int
DLLEXPORT_OST_INFO
GetIntInfoItem
(
const
InfoGroup& ig,
const
InfoPath& path,
int
def);
134
bool
DLLEXPORT_OST_INFO
GetBoolInfoItem
(
const
InfoGroup& ig,
const
InfoPath& path,
bool
def);
135
geom::Vec3
DLLEXPORT_OST_INFO
GetVectorInfoItem
(
const
InfoGroup& ig,
const
InfoPath& path,
const
geom::Vec3
& def);
136
String
DLLEXPORT_OST_INFO
GetStringInfoItem
(
const
InfoGroup& ig,
const
InfoPath& path,
const
String
& def);
137
138
void
DLLEXPORT_OST_INFO
SetFloatInfoItem
(InfoGroup ig,
const
InfoPath& path,
Real
val);
139
void
DLLEXPORT_OST_INFO
SetIntInfoItem
(InfoGroup ig,
const
InfoPath& path,
int
val);
140
void
DLLEXPORT_OST_INFO
SetBoolInfoItem
(InfoGroup ig,
const
InfoPath& path,
bool
val);
141
void
DLLEXPORT_OST_INFO
SetVectorInfoItem
(InfoGroup ig,
const
InfoPath& path,
const
geom::Vec3
& val);
142
void
DLLEXPORT_OST_INFO
SetStringInfoItem
(InfoGroup ig,
const
InfoPath& path,
const
String
& val);
143
144
}}
// ns
145
146
#endif
Generated on Thu Jun 14 2012 18:58:01 for OpenStructure by
1.8.1.1