29 {
object.template bind<Q>(val);
return true; }
33 {
object.template bind<std::vector<Q> >(val);
return true; }
36 template <
typename T,
typename Q>
bool __bind__(
const dd4hep::detail::ListBinder&, T&
object,
const std::string& val,
const Q*)
37 {
object.template bind<std::list<Q> >(val);
return true; }
40 template <
typename T,
typename Q>
bool __bind__(
const dd4hep::detail::SetBinder&, T&
object,
const std::string& val,
const Q*)
41 {
object.template bind<std::set<Q> >(val);
return true; }
45 {
object.template bind<Q>();
return true; }
56 template <
typename BINDER,
typename T>
58 #if defined(DD4HEP_HAVE_ALL_PARSERS)
59 if ( typ.substr(0,4) ==
"char" )
60 return __bind__(b,
object,val,Primitive<char>::null_pointer());
61 else if ( typ.substr(0,13) ==
"unsigned char" )
62 return __bind__(b,
object,val,Primitive<unsigned char>::null_pointer());
63 else if ( typ.substr(0,5) ==
"short" )
64 return __bind__(b,
object,val,Primitive<short>::null_pointer());
65 else if ( typ.substr(0,14) ==
"unsigned short" )
66 return __bind__(b,
object,val,Primitive<unsigned short>::null_pointer());
67 else if ( typ.substr(0,12) ==
"unsigned int" )
68 return __bind__(b,
object,val,Primitive<unsigned int>::null_pointer());
69 else if ( typ.substr(0,13) ==
"unsigned long" )
70 return __bind__(b,
object,val,Primitive<unsigned long>::null_pointer());
73 if ( typ.substr(0,4) ==
"char" )
74 return __bind__(b,
object,val,Primitive<int>::null_pointer());
75 else if ( typ.substr(0,5) ==
"short" )
76 return __bind__(b,
object,val,Primitive<int>::null_pointer());
78 else if ( typ.substr(0,3) ==
"int" )
79 return __bind__(b,
object,val,Primitive<int>::null_pointer());
80 else if ( typ.substr(0,4) ==
"long" )
81 return __bind__(b,
object,val,Primitive<long>::null_pointer());
82 else if ( typ.substr(0,5) ==
"float" )
83 return __bind__(b,
object,val,Primitive<float>::null_pointer());
84 else if ( typ.substr(0,6) ==
"double" )
85 return __bind__(b,
object,val,Primitive<double>::null_pointer());
86 else if ( typ.substr(0,6) ==
"string" )
87 return __bind__(b,
object,val,Primitive<std::string>::null_pointer());
88 else if ( typ ==
"std::string" )
89 return __bind__(b,
object,val,Primitive<std::string>::null_pointer());
90 else if ( typ ==
"Histo1D" )
91 return __bind__(b,
object,val,Primitive<std::string>::null_pointer());
92 else if ( typ ==
"Histo2D" )
93 return __bind__(b,
object,val,Primitive<std::string>::null_pointer());
95 printout(INFO,
"OpaqueDataBinder",
"++ Unknown conditions parameter type:%s val:%s",typ.c_str(),val.c_str());
96 return __bind__(b,
object,val,Primitive<std::string>::null_pointer());
99 const std::string& typ,
const std::string& val);
101 const std::string& typ,
const std::string& val);
103 const std::string& typ,
const std::string& val);
105 const std::string& typ,
const std::string& val);
107 template bool OpaqueDataBinder::bind<ValueBinder,Condition>(
const ValueBinder& b,
Condition&
object,
108 const std::string& typ,
const std::string& val);
109 template bool OpaqueDataBinder::bind<VectorBinder,Condition>(
const VectorBinder& b,
Condition&
object,
110 const std::string& typ,
const std::string& val);
111 template bool OpaqueDataBinder::bind<ListBinder,Condition>(
const ListBinder& b,
Condition&
object,
112 const std::string& typ,
const std::string& val);
113 template bool OpaqueDataBinder::bind<SetBinder,Condition>(
const SetBinder& b,
Condition&
object,
114 const std::string& typ,
const std::string& val);
117 template <
typename T>
120 std::size_t idx = typ.find(
'[');
121 std::size_t idq = typ.find(
']');
122 std::string value_type = typ.substr(idx+1,idq-idx-1);
123 if ( typ.substr(0,6) ==
"vector" )
125 else if ( typ.substr(0,4) ==
"list" )
127 else if ( typ.substr(0,3) ==
"set" )
129 else if ( idx == std::string::npos && idq == std::string::npos )
134 template<
typename BINDER,
typename OBJECT,
typename KEY,
typename VAL>
135 static void emplace_map_item(
const BINDER&,
138 const std::string& val,
141 typedef std::map<KEY,VAL> map_t;
142 map_t& m =
object.template get<map_t>();
144 if ( !BasicGrammar::instance<VAL>().fromString(&
v, val) ) {
145 except(
"OpaqueDataBinder",
"++ Failed to convert conditions map entry.");
150 template<
typename BINDER,
typename OBJECT,
typename KEY>
151 static void emplace_map_key(
const BINDER& b,
153 const std::string& key_val,
154 const std::string& val_type,
155 const std::string& val,
159 BasicGrammar::instance<KEY>().fromString(&
key, key_val);
161 if ( val_type.substr(0,4) ==
"char" )
162 emplace_map_item(b,
object,
key, val, (
int*)0);
163 else if ( val_type.substr(0,5) ==
"short" )
164 emplace_map_item(b,
object,
key, val, (
int*)0);
165 else if ( val_type.substr(0,3) ==
"int" )
166 emplace_map_item(b,
object,
key, val, (
int*)0);
167 else if ( val_type.substr(0,4) ==
"long" )
168 emplace_map_item(b,
object,
key, val, (
long*)0);
169 else if ( val_type.substr(0,5) ==
"float" )
170 emplace_map_item(b,
object,
key, val, (
float*)0);
171 else if ( val_type.substr(0,6) ==
"double" )
172 emplace_map_item(b,
object,
key, val, (
double*)0);
173 else if ( val_type.substr(0,6) ==
"string" )
174 emplace_map_item(b,
object,
key, val, (std::string*)0);
175 else if ( val_type ==
"std::string" )
176 emplace_map_item(b,
object,
key, val, (std::string*)0);
178 printout(INFO,
"Param",
"++ Unknown conditions parameter type:%s data:%s",
179 val_type.c_str(),val.c_str());
180 emplace_map_item(b,
object,
key, val, (std::string*)0);
184 template<
typename BINDER,
typename OBJECT,
typename KEY,
typename VAL>
185 static void emplace_map_pair(
const BINDER&,
187 const std::string& data,
191 typedef std::map<KEY,VAL> map_t;
192 std::pair<KEY,VAL> entry;
193 map_t& m =
object.template get<map_t>();
195 except(
"OpaqueDataBinder",
"++ Failed to convert conditions map entry.");
200 template<
typename BINDER,
typename OBJECT,
typename KEY>
201 static void emplace_map_data(
const BINDER& b,
203 const std::string& val_type,
204 const std::string& pair_data,
208 if ( val_type.substr(0,4) ==
"char" )
209 emplace_map_pair(b,
object, pair_data, (KEY*)0, (
int*)0);
210 else if ( val_type.substr(0,5) ==
"short" )
211 emplace_map_pair(b,
object, pair_data, (KEY*)0, (
int*)0);
212 else if ( val_type.substr(0,3) ==
"int" )
213 emplace_map_pair(b,
object, pair_data, (KEY*)0, (
int*)0);
214 else if ( val_type.substr(0,4) ==
"long" )
215 emplace_map_pair(b,
object, pair_data, (KEY*)0, (
long*)0);
216 else if ( val_type.substr(0,5) ==
"float" )
217 emplace_map_pair(b,
object, pair_data, (KEY*)0, (
float*)0);
218 else if ( val_type.substr(0,6) ==
"double" )
219 emplace_map_pair(b,
object, pair_data, (KEY*)0, (
double*)0);
220 else if ( val_type.substr(0,6) ==
"string" )
221 emplace_map_pair(b,
object, pair_data, (KEY*)0, (std::string*)0);
222 else if ( val_type ==
"std::string" )
223 emplace_map_pair(b,
object, pair_data, (KEY*)0, (std::string*)0);
225 printout(INFO,
"Param",
"++ Unknown conditions parameter type:%s data:%s",
226 val_type.c_str(),pair_data.c_str());
227 emplace_map_pair(b,
object, pair_data, (KEY*)0, (std::string*)0);
231 template<
typename BINDER,
typename OBJECT,
typename KEY>
232 static void bind_mapping(
const BINDER& b,
const std::string& val_type, OBJECT&
object,
const KEY*) {
233 if ( val_type.substr(0,3) ==
"int" )
234 __bind__(b,
object, (std::map<KEY,int>*)0);
235 #if defined(DD4HEP_HAVE_ALL_PARSERS)
236 else if ( val_type.substr(0,12) ==
"unsigned int" )
237 __bind__(b,
object, (std::map<KEY,unsigned int>*)0);
238 else if ( val_type.substr(0,4) ==
"char" )
239 __bind__(b,
object, (std::map<KEY,char>*)0);
240 else if ( val_type.substr(0,13) ==
"unsigned char" )
241 __bind__(b,
object, (std::map<KEY,unsigned char>*)0);
242 else if ( val_type.substr(0,5) ==
"short" )
243 __bind__(b,
object, (std::map<KEY,short>*)0);
244 else if ( val_type.substr(0,14) ==
"unsigned short" )
245 __bind__(b,
object, (std::map<KEY,unsigned short>*)0);
246 else if ( val_type.substr(0,13) ==
"unsigned long" )
247 __bind__(b,
object, (std::map<KEY,unsigned long>*)0);
250 else if ( val_type.substr(0,4) ==
"char" )
251 __bind__(b,
object, (std::map<KEY,int>*)0);
252 else if ( val_type.substr(0,5) ==
"short" )
253 __bind__(b,
object, (std::map<KEY,int>*)0);
255 else if ( val_type.substr(0,4) ==
"long" )
256 __bind__(b,
object, (std::map<KEY,long>*)0);
257 else if ( val_type.substr(0,5) ==
"float" )
258 __bind__(b,
object, (std::map<KEY,float>*)0);
259 else if ( val_type.substr(0,6) ==
"double" )
260 __bind__(b,
object, (std::map<KEY,double>*)0);
261 else if ( val_type.substr(0,6) ==
"string" )
262 __bind__(b,
object, (std::map<KEY,std::string>*)0);
263 else if ( val_type ==
"std::string" )
264 __bind__(b,
object, (std::map<KEY,std::string>*)0);
266 __bind__(b,
object, (std::map<KEY,std::string>*)0);
271 template <
typename BINDER,
typename OBJECT>
273 const std::string& key_type,
const std::string& val_type) {
275 if ( key_type.substr(0,3) ==
"int" )
276 bind_mapping(b, val_type,
object, Primitive<int>::null_pointer());
277 #if defined(DD4HEP_HAVE_ALL_PARSERS)
278 else if ( key_type.substr(0,4) ==
"char" )
279 bind_mapping(b, val_type,
object, Primitive<int>::null_pointer());
280 else if ( key_type.substr(0,5) ==
"short" )
281 bind_mapping(b, val_type,
object, Primitive<int>::null_pointer());
282 else if ( key_type.substr(0,4) ==
"long" )
283 bind_mapping(b, val_type,
object, Primitive<long>::null_pointer());
284 else if ( key_type.substr(0,5) ==
"float" )
285 bind_mapping(b, val_type,
object, Primitive<float>::null_pointer());
286 else if ( key_type.substr(0,6) ==
"double" )
287 bind_mapping(b, val_type,
object, Primitive<double>::null_pointer());
289 else if ( key_type.substr(0,6) ==
"string" )
290 bind_mapping(b, val_type,
object, Primitive<std::string>::null_pointer());
291 else if ( key_type ==
"std::string" )
292 bind_mapping(b, val_type,
object, Primitive<std::string>::null_pointer());
294 printout(INFO,
"OpaqueDataBinder",
"++ Unknown MAP-conditions key-type:%s",key_type.c_str());
295 bind_mapping(b, val_type,
object, Primitive<std::string>::null_pointer());
301 template <
typename BINDER,
typename OBJECT>
303 const std::string& key_type,
const std::string&
key,
304 const std::string& val_type,
const std::string& val)
306 if ( key_type.substr(0,3) ==
"int" )
307 emplace_map_key(b,
object,
key, val_type, val, Primitive<int>::null_pointer());
308 #if defined(DD4HEP_HAVE_ALL_PARSERS)
310 else if ( key_type.substr(0,4) ==
"char" )
311 emplace_map_key(b,
object,
key, val_type, val, Primitive<int>::null_pointer());
312 else if ( key_type.substr(0,5) ==
"short" )
313 emplace_map_key(b,
object,
key, val_type, val, Primitive<int>::null_pointer());
314 else if ( key_type.substr(0,4) ==
"long" )
315 emplace_map_key(b,
object,
key, val_type, val, Primitive<long>::null_pointer());
316 else if ( key_type.substr(0,5) ==
"float" )
317 emplace_map_key(b,
object,
key, val_type, val, Primitive<float>::null_pointer());
318 else if ( key_type.substr(0,6) ==
"double" )
319 emplace_map_key(b,
object,
key, val_type, val, Primitive<double>::null_pointer());
321 else if ( key_type.substr(0,6) ==
"string" )
322 emplace_map_key(b,
object,
key, val_type, val, Primitive<std::string>::null_pointer());
323 else if ( key_type ==
"std::string" )
324 emplace_map_key(b,
object,
key, val_type, val, Primitive<std::string>::null_pointer());
326 printout(INFO,
"OpaqueDataBinder",
"++ Unknown MAP-conditions key-type:%s",key_type.c_str());
327 emplace_map_key(b,
object,
key, val_type, val, Primitive<std::string>::null_pointer());
333 template <
typename BINDER,
typename OBJECT>
335 const std::string& key_type,
const std::string& val_type,
336 const std::string& pair_data)
338 if ( key_type.substr(0,3) ==
"int" )
339 emplace_map_data(b,
object, val_type, pair_data, Primitive<int>::null_pointer());
340 #if defined(DD4HEP_HAVE_ALL_PARSERS)
342 else if ( key_type.substr(0,4) ==
"char" )
343 emplace_map_data(b,
object, val_type, pair_data, Primitive<int>::null_pointer());
344 else if ( key_type.substr(0,5) ==
"short" )
345 emplace_map_data(b,
object, val_type, pair_data, Primitive<int>::null_pointer());
346 else if ( key_type.substr(0,4) ==
"long" )
347 emplace_map_data(b,
object, val_type, pair_data, Primitive<long>::null_pointer());
348 else if ( key_type.substr(0,5) ==
"float" )
349 emplace_map_data(b,
object, val_type, pair_data, Primitive<float>::null_pointer());
350 else if ( key_type.substr(0,6) ==
"double" )
351 emplace_map_data(b,
object, val_type, pair_data, Primitive<double>::null_pointer());
353 else if ( key_type.substr(0,6) ==
"string" )
354 emplace_map_data(b,
object, val_type, pair_data, Primitive<std::string>::null_pointer());
355 else if ( key_type ==
"std::string" )
356 emplace_map_data(b,
object, val_type, pair_data, Primitive<std::string>::null_pointer());
358 printout(INFO,
"OpaqueDataBinder",
"++ Unknown MAP-conditions key-type:%s",key_type.c_str());
359 emplace_map_data(b,
object, val_type, pair_data, Primitive<std::string>::null_pointer());
364 template bool OpaqueDataBinder::bind_sequence<OpaqueDataBlock>(
OpaqueDataBlock&
object,
const std::string& typ,
const std::string& val);
366 const std::string& typ,
const std::string& val);
368 const std::string& key_type,
const std::string&
key,
369 const std::string& val_type,
const std::string& val);
371 const std::string& key_type,
const std::string& val_type,
372 const std::string& pair_data);
375 template bool OpaqueDataBinder::bind_sequence<Condition>(
Condition&
object,
376 const std::string& typ,
const std::string& val);
379 const std::string& key_type,
const std::string& val_type)
380 {
return bind_map(b, object->
data, key_type, val_type); }
384 const std::string& key_type,
const std::string&
key,
385 const std::string& val_type,
const std::string& val)
390 const std::string& key_type,
const std::string& val_type,
const std::string& pair_data)
391 {
return insert_map(b, object->
data, key_type, val_type, pair_data); }