LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Policy.h
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 details.
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 
25 #ifndef LSST_PEX_POLICY_POLICY_H
26 #define LSST_PEX_POLICY_POLICY_H
27 
28 #include <string>
29 #include <vector>
30 #include <list>
31 #include <map>
32 
33 #include <boost/shared_ptr.hpp>
34 #include <boost/filesystem/path.hpp>
35 #include <boost/filesystem/operations.hpp>
36 
37 #include "lsst/daf/base/Citizen.h"
41 
42 namespace lsst {
43 namespace pex {
44 namespace policy {
45 
46 // forward declaration
47 class PolicySource;
48 class PolicyFile;
49 class Dictionary;
50 class ValidationError;
51 
52 #define POL_GETSCALAR(name, type, vtype) \
53  try { \
54  return _data->get<type>(name); \
55  } catch (lsst::pex::exceptions::NotFoundError&) { \
56  throw LSST_EXCEPT(NameNotFound, name); \
57  } catch (lsst::pex::exceptions::TypeError&) { \
58  throw LSST_EXCEPT(TypeError, name, std::string(typeName[vtype])); \
59  } catch (boost::bad_any_cast&) { \
60  throw LSST_EXCEPT(TypeError, name, std::string(typeName[vtype])); \
61  }
62 
63 #define POL_GETLIST(name, type, vtype) \
64  try { \
65  return _data->getArray<type>(name); \
66  } catch (lsst::pex::exceptions::NotFoundError&) { \
67  throw LSST_EXCEPT(NameNotFound, name); \
68  } catch (lsst::pex::exceptions::TypeError&) { \
69  throw LSST_EXCEPT(TypeError, name, std::string(typeName[vtype])); \
70  } catch (boost::bad_any_cast&) { \
71  throw LSST_EXCEPT(TypeError, name, std::string(typeName[vtype])); \
72  }
73 
74 
170 public:
171 
172  typedef boost::shared_ptr<Policy> Ptr;
173  typedef boost::shared_ptr<const Policy> ConstPtr;
174  typedef boost::shared_ptr<Dictionary> DictPtr;
175  typedef boost::shared_ptr<const Dictionary> ConstDictPtr;
176  typedef boost::shared_ptr<PolicyFile> FilePtr;
177 
178  typedef std::vector<bool> BoolArray;
179  typedef std::vector<int> IntArray;
180  typedef std::vector<double> DoubleArray;
181  typedef std::vector<std::string> StringArray;
182  typedef std::vector<Ptr> PolicyPtrArray;
183  typedef std::vector<FilePtr> FilePtrArray;
184  typedef std::vector<ConstPtr> ConstPolicyPtrArray;
185 
189  enum ValueType {
198  };
199 
205  static const char * const typeName[];
206 
210  Policy();
211 
213 
219  explicit Policy(const std::string& pathOrUrn);
220  explicit Policy(const char *pathOrUrn);
222 
227  explicit Policy(const PolicySource& source);
228 
242  Policy(bool validate, const Dictionary& dict,
243  const boost::filesystem::path& repository="");
244 
251  Policy(Policy& pol, bool deep=false);
252 
256  Policy(const Policy& pol);
257 
259 
274  static Policy *createPolicy(PolicySource& input, bool doIncludes=true,
275  bool validate=true);
276  static Policy *createPolicy(const std::string& input, bool doIncludes=true,
277  bool validate=true);
279 
294  static Policy *createPolicyFromUrn(const std::string& urn,
295  bool validate=true);
296 
298 
312  static Policy *createPolicy(PolicySource& input,
313  const boost::filesystem::path& repos,
314  bool validate=true);
315  static Policy *createPolicy(PolicySource& input, const std::string& repos,
316  bool validate=true);
317  static Policy *createPolicy(PolicySource& input, const char *repos,
318  bool validate=true);
319  static Policy *createPolicy(const std::string& input,
320  const boost::filesystem::path& repos,
321  bool validate=true);
322  static Policy *createPolicy(const std::string& input,
323  const std::string& repos, bool validate=true);
324  static Policy *createPolicy(const std::string& input, const char *repos,
325  bool validate=true);
327 
336  static FilePtr createPolicyFile(const std::string& pathOrUrn, bool strict=false);
337 
344  template <typename T> static ValueType getValueType();
345 
351  static ValueType getTypeByName(const std::string& name);
352  // throw(BadNameError) // swig doesn't like this
353 
357  virtual ~Policy();
358 
362  int nameCount() const {
363  return _data->nameCount();
364  }
365 
367 
383  int names(std::list<std::string>& names,
384  bool topLevelOnly=false,
385  bool append=false) const; // inlined below
386  int paramNames(std::list<std::string>& names,
387  bool topLevelOnly=false,
388  bool append=false) const; // inlined below
389  int policyNames(std::list<std::string>& names,
390  bool topLevelOnly=false,
391  bool append=false) const; // inlined below
392  int fileNames(std::list<std::string>& names,
393  bool topLevelOnly=false,
394  bool append=false) const; // inlined below
396 
398 
409  StringArray names(bool topLevelOnly=false) const; // inlined below
410  StringArray paramNames(bool topLevelOnly=false) const; // inlined below
411  StringArray policyNames(bool topLevelOnly=false) const; // inlined below
412  StringArray fileNames(bool topLevelOnly=false) const; // inlined below
414 
419  bool isDictionary() const { return exists("definitions"); }
420 
426  bool canValidate() const;
427 
432  const ConstDictPtr getDictionary() const;
433 
439  void setDictionary(const Dictionary& dict);
440 
451  void validate(ValidationError *errs=0) const;
452 
458  size_t valueCount(const std::string& name) const; // inlined below
459 
467  bool isArray(const std::string& name) const; // inlined below
468 
476  bool exists(const std::string& name) const; // inlined below
477 
481  bool isBool(const std::string& name) const; // inlined below
482 
486  bool isInt(const std::string& name) const; // inlined below
487 
491  bool isDouble(const std::string& name) const; // inlined below
492 
496  bool isString(const std::string& name) const; // inlined below
497 
501  bool isPolicy(const std::string& name) const; // inlined below
502 
506  bool isFile(const std::string& name) const; // inlined below
507 
513  const std::type_info& getTypeInfo(const std::string& name) const; //inlined
514 
520  const std::type_info& typeOf(const std::string& name) const; // inlined
521 
527  ValueType getValueType(const std::string& name) const;
528 
534  const char *getTypeName(const std::string& name) const {
535  try { return typeName[getValueType(name)]; }
536  catch (NameNotFound&) { return typeName[UNDEF]; }
537  }
538 
545  template <typename T> T getValue(const std::string& name) const;
546 
553  template <typename T> std::vector<T> getValueArray(const std::string& name) const;
554 
556 
564  ConstPtr getPolicy(const std::string& name) const; // inlined below
565  Ptr getPolicy(const std::string& name); // inlined below
567 
577  FilePtr getFile(const std::string& name) const;
578 
589  bool getBool(const std::string& name) const {
590  POL_GETSCALAR(name, bool, BOOL)
591  }
592 
603  int getInt(const std::string& name) const {
604  POL_GETSCALAR(name, int, INT)
605  }
606 
617  double getDouble(const std::string& name) const {
618  POL_GETSCALAR(name, double, DOUBLE)
619  }
620 
631  const std::string getString(const std::string& name) const {
632  POL_GETSCALAR(name, std::string, STRING)
633  }
634 
636 
648  PolicyPtrArray getPolicyArray(const std::string& name) const;
649  ConstPolicyPtrArray getConstPolicyArray(const std::string& name) const;
651 
665  FilePtrArray getFileArray(const std::string& name) const;
666 
668 
676  BoolArray getBoolArray(const std::string& name) const; // inlined
677  IntArray getIntArray(const std::string& name) const; // inlined
678  DoubleArray getDoubleArray(const std::string& name) const; // inlined
679  StringArray getStringArray(const std::string& name) const; //inlined
681 
683 
708  template <typename T> void setValue(const std::string& name, const T& value);
709  void set(const std::string& name, const Ptr& value); // inlined below
710  void set(const std::string& name, const FilePtr& value); // inlined below
711  void set(const std::string& name, bool value); // inlined below
712  void set(const std::string& name, int value); // inlined below
713  void set(const std::string& name, double value); // inlined below
714  void set(const std::string& name, const std::string& value); // inlined
715  void set(const std::string& name, const char *value); // inlined below
717 
719 
744  // avoid name confusion with appended T
745  template <typename T> void addValue(const std::string& name, const T& value);
746  void add(const std::string& name, const Ptr& value); // inlined below
747  void add(const std::string& name, const FilePtr& value); // inlined below
748  void add(const std::string& name, bool value); // inlined below
749  void add(const std::string& name, int value); // inlined below
750  void add(const std::string& name, double value); // inlined below
751  void add(const std::string& name, const std::string& value); // inlined
752  void add(const std::string& name, const char *value); // inlined below
754 
760  void remove(const std::string& name); // inlined below
761 
775  int loadPolicyFiles(bool strict=true) {
776  return loadPolicyFiles(boost::filesystem::path(), strict);
777  }
778 
786  virtual int loadPolicyFiles(const boost::filesystem::path& repository,
787  bool strict=true);
788 
810  int mergeDefaults(const Policy& defaultPol, bool keepForValidation=true,
811  ValidationError *errs=0);
812 
821  virtual std::string str(const std::string& name,
822  const std::string& indent="") const;
823 
831  virtual void print(std::ostream& out, const std::string& label="Policy",
832  const std::string& indent="") const;
833 
838  std::string toString() const;
839 
845 
846 protected:
851  : Citizen(typeid(this)), lsst::daf::base::Persistable(), _data(ps)
852  { }
853 
854 private:
856 
858 
859  int _names(std::list<std::string>& names, bool topLevelOnly=false,
860  bool append=false, int want=3) const;
861  int _names(std::vector<std::string>& names, bool topLevelOnly=false,
862  bool append=false, int want=3) const;
863 
868  template <typename T>
869  void _validate(const std::string& name, const T& value, int curCount=0);
870 
871  std::vector<lsst::daf::base::Persistable::Ptr>
872  _getPersistList(const std::string& name) const
873  {
874  POL_GETLIST(name, Persistable::Ptr, FILE)
875  }
876  std::vector<lsst::daf::base::PropertySet::Ptr>
877  _getPropSetList(const std::string& name) const
878  {
880  }
881 
882  static Policy *_createPolicy(PolicySource& input, bool doIncludes,
883  const boost::filesystem::path& repos,
884  bool validate);
885  static Policy *_createPolicy(const std::string& input, bool doIncludes,
886  const boost::filesystem::path& repos,
887  bool validate);
888 };
889 
890 inline std::ostream& operator<<(std::ostream& os, const Policy& p) {
891  p.print(os);
892  return os;
893 }
894 
895 /* ************** Inline Class functions ******************** */
896 
897 inline int Policy::names(std::list<std::string>& names, bool topLevelOnly,
898  bool append) const
899 {
900  return _names(names, topLevelOnly, append, 7);
901 }
902 inline int Policy::paramNames(std::list<std::string>& names, bool topLevelOnly,
903  bool append) const
904 {
905  return _names(names, topLevelOnly, append, 4);
906 }
907 inline int Policy::policyNames(std::list<std::string>& names,
908  bool topLevelOnly,
909  bool append) const
910 {
911  return _names(names, topLevelOnly, append, 1);
912 }
913 inline int Policy::fileNames(std::list<std::string>& names, bool topLevelOnly,
914  bool append) const
915 {
916  return _names(names, topLevelOnly, append, 2);
917 }
918 
919 inline Policy::StringArray Policy::names(bool topLevelOnly) const {
920  return _data->names();
921 }
922 inline Policy::StringArray Policy::paramNames(bool topLevelOnly) const {
923  StringArray out;
924  _names(out, topLevelOnly, true, 4);
925  return out;
926 }
927 inline Policy::StringArray Policy::policyNames(bool topLevelOnly) const {
928  return _data->propertySetNames(topLevelOnly);
929 }
930 inline Policy::StringArray Policy::fileNames(bool topLevelOnly) const {
931  StringArray out;
932  _names(out, topLevelOnly, true, 2);
933  return out;
934 }
935 
936 inline size_t Policy::valueCount(const std::string& name) const {
937  return _data->valueCount(name);
938 }
939 
940 inline bool Policy::isArray(const std::string& name) const {
941  return _data->isArray(name);
942 }
943 
944 inline bool Policy::exists(const std::string& name) const {
945  return _data->exists(name);
946 }
947 
948 inline bool Policy::isBool(const std::string& name) const {
949  try {
950  return (_data->typeOf(name) == typeid(bool));
951  }
952  catch (...) {
953  return false;
954  }
955 }
956 
957 inline bool Policy::isInt(const std::string& name) const {
958  try {
959  return (_data->typeOf(name) == typeid(int));
960  }
961  catch (...) {
962  return false;
963  }
964 }
965 
966 inline bool Policy::isDouble(const std::string& name) const {
967  try {
968  return (_data->typeOf(name) == typeid(double));
969  }
970  catch (...) {
971  return false;
972  }
973 }
974 
975 inline bool Policy::isString(const std::string& name) const {
976  try {
977  return (_data->typeOf(name) == typeid(std::string));
978  }
979  catch (...) {
980  return false;
981  }
982 }
983 
984 inline bool Policy::isPolicy(const std::string& name) const {
985  try {
986  return (_data->typeOf(name) == typeid(lsst::daf::base::PropertySet::Ptr));
987  }
988  catch (...) {
989  return false;
990  }
991 }
992 
993 inline bool Policy::isFile(const std::string& name) const {
994 
995  try {
996  return (getValueType(name) == FILE);
997  }
998  catch (...) {
999  return false;
1000  }
1001 }
1002 
1003 inline const std::type_info& Policy::getTypeInfo(const std::string& name) const
1004 {
1005  try { return _data->typeOf(name); }
1006  catch (lsst::pex::exceptions::NotFoundError& e) {
1007  throw LSST_EXCEPT(NameNotFound, name);
1008  }
1009 }
1010 
1011 inline const std::type_info& Policy::typeOf(const std::string& name) const {
1012  return getTypeInfo(name);
1013 }
1014 
1015 inline Policy::ConstPtr Policy::getPolicy(const std::string& name) const {
1016  return ConstPtr(new Policy(_data->get<lsst::daf::base::PropertySet::Ptr>(name)));
1017 }
1018 inline Policy::Ptr Policy::getPolicy(const std::string& name) {
1019  return Ptr(new Policy(_data->get<lsst::daf::base::PropertySet::Ptr>(name)));
1020 }
1021 
1022 inline
1024  return _data->getArray<std::string>(name);
1025 }
1026 
1027 inline Policy::BoolArray Policy::getBoolArray(const std::string& name) const {
1028  POL_GETLIST(name, bool, BOOL)
1029 }
1030 
1031 inline Policy::IntArray Policy::getIntArray(const std::string& name) const {
1032  POL_GETLIST(name, int, INT)
1033 }
1034 
1035 inline
1037  POL_GETLIST(name, double, DOUBLE)
1038 }
1039 
1040 inline void Policy::set(const std::string& name, const Ptr& value) {
1041  _validate(name, value);
1042  _data->set(name, value->asPropertySet());
1043 }
1044 inline void Policy::set(const std::string& name, bool value) {
1045  _validate(name, value);
1046  _data->set(name, value);
1047 }
1048 inline void Policy::set(const std::string& name, int value) {
1049  _validate(name, value);
1050  _data->set(name, value);
1051 }
1052 inline void Policy::set(const std::string& name, double value) {
1053  _validate(name, value);
1054  _data->set(name, value);
1055 }
1056 inline void Policy::set(const std::string& name, const std::string& value) {
1057  _validate(name, value);
1058  _data->set(name, value);
1059 }
1060 inline void Policy::set(const std::string& name, const char *value) {
1061  if (value == NULL)
1062  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
1063  std::string("Attempted to assign NULL value to ")
1064  + name + ".");
1065  _validate(name, std::string(value));
1066  _data->set(name, std::string(value));
1067 }
1068 
1069 #define POL_ADD(name, value) \
1070  try { _data->add(name, value); } \
1071  catch(lsst::pex::exceptions::TypeError&) { \
1072  throw LSST_EXCEPT(TypeError, name, getTypeName(name)); \
1073  }
1074 
1075 inline void Policy::add(const std::string& name, const Ptr& value) {
1076  _validate(name, value, valueCount(name));
1077  POL_ADD(name, value->asPropertySet())
1078 }
1079 inline void Policy::add(const std::string& name, bool value) {
1080  _validate(name, value, valueCount(name));
1081  POL_ADD(name, value);
1082 }
1083 inline void Policy::add(const std::string& name, int value) {
1084  _validate(name, value, valueCount(name));
1085  POL_ADD(name, value);
1086 }
1087 inline void Policy::add(const std::string& name, double value) {
1088  _validate(name, value, valueCount(name));
1089  POL_ADD(name, value);
1090 }
1091 inline void Policy::add(const std::string& name, const std::string& value) {
1092  _validate(name, value, valueCount(name));
1093  POL_ADD(name, value);
1094 }
1095 inline void Policy::add(const std::string& name, const char *value) {
1096  std::string v(value);
1097  _validate(name, v, valueCount(name));
1098  POL_ADD(name, v);
1099 }
1100 
1101 // TODO: validate if required value?
1102 inline void Policy::remove(const std::string& name) {
1103  _data->remove(name);
1104 }
1105 
1106 inline Policy* Policy::createPolicy(PolicySource& input, bool doIncludes,
1107  bool validate)
1108 {
1109  return _createPolicy(input, doIncludes, boost::filesystem::path(), validate);
1110 }
1111 
1112 inline Policy* Policy::createPolicy(const std::string& input, bool doIncludes,
1113  bool validate)
1114 {
1115  return _createPolicy(input, doIncludes, boost::filesystem::path(), validate);
1116 }
1117 
1119  const boost::filesystem::path& repository,
1120  bool validate)
1121 {
1122  return _createPolicy(input, true, repository, validate);
1123 }
1124 
1126  const std::string& repository,
1127  bool validate)
1128 {
1129  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1130 }
1131 
1133  const char *repository,
1134  bool validate)
1135 {
1136  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1137 }
1138 
1139 inline Policy* Policy::createPolicy(const std::string& input,
1140  const boost::filesystem::path& repository,
1141  bool validate)
1142 {
1143  return _createPolicy(input, true, repository, validate);
1144 }
1145 
1146 inline Policy* Policy::createPolicy(const std::string& input,
1147  const std::string& repository,
1148  bool validate)
1149 {
1150  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1151 }
1152 
1153 inline Policy* Policy::createPolicy(const std::string& input,
1154  const char *repository,
1155  bool validate)
1156 {
1157  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1158 }
1159 
1161 
1162 // general case is disallowed; known types are specialized
1163 template <typename T> T Policy::getValue(const std::string& name) const {
1164  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1165 }
1166 template <> bool Policy::getValue<bool>(const std::string& name) const;
1167 template <> int Policy::getValue<int>(const std::string& name) const;
1168 template <> double Policy::getValue<double>(const std::string& name) const;
1169 template <> std::string Policy::getValue<std::string>(const std::string& name) const;
1170 template <> Policy::FilePtr Policy::getValue<Policy::FilePtr>(const std::string& name) const;
1171 template <> Policy::ConstPtr Policy::getValue<Policy::ConstPtr>(const std::string& name) const;
1172 
1173 // general case is disallowed; known types are specialized
1174 template <typename T> std::vector<T> Policy::getValueArray(const std::string& name) const {
1175  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1176 }
1177 template <> std::vector<bool> Policy::getValueArray<bool>(const std::string& name) const;
1178 template <> std::vector<int> Policy::getValueArray<int>(const std::string& name) const;
1179 template <> std::vector<double> Policy::getValueArray<double>(const std::string& name) const;
1180 template <> std::vector<std::string> Policy::getValueArray<std::string>(const std::string& name) const;
1181 template <> Policy::FilePtrArray Policy::getValueArray<Policy::FilePtr>(const std::string& name) const;
1182 template <> Policy::PolicyPtrArray Policy::getValueArray<Policy::Ptr>(const std::string& name) const;
1183 template <> Policy::ConstPolicyPtrArray Policy::getValueArray<Policy::ConstPtr>(const std::string& name) const;
1184 
1185 // general case is disallowed; known types are specialized
1186 template <typename T> Policy::ValueType Policy::getValueType() {
1187  throw LSST_EXCEPT(TypeError, "unknown", "not implemented for this type");
1188 }
1189 template <> Policy::ValueType Policy::getValueType<bool>();
1190 template <> Policy::ValueType Policy::getValueType<int>();
1191 template <> Policy::ValueType Policy::getValueType<double>();
1192 template <> Policy::ValueType Policy::getValueType<std::string>();
1193 template <> Policy::ValueType Policy::getValueType<Policy>();
1194 template <> Policy::ValueType Policy::getValueType<Policy::FilePtr>();
1195 template <> Policy::ValueType Policy::getValueType<Policy::Ptr>();
1196 template <> Policy::ValueType Policy::getValueType<Policy::ConstPtr>();
1197 
1198 // general case is disallowed; known types are specialized
1199 template <typename T> void Policy::setValue(const std::string& name, const T& value) {
1200  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1201 }
1202 template <> void Policy::setValue<bool>(const std::string& name, const bool& value);
1203 template <> void Policy::setValue<int>(const std::string& name, const int& value);
1204 template <> void Policy::setValue<double>(const std::string& name, const double& value);
1205 template <> void Policy::setValue<std::string>(const std::string& name, const std::string& value);
1206 template <> void Policy::setValue<Policy::Ptr>(const std::string& name, const Policy::Ptr& value);
1207 template <> void Policy::setValue<Policy::FilePtr>(const std::string& name, const Policy::FilePtr& value);
1208 
1209 // general case is disallowed; known types are specialized
1210 template <typename T> void Policy::addValue(const std::string& name, const T& value) {
1211  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1212 }
1213 template <> void Policy::addValue<bool>(const std::string& name, const bool& value);
1214 template <> void Policy::addValue<int>(const std::string& name, const int& value);
1215 template <> void Policy::addValue<double>(const std::string& name, const double& value);
1216 template <> void Policy::addValue<std::string>(const std::string& name, const std::string& value);
1217 template <> void Policy::addValue<Policy::Ptr>(const std::string& name, const Policy::Ptr& value);
1218 template <> void Policy::addValue<Policy::FilePtr>(const std::string& name, const Policy::FilePtr& value);
1219 
1220 }}} // end namespace lsst::pex::policy
1221 
1222 #endif // LSST_PEX_POLICY_POLICY_H
bool isDictionary() const
Definition: Policy.h:419
std::vector< int > IntArray
Definition: Policy.h:179
int getInt(const std::string &name) const
Definition: Policy.h:603
void set(const std::string &name, const Ptr &value)
Definition: Policy.h:1040
size_t valueCount(const std::string &name) const
Definition: Policy.h:936
bool isDouble(const std::string &name) const
Definition: Policy.h:966
std::vector< Ptr > PolicyPtrArray
Definition: Policy.h:182
bool exists(const std::string &name) const
Definition: Policy.h:944
ConstPolicyPtrArray getConstPolicyArray(const std::string &name) const
static Policy * createPolicyFromUrn(const std::string &urn, bool validate=true)
int _names(std::list< std::string > &names, bool topLevelOnly=false, bool append=false, int want=3) const
table::Key< std::string > name
Definition: ApCorrMap.cc:71
static Policy * createPolicy(PolicySource &input, bool doIncludes=true, bool validate=true)
Definition: Policy.h:1106
boost::shared_ptr< PolicyFile > FilePtr
Definition: Policy.h:176
bool isInt(const std::string &name) const
Definition: Policy.h:957
PolicyPtrArray getPolicyArray(const std::string &name) const
#define POL_ADD(name, value)
Definition: Policy.h:1069
std::vector< T > getValueArray(const std::string &name) const
Definition: Policy.h:1174
definition of Policy-specific exceptions classes
boost::shared_ptr< const Policy > ConstPtr
Definition: Policy.h:173
lsst::daf::base::PropertySet::Ptr asPropertySet()
Definition: Policy.h:1160
bool getBool(const std::string &name) const
Definition: Policy.h:589
a container for holding hierarchical configuration data in memory.
Definition: Policy.h:169
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
boost::shared_ptr< Policy > Ptr
Definition: Policy.h:172
virtual std::string str(const std::string &name, const std::string &indent="") const
const std::string getString(const std::string &name) const
Definition: Policy.h:631
StringArray getStringArray(const std::string &name) const
Definition: Policy.h:1023
const std::type_info & getTypeInfo(const std::string &name) const
Definition: Policy.h:1003
bool isBool(const std::string &name) const
Definition: Policy.h:948
boost::shared_ptr< Dictionary > DictPtr
Definition: Policy.h:174
void setDictionary(const Dictionary &dict)
virtual void print(std::ostream &out, const std::string &label="Policy", const std::string &indent="") const
std::vector< lsst::daf::base::Persistable::Ptr > _getPersistList(const std::string &name) const
Definition: Policy.h:872
static const char *const typeName[]
Definition: Policy.h:205
FilePtr getFile(const std::string &name) const
std::ostream & operator<<(std::ostream &os, const Policy &p)
Definition: Policy.h:890
int nameCount() const
Definition: Policy.h:362
an abstract class representing a source of serialized Policy parameter data. This might be a file or ...
Definition: PolicySource.h:53
static FilePtr createPolicyFile(const std::string &pathOrUrn, bool strict=false)
const ConstDictPtr getDictionary() const
std::vector< std::string > StringArray
Definition: Policy.h:181
#define POL_GETSCALAR(name, type, vtype)
Definition: Policy.h:52
void _validate(const std::string &name, const T &value, int curCount=0)
void addValue(const std::string &name, const T &value)
Definition: Policy.h:1210
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
FilePtrArray getFileArray(const std::string &name) const
static Policy * _createPolicy(PolicySource &input, bool doIncludes, const boost::filesystem::path &repos, bool validate)
void setValue(const std::string &name, const T &value)
Definition: Policy.h:1199
int mergeDefaults(const Policy &defaultPol, bool keepForValidation=true, ValidationError *errs=0)
bool isString(const std::string &name) const
Definition: Policy.h:975
Policy(const lsst::daf::base::PropertySet::Ptr ps)
Definition: Policy.h:850
#define POL_GETLIST(name, type, vtype)
Definition: Policy.h:63
std::string toString() const
Interface for Persistable base class.
int fileNames(std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const
Definition: Policy.h:913
bool isPolicy(const std::string &name) const
Definition: Policy.h:984
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
std::vector< FilePtr > FilePtrArray
Definition: Policy.h:183
bool isArray(const std::string &name) const
Definition: Policy.h:940
BoolArray getBoolArray(const std::string &name) const
Definition: Policy.h:1027
double getDouble(const std::string &name) const
Definition: Policy.h:617
std::vector< double > DoubleArray
Definition: Policy.h:180
Citizen(const std::type_info &)
Definition: Citizen.cc:173
DoubleArray getDoubleArray(const std::string &name) const
Definition: Policy.h:1036
void remove(const std::string &name)
Definition: Policy.h:1102
int names(std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const
Definition: Policy.h:897
bool isFile(const std::string &name) const
Definition: Policy.h:993
void validate(ValidationError *errs=0) const
const std::type_info & typeOf(const std::string &name) const
Definition: Policy.h:1011
static ValueType getTypeByName(const std::string &name)
static ValueType getValueType()
Definition: Policy.h:1186
const char * getTypeName(const std::string &name) const
Definition: Policy.h:534
boost::shared_ptr< const Dictionary > ConstDictPtr
Definition: Policy.h:175
Interface for PropertySet class.
Base class for all persistable classes.
Definition: Persistable.h:74
T getValue(const std::string &name) const
Definition: Policy.h:1163
int loadPolicyFiles(bool strict=true)
Definition: Policy.h:775
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
Definition: Citizen.h:56
ConstPtr getPolicy(const std::string &name) const
Definition: Policy.h:1015
int paramNames(std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const
Definition: Policy.h:902
std::vector< bool > BoolArray
Definition: Policy.h:178
int policyNames(std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const
Definition: Policy.h:907
void add(const std::string &name, const Ptr &value)
Definition: Policy.h:1075
std::vector< lsst::daf::base::PropertySet::Ptr > _getPropSetList(const std::string &name) const
Definition: Policy.h:877
std::vector< ConstPtr > ConstPolicyPtrArray
Definition: Policy.h:184
IntArray getIntArray(const std::string &name) const
Definition: Policy.h:1031