lsst.daf.base  16.0-5-g4940a70
PropertySet.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more errors.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
26 
27 #include <algorithm>
28 #include <iomanip>
29 #include <sstream>
30 #include <stdexcept>
31 
33 #include "lsst/daf/base/DateTime.h"
34 
35 namespace lsst {
36 namespace daf {
37 namespace base {
38 
39 namespace {
40 
47 template <typename T>
48 void _append(std::vector<boost::any>& dest, std::vector<T> const& src) {
49  dest.reserve(dest.size() + src.size());
50  for (const T& val : src) {
51  dest.push_back(static_cast<T>(val));
52  }
53 }
54 
55 } // namespace
56 
57 PropertySet::PropertySet(bool flat) : Citizen(typeid(*this)), _flat(flat) {}
58 
60 
62 // Accessors
64 
66  Ptr n(new PropertySet(_flat));
67  for (auto const& elt : _map) {
68  if (elt.second->back().type() == typeid(Ptr)) {
69  for (auto const& j : *elt.second) {
70  Ptr p = boost::any_cast<Ptr>(j);
71  if (p.get() == 0) {
72  n->add(elt.first, Ptr());
73  } else {
74  n->add(elt.first, p->deepCopy());
75  }
76  }
77  } else {
79  n->_map[elt.first] = vp;
80  }
81  }
82  return n;
83 }
84 
85 size_t PropertySet::nameCount(bool topLevelOnly) const {
86  int n = 0;
87  for (auto const& elt : _map) {
88  ++n;
89  if (!topLevelOnly && elt.second->back().type() == typeid(Ptr)) {
90  Ptr p = boost::any_cast<Ptr>(elt.second->back());
91  if (p.get() != 0) {
92  n += p->nameCount(false);
93  }
94  }
95  }
96  return n;
97 }
98 
99 std::vector<std::string> PropertySet::names(bool topLevelOnly) const {
101  for (auto const& elt : _map) {
102  v.push_back(elt.first);
103  if (!topLevelOnly && elt.second->back().type() == typeid(Ptr)) {
104  Ptr p = boost::any_cast<Ptr>(elt.second->back());
105  if (p.get() != 0) {
106  std::vector<std::string> w = p->names(false);
107  for (auto const& k : w) {
108  v.push_back(elt.first + "." + k);
109  }
110  }
111  }
112  }
113  return v;
114 }
115 
116 std::vector<std::string> PropertySet::paramNames(bool topLevelOnly) const {
118  for (auto const& elt : _map) {
119  if (elt.second->back().type() == typeid(Ptr)) {
120  Ptr p = boost::any_cast<Ptr>(elt.second->back());
121  if (p.get() != 0 && !topLevelOnly) {
122  std::vector<std::string> w = p->paramNames(false);
123  for (auto const& k : w) {
124  v.push_back(elt.first + "." + k);
125  }
126  }
127  } else {
128  v.push_back(elt.first);
129  }
130  }
131  return v;
132 }
133 
136  for (auto const& elt : _map) {
137  if (elt.second->back().type() == typeid(Ptr)) {
138  v.push_back(elt.first);
139  Ptr p = boost::any_cast<Ptr>(elt.second->back());
140  if (p.get() != 0 && !topLevelOnly) {
141  std::vector<std::string> w = p->propertySetNames(false);
142  for (auto const& k : w) {
143  v.push_back(elt.first + "." + k);
144  }
145  }
146  }
147  }
148  return v;
149 }
150 
151 bool PropertySet::exists(std::string const& name) const { return _find(name) != _map.end(); }
152 
153 bool PropertySet::isArray(std::string const& name) const {
154  auto const i = _find(name);
155  return i != _map.end() && i->second->size() > 1U;
156 }
157 
158 bool PropertySet::isPropertySetPtr(std::string const& name) const {
159  auto const i = _find(name);
160  return i != _map.end() && i->second->back().type() == typeid(Ptr);
161 }
162 
163 size_t PropertySet::valueCount(std::string const& name) const {
164  auto const i = _find(name);
165  if (i == _map.end()) return 0;
166  return i->second->size();
167 }
168 
169 std::type_info const& PropertySet::typeOf(std::string const& name) const {
170  auto const i = _find(name);
171  if (i == _map.end()) {
172  throw LSST_EXCEPT(pex::exceptions::NotFoundError, name + " not found");
173  }
174  return i->second->back().type();
175 }
176 
177 // The following throw an exception if the type does not match exactly.
178 
179 template <typename T>
180 T PropertySet::get(std::string const& name)
181  const { /* parasoft-suppress LsstDm-3-4a LsstDm-4-6 "allow template over bool" */
182  auto const i = _find(name);
183  if (i == _map.end()) {
184  throw LSST_EXCEPT(pex::exceptions::NotFoundError, name + " not found");
185  }
186  try {
187  return boost::any_cast<T>(i->second->back());
188  } catch (boost::bad_any_cast) {
189  throw LSST_EXCEPT(pex::exceptions::TypeError, name);
190  }
191  // not reached
192  return boost::any_cast<T>(i->second->back());
193 }
194 
195 template <typename T>
196 T PropertySet::get(std::string const& name, T const& defaultValue)
197  const { /* parasoft-suppress LsstDm-3-4a LsstDm-4-6 "allow template over bool" */
198  auto const i = _find(name);
199  if (i == _map.end()) {
200  return defaultValue;
201  }
202  try {
203  return boost::any_cast<T>(i->second->back());
204  } catch (boost::bad_any_cast) {
205  throw LSST_EXCEPT(pex::exceptions::TypeError, name);
206  }
207  // not reached
208  return boost::any_cast<T>(i->second->back());
209 }
210 
211 template <typename T>
213  auto const i = _find(name);
214  if (i == _map.end()) {
215  throw LSST_EXCEPT(pex::exceptions::NotFoundError, name + " not found");
216  }
217  std::vector<T> v;
218  for (auto const& j : *(i->second)) {
219  try {
220  v.push_back(boost::any_cast<T>(j));
221  } catch (boost::bad_any_cast) {
222  throw LSST_EXCEPT(pex::exceptions::TypeError, name);
223  }
224  }
225  return v;
226 }
227 
228 // The following throw an exception if the conversion is inappropriate.
229 
230 bool PropertySet::getAsBool(std::string const& name)
231  const { /* parasoft-suppress LsstDm-3-4a LsstDm-4-6 "for symmetry with other types" */
232  return get<bool>(name);
233 }
234 
235 int PropertySet::getAsInt(std::string const& name) const {
236  auto const i = _find(name);
237  if (i == _map.end()) {
238  throw LSST_EXCEPT(pex::exceptions::NotFoundError, name + " not found");
239  }
240  boost::any v = i->second->back();
241  std::type_info const& t = v.type();
242  if (t == typeid(bool)) {
243  return boost::any_cast<bool>(v);
244  } else if (t == typeid(char)) {
245  return boost::any_cast<char>(v);
246  } else if (t == typeid(signed char)) {
247  return boost::any_cast<signed char>(v);
248  } else if (t == typeid(unsigned char)) {
249  return boost::any_cast<unsigned char>(v);
250  } else if (t == typeid(short)) {
251  return boost::any_cast<short>(v);
252  } else if (t == typeid(unsigned short)) {
253  return boost::any_cast<unsigned short>(v);
254  }
255  try {
256  return boost::any_cast<int>(v);
257  } catch (boost::bad_any_cast) {
258  throw LSST_EXCEPT(pex::exceptions::TypeError, name);
259  }
260  // not reached
261  return boost::any_cast<int>(v);
262 }
263 
264 int64_t PropertySet::getAsInt64(std::string const& name) const {
265  auto const i = _find(name);
266  if (i == _map.end()) {
267  throw LSST_EXCEPT(pex::exceptions::NotFoundError, name + " not found");
268  }
269  boost::any v = i->second->back();
270  std::type_info const& t = v.type();
271  if (t == typeid(bool)) return boost::any_cast<bool>(v);
272  if (t == typeid(char)) return boost::any_cast<char>(v);
273  if (t == typeid(signed char)) return boost::any_cast<signed char>(v);
274  if (t == typeid(unsigned char)) return boost::any_cast<unsigned char>(v);
275  if (t == typeid(short)) return boost::any_cast<short>(v);
276  if (t == typeid(unsigned short)) return boost::any_cast<unsigned short>(v);
277  if (t == typeid(int)) return boost::any_cast<int>(v);
278  if (t == typeid(unsigned int)) return boost::any_cast<unsigned int>(v);
279  if (t == typeid(long)) return boost::any_cast<long>(v);
280  if (t == typeid(long long)) return boost::any_cast<long long>(v);
281  try {
282  return boost::any_cast<int64_t>(v);
283  } catch (boost::bad_any_cast) {
284  throw LSST_EXCEPT(pex::exceptions::TypeError, name);
285  }
286  // not reached
287  return boost::any_cast<int64_t>(v);
288 }
289 
290 double PropertySet::getAsDouble(std::string const& name) const {
291  auto const i = _find(name);
292  if (i == _map.end()) {
293  throw LSST_EXCEPT(pex::exceptions::NotFoundError, name + " not found");
294  }
295  boost::any v = i->second->back();
296  std::type_info const& t = v.type();
297  if (t == typeid(bool)) return boost::any_cast<bool>(v);
298  if (t == typeid(char)) return boost::any_cast<char>(v);
299  if (t == typeid(signed char)) return boost::any_cast<signed char>(v);
300  if (t == typeid(unsigned char)) return boost::any_cast<unsigned char>(v);
301  if (t == typeid(short)) return boost::any_cast<short>(v);
302  if (t == typeid(unsigned short)) return boost::any_cast<unsigned short>(v);
303  if (t == typeid(int)) return boost::any_cast<int>(v);
304  if (t == typeid(unsigned int)) return boost::any_cast<unsigned int>(v);
305  if (t == typeid(long)) return boost::any_cast<long>(v);
306  if (t == typeid(unsigned long)) return boost::any_cast<unsigned long>(v);
307  if (t == typeid(long long)) return boost::any_cast<long long>(v);
308  if (t == typeid(unsigned long long)) return boost::any_cast<unsigned long long>(v);
309  if (t == typeid(float)) return boost::any_cast<float>(v);
310  try {
311  return boost::any_cast<double>(v);
312  } catch (boost::bad_any_cast) {
313  throw LSST_EXCEPT(pex::exceptions::TypeError, name);
314  }
315  // not reached
316  return boost::any_cast<double>(v);
317 }
318 
319 std::string PropertySet::getAsString(std::string const& name) const { return get<std::string>(name); }
320 
321 PropertySet::Ptr PropertySet::getAsPropertySetPtr(std::string const& name) const { return get<Ptr>(name); }
322 
324  return get<Persistable::Ptr>(name);
325 }
326 
327 std::string PropertySet::toString(bool topLevelOnly, std::string const& indent) const {
330  sort(nv.begin(), nv.end());
331  for (auto const& i : nv) {
332  std::shared_ptr<std::vector<boost::any>> vp = _map.find(i)->second;
333  std::type_info const& t = vp->back().type();
334  if (t == typeid(Ptr)) {
335  s << indent << i << " = ";
336  if (topLevelOnly) {
337  s << "{ ... }";
338  } else {
339  Ptr p = boost::any_cast<Ptr>(vp->back());
340  if (p.get() == 0) {
341  s << "{ NULL }";
342  } else {
343  s << '{' << std::endl;
344  s << p->toString(false, indent + "..");
345  s << indent << '}';
346  }
347  }
348  s << std::endl;
349  } else {
350  s << indent << _format(i);
351  }
352  }
353  return s.str();
354 }
355 
356 std::string PropertySet::_format(std::string const& name) const {
358  s << std::showpoint; // Always show a decimal point for floats
359  auto const j = _map.find(name);
360  s << j->first << " = ";
362  if (vp->size() > 1) {
363  s << "[ ";
364  }
365  std::type_info const& t = vp->back().type();
366  bool isFirst = true;
367  for (auto const& k : *vp) {
368  if (isFirst) {
369  isFirst = false;
370  } else {
371  s << ", ";
372  }
373  boost::any const& v(k);
374  if (t == typeid(bool)) {
375  s << boost::any_cast<bool>(v);
376  } else if (t == typeid(char)) {
377  s << '\'' << boost::any_cast<char>(v) << '\'';
378  } else if (t == typeid(signed char)) {
379  s << '\'' << boost::any_cast<signed char>(v) << '\'';
380  } else if (t == typeid(unsigned char)) {
381  s << '\'' << boost::any_cast<unsigned char>(v) << '\'';
382  } else if (t == typeid(short)) {
383  s << boost::any_cast<short>(v);
384  } else if (t == typeid(unsigned short)) {
385  s << boost::any_cast<unsigned short>(v);
386  } else if (t == typeid(int)) {
387  s << boost::any_cast<int>(v);
388  } else if (t == typeid(unsigned int)) {
389  s << boost::any_cast<unsigned int>(v);
390  } else if (t == typeid(long)) {
391  s << boost::any_cast<long>(v);
392  } else if (t == typeid(unsigned long)) {
393  s << boost::any_cast<unsigned long>(v);
394  } else if (t == typeid(long long)) {
395  s << boost::any_cast<long long>(v);
396  } else if (t == typeid(unsigned long long)) {
397  s << boost::any_cast<unsigned long long>(v);
398  } else if (t == typeid(float)) {
399  s << std::setprecision(7) << boost::any_cast<float>(v);
400  } else if (t == typeid(double)) {
401  s << std::setprecision(14) << boost::any_cast<double>(v);
402  } else if (t == typeid(std::string)) {
403  s << '"' << boost::any_cast<std::string>(v) << '"';
404  } else if (t == typeid(DateTime)) {
405  s << boost::any_cast<DateTime>(v).toString(DateTime::UTC);
406  } else if (t == typeid(Ptr)) {
407  s << "{ ... }";
408  } else if (t == typeid(Persistable::Ptr)) {
409  s << "<Persistable>";
410  } else {
411  s << "<Unknown>";
412  }
413  }
414  if (j->second->size() > 1) {
415  s << " ]";
416  }
417  s << std::endl;
418  return s.str();
419 }
420 
422 // Modifiers
424 
425 template <typename T>
426 void PropertySet::set(std::string const& name, T const& value) {
428  vp->push_back(value);
429  _set(name, vp);
430 }
431 
432 template <typename T>
433 void PropertySet::set(std::string const& name, std::vector<T> const& value) {
434  if (value.empty()) return;
436  _append(*vp, value);
437  _set(name, vp);
438 }
439 
440 void PropertySet::set(std::string const& name, char const* value) { set(name, std::string(value)); }
441 
442 template <typename T>
443 void PropertySet::add(std::string const& name, T const& value) {
444  AnyMap::iterator i = _find(name);
445  if (i == _map.end()) {
446  set(name, value);
447  } else {
448  if (i->second->back().type() != typeid(T)) {
449  throw LSST_EXCEPT(pex::exceptions::TypeError, name + " has mismatched type");
450  }
451  i->second->push_back(value);
452  }
453 }
454 
455 // Specialize for Ptrs to check for cycles.
456 template <>
457 void PropertySet::add<PropertySet::Ptr>(std::string const& name, Ptr const& value) {
458  AnyMap::iterator i = _find(name);
459  if (i == _map.end()) {
460  set(name, value);
461  } else {
462  if (i->second->back().type() != typeid(Ptr)) {
463  throw LSST_EXCEPT(pex::exceptions::TypeError, name + " has mismatched type");
464  }
465  _cycleCheckPtr(value, name);
466  i->second->push_back(value);
467  }
468 }
469 
470 template <typename T>
471 void PropertySet::add(std::string const& name, std::vector<T> const& value) {
472  AnyMap::iterator i = _find(name);
473  if (i == _map.end()) {
474  set(name, value);
475  } else {
476  if (i->second->back().type() != typeid(T)) {
477  throw LSST_EXCEPT(pex::exceptions::TypeError, name + " has mismatched type");
478  }
479  _append(*(i->second), value);
480  }
481 }
482 
483 // Specialize for Ptrs to check for cycles.
484 template <>
485 void PropertySet::add<PropertySet::Ptr>(std::string const& name, std::vector<Ptr> const& value) {
486  AnyMap::iterator i = _find(name);
487  if (i == _map.end()) {
488  set(name, value);
489  } else {
490  if (i->second->back().type() != typeid(Ptr)) {
491  throw LSST_EXCEPT(pex::exceptions::TypeError, name + " has mismatched type");
492  }
493  _cycleCheckPtrVec(value, name);
494  _append(*(i->second), value);
495  }
496 }
497 
498 void PropertySet::add(std::string const& name, char const* value) { add(name, std::string(value)); }
499 
500 void PropertySet::copy(std::string const& dest, ConstPtr source, std::string const& name, bool asScalar) {
501  if (source.get() == 0) {
502  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "Missing source");
503  }
504  auto const sj = source->_find(name);
505  if (sj == source->_map.end()) {
506  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, name + " not in source");
507  }
508  remove(dest);
509  if (asScalar) {
510  auto vp = std::make_shared<std::vector<boost::any>>();
511  vp->push_back(sj->second->back());
512  _set(dest, vp);
513  } else {
514  auto vp = std::make_shared<std::vector<boost::any>>(*(sj->second));
515  _set(dest, vp);
516  }
517 }
518 
519 void PropertySet::combine(ConstPtr source) {
520  if (source.get() == 0) {
521  return;
522  }
523  std::vector<std::string> names = source->paramNames(false);
524  for (auto const& name : names) {
525  auto const sp = source->_find(name);
526  _add(name, sp->second);
527  }
528 }
529 
530 void PropertySet::remove(std::string const& name) {
531  std::string::size_type i = name.find('.');
532  if (_flat || i == name.npos) {
533  _map.erase(name);
534  return;
535  }
536  std::string prefix(name, 0, i);
537  AnyMap::iterator j = _map.find(prefix);
538  if (j == _map.end() || j->second->back().type() != typeid(Ptr)) {
539  return;
540  }
541  Ptr p = boost::any_cast<Ptr>(j->second->back());
542  if (p.get() != 0) {
543  std::string suffix(name, i + 1);
544  p->remove(suffix);
545  }
546 }
547 
549 // Private member functions
551 
552 PropertySet::AnyMap::iterator PropertySet::_find(std::string const& name) {
553  std::string::size_type i = name.find('.');
554  if (_flat || i == name.npos) {
555  return _map.find(name);
556  }
557  std::string prefix(name, 0, i);
558  AnyMap::iterator j = _map.find(prefix);
559  if (j == _map.end() || j->second->back().type() != typeid(Ptr)) {
560  return _map.end();
561  }
562  Ptr p = boost::any_cast<Ptr>(j->second->back());
563  if (p.get() == 0) {
564  return _map.end();
565  }
566  std::string suffix(name, i + 1);
567  AnyMap::iterator x = p->_find(suffix);
568  if (x == p->_map.end()) {
569  return _map.end();
570  }
571  return x;
572 }
573 
574 PropertySet::AnyMap::const_iterator PropertySet::_find(std::string const& name) const {
575  std::string::size_type i = name.find('.');
576  if (_flat || i == name.npos) {
577  return _map.find(name);
578  }
579  std::string prefix(name, 0, i);
580  auto const j = _map.find(prefix);
581  if (j == _map.end() || j->second->back().type() != typeid(Ptr)) {
582  return _map.end();
583  }
584  Ptr p = boost::any_cast<Ptr>(j->second->back());
585  if (p.get() == 0) {
586  return _map.end();
587  }
588  std::string suffix(name, i + 1);
589  auto const x = p->_find(suffix);
590  if (x == p->_map.end()) {
591  return _map.end();
592  }
593  return x;
594 }
595 
597  _findOrInsert(name, vp);
598 }
599 
601  auto const dp = _find(name);
602  if (dp == _map.end()) {
603  _set(name, vp);
604  } else {
605  if (vp->back().type() != dp->second->back().type()) {
606  throw LSST_EXCEPT(pex::exceptions::TypeError, name + " has mismatched type");
607  }
608  // Check for cycles
609  if (vp->back().type() == typeid(Ptr)) {
610  _cycleCheckAnyVec(*vp, name);
611  }
612  _append(*(dp->second), *vp);
613  }
614 }
615 
616 void PropertySet::_findOrInsert(std::string const& name, std::shared_ptr<std::vector<boost::any>> vp) {
617  if (vp->back().type() == typeid(Ptr)) {
618  if (_flat) {
619  Ptr source = boost::any_cast<Ptr>(vp->back());
620  std::vector<std::string> names = source->paramNames(false);
621  for (auto const& i : names) {
622  auto const sp = source->_find(i);
623  _add(name + "." + i, sp->second);
624  }
625  return;
626  }
627 
628  // Check for cycles
629  _cycleCheckAnyVec(*vp, name);
630  }
631 
632  std::string::size_type i = name.find('.');
633  if (_flat || i == name.npos) {
634  _map[name] = vp;
635  return;
636  }
637  std::string prefix(name, 0, i);
638  std::string suffix(name, i + 1);
639  AnyMap::iterator j = _map.find(prefix);
640  if (j == _map.end()) {
642  pp->_findOrInsert(suffix, vp);
644  temp->push_back(pp);
645  _map[prefix] = temp;
646  return;
647  } else if (j->second->back().type() != typeid(Ptr)) {
648  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
649  prefix + " exists but does not contain PropertySet::Ptrs");
650  }
651  Ptr p = boost::any_cast<Ptr>(j->second->back());
652  if (p.get() == 0) {
653  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
654  prefix + " exists but contains null PropertySet::Ptr");
655  }
656  p->_findOrInsert(suffix, vp);
657 }
658 
659 void PropertySet::_cycleCheckPtrVec(std::vector<Ptr> const& v, std::string const& name) {
660  for (auto const& i : v) {
661  _cycleCheckPtr(i, name);
662  }
663 }
664 
665 void PropertySet::_cycleCheckAnyVec(std::vector<boost::any> const& v, std::string const& name) {
666  for (auto const& i : v) {
667  _cycleCheckPtr(boost::any_cast<Ptr>(i), name);
668  }
669 }
670 
671 void PropertySet::_cycleCheckPtr(Ptr const& v, std::string const& name) {
672  if (v.get() == this) {
673  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, name + " would cause a cycle");
674  }
675  std::vector<std::string> sets = v->propertySetNames(false);
676  for (auto const& i : sets) {
677  if (v->getAsPropertySetPtr(i).get() == this) {
678  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, name + " would cause a cycle");
679  }
680  }
681 }
682 
684 // Explicit template instantiations
686 
688 // Explicit template instantiations are not well understood by doxygen.
689 
690 #define INSTANTIATE(t) \
691  template t PropertySet::get<t>(std::string const& name) const; \
692  template t PropertySet::get<t>(std::string const& name, t const& defaultValue) const; \
693  template std::vector<t> PropertySet::getArray<t>(std::string const& name) const; \
694  template void PropertySet::set<t>(std::string const& name, t const& value); \
695  template void PropertySet::set<t>(std::string const& name, std::vector<t> const& value); \
696  template void PropertySet::add<t>(std::string const& name, t const& value); \
697  template void PropertySet::add<t>(std::string const& name, std::vector<t> const& value);
698 
699 #define INSTANTIATE_PROPERTY_SET(t) \
700  template t PropertySet::get<t>(std::string const& name) const; \
701  template t PropertySet::get<t>(std::string const& name, t const& defaultValue) const; \
702  template std::vector<t> PropertySet::getArray<t>(std::string const& name) const; \
703  template void PropertySet::set<t>(std::string const& name, t const& value); \
704  template void PropertySet::set<t>(std::string const& name, std::vector<t> const& value);
705 
706 INSTANTIATE(bool)
707 INSTANTIATE(char)
708 INSTANTIATE(signed char)
709 INSTANTIATE(unsigned char)
710 INSTANTIATE(short)
711 INSTANTIATE(unsigned short)
712 INSTANTIATE(int)
713 INSTANTIATE(unsigned int)
714 INSTANTIATE(long)
715 INSTANTIATE(unsigned long)
716 INSTANTIATE(long long)
717 INSTANTIATE(unsigned long long)
718 INSTANTIATE(float)
719 INSTANTIATE(double)
720 INSTANTIATE(std::string)
721 INSTANTIATE_PROPERTY_SET(PropertySet::Ptr)
722 INSTANTIATE(Persistable::Ptr)
723 INSTANTIATE(DateTime)
724 
725 } // namespace base
726 } // namespace daf
727 } // namespace lsst
728 
double getAsDouble(std::string const &name) const
Get the last value for any arithmetic property name (possibly hierarchical).
virtual std::string toString(bool topLevelOnly=false, std::string const &indent="") const
Generate a string representation of the PropertySet.
T empty(T... args)
std::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:75
virtual void copy(std::string const &dest, ConstPtr source, std::string const &name, bool asScalar=false)
Replace a single value vector in the destination with one from the source.
virtual Ptr deepCopy(void) const
Make a deep copy of the PropertySet and all of its contents.
size_t valueCount(std::string const &name) const
Get the number of values for a property name (possibly hierarchical).
virtual std::string toString(bool topLevelOnly=false, std::string const &indent="") const
Generate a string representation of the PropertySet.
Definition: PropertyList.cc:93
std::vector< T > getArray(std::string const &name) const
Get the vector of values for a property name (possibly hierarchical).
virtual void combine(ConstPtr source)
Append all value vectors from the source to their corresponding properties.
T get(std::string const &name) const
Get the last value for a property name (possibly hierarchical).
bool getAsBool(std::string const &name) const
Get the last value for a bool property name (possibly hierarchical).
std::vector< std::string > propertySetNames(bool topLevelOnly=true) const
A variant of names that only returns the names of subproperties.
int getAsInt(std::string const &name) const
Get the last value for a bool/char/short/int property name (possibly hierarchical).
T endl(T... args)
PropertySet::Ptr getAsPropertySetPtr(std::string const &name) const
Get the last value for a subproperty name (possibly hierarchical).
virtual std::string _format(std::string const &name) const
T end(T... args)
bool isPropertySetPtr(std::string const &name) const
Determine if a name (possibly hierarchical) is a subproperty.
virtual void remove(std::string const &name)
Remove all values for a property name (possibly hierarchical).
virtual ~PropertySet(void)
Destructor.
std::vector< std::string > paramNames(bool topLevelOnly=true) const
A variant of names that excludes the names of subproperties.
PropertySet(bool flat=false)
Construct an empty PropertySet.
void set(std::string const &name, T const &value)
Replace all values for a property name (possibly hierarchical) with a new scalar value.
STL class.
bool isArray(std::string const &name) const
Determine if a name (possibly hierarchical) has multiple values.
T push_back(T... args)
std::shared_ptr< PropertyList const > ConstPtr
Definition: PropertyList.h:76
std::shared_ptr< PropertyList > Ptr
Definition: PropertyList.h:75
void add(std::string const &name, T const &value)
Append a single value to the vector of values for a property name (possibly hierarchical).
int64_t getAsInt64(std::string const &name) const
Get the last value for a bool/char/short/int/int64_t property name (possibly hierarchical).
size_t nameCount(bool topLevelOnly=true) const
Get the number of names in the PropertySet, optionally including those in subproperties.
T str(T... args)
bool exists(std::string const &name) const
Determine if a name (possibly hierarchical) exists.
T showpoint(T... args)
virtual void _set(std::string const &name, std::shared_ptr< std::vector< boost::any > > vp)
Interface for DateTime class.
Persistable::Ptr getAsPersistablePtr(std::string const &name) const
Get the last value for a Persistable name (possibly hierarchical).
T find(T... args)
T size(T... args)
#define LSST_EXCEPT(type,...)
STL class.
virtual void _add(std::string const &name, std::shared_ptr< std::vector< boost::any > > vp)
T begin(T... args)
T back(T... args)
std::shared_ptr< Persistable > Ptr
Definition: Persistable.h:75
T sort(T... args)
std::string getAsString(std::string const &name) const
Get the last value for a string property name (possibly hierarchical).
std::vector< std::string > names(bool topLevelOnly=true) const
Get the names in the PropertySet, optionally including those in subproperties.
void add(std::string const &name, T const &value)
Append a single value to the vector of values for a property name (possibly hierarchical).
T reserve(T... args)
std::type_info const & typeOf(std::string const &name) const
Get the type of values for a property name (possibly hierarchical).