OpenStructure
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  String (C::*get_str1)(const String&, const String&) const=&C::GetStringProp;
146  String (C::*get_str2)(const String&) const=&C::GetStringProp;
147  bp_class
148  .def("HasProp", &C::HasProp)
149  .def("GetPropAsString",
150  &C::GetPropAsString)
151  .def("GetBoolProp", get_bool1)
152  .def("GetBoolProp", get_bool2)
153  .def("GetFloatProp", get_float1)
154  .def("GetFloatProp", get_float2)
155  .def("GetIntProp", get_int1)
156  .def("GetIntProp", get_int2)
157  .def("GetStringProp", get_str1)
158  .def("GetStringProp", get_str2)
159  .def("GetPropList",&C::GetPropList)
160  .def("GetGenericBoolProperty", &depr_get_bool_a<C>)
161  .def("GetGenericBoolProperty", &depr_get_bool_b<C>)
162  .def("GetGenericFloatProperty", &depr_get_float_a<C>)
163  .def("GetGenericFloatProperty", &depr_get_float_b<C>)
164  .def("GetGenericIntProperty", &depr_get_int_a<C>)
165  .def("GetGenericIntProperty", &depr_get_int_b<C>)
166  .def("GetGenericStringProperty", &depr_get_string_a<C>)
167  .def("GetGenericStringProperty", &depr_get_string_b<C>)
168  .def("HasGenericProperty", &depr_has_prop<C>)
169  .def("GetGenericPropertyStringRepresentation", &depr_prop_as_string<C>)
170  ;
171 }
172 
173 template <typename C, typename O>
174 void generic_prop_def(O& bp_class)
175 {
176  const_generic_prop_def<C, O>(bp_class);
177  bp_class
178  .def("SetBoolProp",&C::SetBoolProp)
179  .def("ClearProps", &C::ClearProps)
180  .def("GetPropAsString", &C::GetPropAsString)
181  .def("SetFloatProp", &C::SetFloatProp)
182  .def("SetIntProp", &C::SetIntProp)
183  .def("SetStringProp", &C::SetStringProp)
184  .def("GetPropList",&C::GetPropList)
185  .def("ClearGenericProperties", &depr_clear_props<C>)
186  .def("SetGenericIntProperty", &depr_set_int<C>)
187  .def("SetGenericFloatProperty", &depr_set_float<C>)
188  .def("SetGenericBoolProperty", &depr_set_bool<C>)
189  .def("SetGenericStringProperty", &depr_set_string<C>)
190  .def("RemoveProp", &C::RemoveProp)
191  ;
192 }
193 
194 #endif