OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
generic_property_def.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 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 
20 #ifndef GENERIC_PROPERTY_DEF_HH
21 #define GENERIC_PROPERTY_DEF_HH
22 
23 #include <ost/log.hh>
24 /*
25  Author: Marco Biasini
26  */
27 
28 template <typename C>
29 String depr_get_string_a(C& c, const String& k, const String& v)
30 {
31  WARN_DEPRECATED("GetGenericStringProperty is deprecated. Use GetStringProp");
32  return c.GetStringProp(k, v);
33 }
34 
35 template <typename C>
37 {
38  WARN_DEPRECATED("GetGenericStringProperty is deprecated. Use GetStringProp");
39  return c.GetStringProp(k);
40 }
41 
42 template <typename C>
43 void depr_set_string(C& c, const String& k, const String& v)
44 {
45  WARN_DEPRECATED("SetGenericStringProperty is deprecated. Use SetStringProp");
46  return c.SetStringProp(k, v);
47 }
48 
49 template <typename C>
50 int depr_get_int_a(C& c, const String& k, const int& v)
51 {
52  WARN_DEPRECATED("GetGenericIntProperty is deprecated. Use GetIntProp");
53  return c.GetIntProp(k, v);
54 }
55 
56 template <typename C>
57 int depr_get_int_b(C& c, const String& k)
58 {
59  WARN_DEPRECATED("GetGenericIntProperty is deprecated. Use GetIntProp");
60  return c.GetIntProp(k);
61 }
62 
63 template <typename C>
64 void depr_set_int(C& c, const String& k, const int& v)
65 {
66  WARN_DEPRECATED("SetGenericIntProperty is deprecated. Use SetIntProp");
67  return c.SetIntProp(k, v);
68 }
69 
70 template <typename C>
71 bool depr_get_bool_a(C& c, const String& k, const bool& v)
72 {
73  WARN_DEPRECATED("GetGenericBoolProperty is deprecated. Use GetBoolProp");
74  return c.GetBoolProp(k, v);
75 }
76 
77 template <typename C>
78 bool depr_get_bool_b(C& c, const String& k)
79 {
80  WARN_DEPRECATED("GetGenericBoolProperty is deprecated. Use GetBoolProp");
81  return c.GetBoolProp(k);
82 }
83 
84 template <typename C>
85 void depr_set_bool(C& c, const String& k, const bool& v)
86 {
87  WARN_DEPRECATED("SetGenericBoolProperty is deprecated. Use SetBoolProp");
88  return c.SetBoolProp(k, v);
89 }
90 
91 template <typename C>
92 Real depr_get_float_a(C& c, const String& k, const float& v)
93 {
94  WARN_DEPRECATED("GetGenericFloatProperty is deprecated. Use GetFloatProp");
95  return c.GetFloatProp(k, v);
96 }
97 
98 template <typename C>
99 Real depr_get_float_b(C& c, const String& k)
100 {
101  WARN_DEPRECATED("GetGenericFloatProperty is deprecated. Use GetFloatProp");
102  return c.GetFloatProp(k);
103 }
104 
105 template <typename C>
106 void depr_set_float(C& c, const String& k, const Real& v)
107 {
108  WARN_DEPRECATED("SetGenericFloatProperty is deprecated. Use SetFloatProp");
109  return c.SetFloatProp(k, v);
110 }
111 
112 template <typename C>
114 {
115  WARN_DEPRECATED("ClearGenericProperties is deprecated. Use ClearProps");
116  c.ClearProps();
117 }
118 
119 template <typename C>
120 bool depr_has_prop(C& c, const String& k)
121 {
122  WARN_DEPRECATED("HasGenericProperty is deprecated. Use HasProp");
123  return c.HasProp(k);
124 }
125 
126 template <typename C>
128 {
129  WARN_DEPRECATED("GetGenericPropertyStringRepresentation is deprecated. Use GetPropAsString");
130  return c.GetPropAsString(k);
131 }
132 
133 template <typename C, typename O>
134 void const_generic_prop_def(O& bp_class)
135 {
136  bool (C::*get_bool1)(const String&, bool) const=&C::GetBoolProp;
137  bool (C::*get_bool2)(const String&) const=&C::GetBoolProp;
138 
139  int (C::*get_int1)(const String&, int) const=&C::GetIntProp;
140  int (C::*get_int2)(const String&) const=&C::GetIntProp;
141 
142  Real (C::*get_float1)(const String&, Real) const=&C::GetFloatProp;
143  Real (C::*get_float2)(const String&) const=&C::GetFloatProp;
144 
145  geom::Vec3 (C::*get_vec3)(const String&) const=&C::GetVec3Prop;
146 
147  String (C::*get_str1)(const String&, const String&) const=&C::GetStringProp;
148  String (C::*get_str2)(const String&) const=&C::GetStringProp;
149  bp_class
150  .def("HasProp", &C::HasProp)
151  .def("GetPropAsString",
152  &C::GetPropAsString)
153  .def("GetBoolProp", get_bool1)
154  .def("GetBoolProp", get_bool2)
155  .def("GetFloatProp", get_float1)
156  .def("GetFloatProp", get_float2)
157  .def("GetVec3Prop", get_vec3)
158  .def("GetIntProp", get_int1)
159  .def("GetIntProp", get_int2)
160  .def("GetStringProp", get_str1)
161  .def("GetStringProp", get_str2)
162  .def("GetPropList",&C::GetPropList)
163  .def("GetGenericBoolProperty", &depr_get_bool_a<C>)
164  .def("GetGenericBoolProperty", &depr_get_bool_b<C>)
165  .def("GetGenericFloatProperty", &depr_get_float_a<C>)
166  .def("GetGenericFloatProperty", &depr_get_float_b<C>)
167  .def("GetGenericIntProperty", &depr_get_int_a<C>)
168  .def("GetGenericIntProperty", &depr_get_int_b<C>)
169  .def("GetGenericStringProperty", &depr_get_string_a<C>)
170  .def("GetGenericStringProperty", &depr_get_string_b<C>)
171  .def("HasGenericProperty", &depr_has_prop<C>)
172  .def("GetGenericPropertyStringRepresentation", &depr_prop_as_string<C>)
173  ;
174 }
175 
176 template <typename C, typename O>
177 void generic_prop_def(O& bp_class)
178 {
179  const_generic_prop_def<C, O>(bp_class);
180  bp_class
181  .def("SetBoolProp",&C::SetBoolProp)
182  .def("ClearProps", &C::ClearProps)
183  .def("GetPropAsString", &C::GetPropAsString)
184  .def("SetFloatProp", &C::SetFloatProp)
185  .def("SetVec3Prop", &C::SetVec3Prop)
186  .def("SetIntProp", &C::SetIntProp)
187  .def("SetStringProp", &C::SetStringProp)
188  .def("GetPropList",&C::GetPropList)
189  .def("ClearGenericProperties", &depr_clear_props<C>)
190  .def("SetGenericIntProperty", &depr_set_int<C>)
191  .def("SetGenericFloatProperty", &depr_set_float<C>)
192  .def("SetGenericBoolProperty", &depr_set_bool<C>)
193  .def("SetGenericStringProperty", &depr_set_string<C>)
194  .def("RemoveProp", &C::RemoveProp)
195  ;
196 }
197 
198 #endif
#define WARN_DEPRECATED(m)
Definition: log.hh:80
String depr_get_string_a(C &c, const String &k, const String &v)
Real depr_get_float_b(C &c, const String &k)
std::string String
Definition: base.hh:54
float Real
Definition: base.hh:44
bool depr_get_bool_a(C &c, const String &k, const bool &v)
void depr_set_string(C &c, const String &k, const String &v)
void generic_prop_def(O &bp_class)
void depr_set_int(C &c, const String &k, const int &v)
void depr_clear_props(C &c)
int depr_get_int_a(C &c, const String &k, const int &v)
String depr_prop_as_string(C &c, const String &k)
Three dimensional vector class, using Real precision.
Definition: vec3.hh:42
String depr_get_string_b(C &c, const String &k)
void depr_set_bool(C &c, const String &k, const bool &v)
int depr_get_int_b(C &c, const String &k)
bool depr_get_bool_b(C &c, const String &k)
void const_generic_prop_def(O &bp_class)
void depr_set_float(C &c, const String &k, const Real &v)
Real depr_get_float_a(C &c, const String &k, const float &v)
bool depr_has_prop(C &c, const String &k)