LSSTApplications  20.0.0
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 <memory>
34 #include <boost/filesystem/path.hpp>
35 #include <boost/filesystem/operations.hpp>
36 
40 
41 namespace lsst {
42 namespace pex {
43 namespace policy {
44 
45 // forward declaration
46 class PolicySource;
47 class PolicyFile;
48 class Dictionary;
49 class ValidationError;
50 
51 #define POL_GETSCALAR(name, type, vtype) \
52  try { \
53  return _data->get<type>(name); \
54  } catch (lsst::pex::exceptions::NotFoundError&) { \
55  throw LSST_EXCEPT(NameNotFound, name); \
56  } catch (lsst::pex::exceptions::TypeError&) { \
57  throw LSST_EXCEPT(TypeError, name, std::string(typeName[vtype])); \
58  } catch (boost::bad_any_cast&) { \
59  throw LSST_EXCEPT(TypeError, name, std::string(typeName[vtype])); \
60  }
61 
62 #define POL_GETLIST(name, type, vtype) \
63  try { \
64  return _data->getArray<type>(name); \
65  } catch (lsst::pex::exceptions::NotFoundError&) { \
66  throw LSST_EXCEPT(NameNotFound, name); \
67  } catch (lsst::pex::exceptions::TypeError&) { \
68  throw LSST_EXCEPT(TypeError, name, std::string(typeName[vtype])); \
69  } catch (boost::bad_any_cast&) { \
70  throw LSST_EXCEPT(TypeError, name, std::string(typeName[vtype])); \
71  }
72 
168 public:
174 
182 
187 
193  static const char* const typeName[];
194 
199 
201 
207  explicit Policy(const std::string& pathOrUrn);
208  explicit Policy(const char* pathOrUrn);
210 
215  explicit Policy(const PolicySource& source);
216 
230  Policy(bool validate, const Dictionary& dict, const boost::filesystem::path& repository = "");
231 
238  Policy(Policy& pol, bool deep = false);
239 
243  Policy(const Policy& pol);
244 
246 
261  static Policy* createPolicy(PolicySource& input, bool doIncludes = true, bool validate = true);
262  static Policy* createPolicy(const std::string& input, bool doIncludes = true, bool validate = true);
264 
279  static Policy* createPolicyFromUrn(const std::string& urn, bool validate = true);
280 
282 
296  static Policy* createPolicy(PolicySource& input, const boost::filesystem::path& repos,
297  bool validate = true);
298  static Policy* createPolicy(PolicySource& input, const std::string& repos, bool validate = true);
299  static Policy* createPolicy(PolicySource& input, const char* repos, bool validate = true);
300  static Policy* createPolicy(const std::string& input, const boost::filesystem::path& repos,
301  bool validate = true);
302  static Policy* createPolicy(const std::string& input, const std::string& repos, bool validate = true);
303  static Policy* createPolicy(const std::string& input, const char* repos, bool validate = true);
305 
314  static FilePtr createPolicyFile(const std::string& pathOrUrn, bool strict = false);
315 
322  template <typename T>
323  static ValueType getValueType();
324 
331  // throw(BadNameError) // swig doesn't like this
332 
336  virtual ~Policy();
337 
341  int nameCount() const { return _data->nameCount(); }
342 
344 
360  int names(std::list<std::string>& names, bool topLevelOnly = false,
361  bool append = false) const; // inlined below
362  int paramNames(std::list<std::string>& names, bool topLevelOnly = false,
363  bool append = false) const; // inlined below
364  int policyNames(std::list<std::string>& names, bool topLevelOnly = false,
365  bool append = false) const; // inlined below
366  int fileNames(std::list<std::string>& names, bool topLevelOnly = false,
367  bool append = false) const; // inlined below
369 
371 
382  StringArray names(bool topLevelOnly = false) const; // inlined below
383  StringArray paramNames(bool topLevelOnly = false) const; // inlined below
384  StringArray policyNames(bool topLevelOnly = false) const; // inlined below
385  StringArray fileNames(bool topLevelOnly = false) const; // inlined below
387 
392  bool isDictionary() const { return exists("definitions"); }
393 
399  bool canValidate() const;
400 
406 
412  void setDictionary(const Dictionary& dict);
413 
424  void validate(ValidationError* errs = 0) const;
425 
431  size_t valueCount(const std::string& name) const; // inlined below
432 
440  bool isArray(const std::string& name) const; // inlined below
441 
449  bool exists(const std::string& name) const; // inlined below
450 
454  bool isBool(const std::string& name) const; // inlined below
455 
459  bool isInt(const std::string& name) const; // inlined below
460 
464  bool isDouble(const std::string& name) const; // inlined below
465 
469  bool isString(const std::string& name) const; // inlined below
470 
474  bool isPolicy(const std::string& name) const; // inlined below
475 
479  bool isFile(const std::string& name) const; // inlined below
480 
486  const std::type_info& getTypeInfo(const std::string& name) const; // inlined
487 
493  const std::type_info& typeOf(const std::string& name) const; // inlined
494 
501 
507  const char* getTypeName(const std::string& name) const {
508  try {
509  return typeName[getValueType(name)];
510  } catch (NameNotFound&) {
511  return typeName[UNDEF];
512  }
513  }
514 
521  template <typename T>
522  T getValue(const std::string& name) const;
523 
530  template <typename T>
532 
534 
542  ConstPtr getPolicy(const std::string& name) const; // inlined below
543  Ptr getPolicy(const std::string& name); // inlined below
545 
556 
567  bool getBool(const std::string& name) const { POL_GETSCALAR(name, bool, BOOL) }
568 
579  int getInt(const std::string& name) const { POL_GETSCALAR(name, int, INT) }
580 
591  double getDouble(const std::string& name) const { POL_GETSCALAR(name, double, DOUBLE) }
592 
604 
606 
621 
636 
638 
646  BoolArray getBoolArray(const std::string& name) const; // inlined
647  IntArray getIntArray(const std::string& name) const; // inlined
648  DoubleArray getDoubleArray(const std::string& name) const; // inlined
649  StringArray getStringArray(const std::string& name) const; // inlined
651 
653 
678  template <typename T>
679  void setValue(const std::string& name, const T& value);
680  void set(const std::string& name, const Ptr& value); // inlined below
681  void set(const std::string& name, const FilePtr& value); // inlined below
682  void set(const std::string& name, bool value); // inlined below
683  void set(const std::string& name, int value); // inlined below
684  void set(const std::string& name, double value); // inlined below
685  void set(const std::string& name, const std::string& value); // inlined
686  void set(const std::string& name, const char* value); // inlined below
688 
690 
715  // avoid name confusion with appended T
716  template <typename T>
717  void addValue(const std::string& name, const T& value);
718  void add(const std::string& name, const Ptr& value); // inlined below
719  void add(const std::string& name, const FilePtr& value); // inlined below
720  void add(const std::string& name, bool value); // inlined below
721  void add(const std::string& name, int value); // inlined below
722  void add(const std::string& name, double value); // inlined below
723  void add(const std::string& name, const std::string& value); // inlined
724  void add(const std::string& name, const char* value); // inlined below
726 
732  void remove(const std::string& name); // inlined below
733 
747  int loadPolicyFiles(bool strict = true) { return loadPolicyFiles(boost::filesystem::path(), strict); }
748 
756  virtual int loadPolicyFiles(const boost::filesystem::path& repository, bool strict = true);
757 
779  int mergeDefaults(const Policy& defaultPol, bool keepForValidation = true, ValidationError* errs = 0);
780 
789  virtual std::string str(const std::string& name, const std::string& indent = "") const;
790 
798  virtual void print(std::ostream& out, const std::string& label = "Policy",
799  const std::string& indent = "") const;
800 
806 
812 
813 protected:
817  Policy(const lsst::daf::base::PropertySet::Ptr ps) : lsst::daf::base::Persistable(), _data(ps) {}
818 
819 private:
821 
822  DictPtr _dictionary;
823 
824  int _names(std::list<std::string>& names, bool topLevelOnly = false, bool append = false,
825  int want = 3) const;
826  int _names(std::vector<std::string>& names, bool topLevelOnly = false, bool append = false,
827  int want = 3) const;
828 
833  template <typename T>
834  void _validate(const std::string& name, const T& value, int curCount = 0);
835 
837  const {POL_GETLIST(name, Persistable::Ptr, FILE)} std::vector<
838  lsst::daf::base::PropertySet::Ptr> _getPropSetList(const std::string& name) const {
840  }
841 
842  static Policy* _createPolicy(PolicySource& input, bool doIncludes, const boost::filesystem::path& repos,
843  bool validate);
844  static Policy* _createPolicy(const std::string& input, bool doIncludes,
845  const boost::filesystem::path& repos, bool validate);
846 };
847 
849  p.print(os);
850  return os;
851 }
852 
853 /* ************** Inline Class functions ******************** */
854 
855 inline int Policy::names(std::list<std::string>& names, bool topLevelOnly, bool append) const {
856  return _names(names, topLevelOnly, append, 7);
857 }
858 inline int Policy::paramNames(std::list<std::string>& names, bool topLevelOnly, bool append) const {
859  return _names(names, topLevelOnly, append, 4);
860 }
861 inline int Policy::policyNames(std::list<std::string>& names, bool topLevelOnly, bool append) const {
862  return _names(names, topLevelOnly, append, 1);
863 }
864 inline int Policy::fileNames(std::list<std::string>& names, bool topLevelOnly, bool append) const {
865  return _names(names, topLevelOnly, append, 2);
866 }
867 
868 inline Policy::StringArray Policy::names(bool topLevelOnly) const {
869  StringArray out;
870  _names(out, topLevelOnly, true, 7);
871  return out;
872 }
873 inline Policy::StringArray Policy::paramNames(bool topLevelOnly) const {
874  StringArray out;
875  _names(out, topLevelOnly, true, 4);
876  return out;
877 }
878 inline Policy::StringArray Policy::policyNames(bool topLevelOnly) const {
879  StringArray out;
880  _names(out, topLevelOnly, true, 1);
881  return out;
882 }
883 inline Policy::StringArray Policy::fileNames(bool topLevelOnly) const {
884  StringArray out;
885  _names(out, topLevelOnly, true, 2);
886  return out;
887 }
888 
889 inline size_t Policy::valueCount(const std::string& name) const { return _data->valueCount(name); }
890 
891 inline bool Policy::isArray(const std::string& name) const { return _data->isArray(name); }
892 
893 inline bool Policy::exists(const std::string& name) const { return _data->exists(name); }
894 
895 inline bool Policy::isBool(const std::string& name) const {
896  try {
897  return (_data->typeOf(name) == typeid(bool));
898  } catch (...) {
899  return false;
900  }
901 }
902 
903 inline bool Policy::isInt(const std::string& name) const {
904  try {
905  return (_data->typeOf(name) == typeid(int));
906  } catch (...) {
907  return false;
908  }
909 }
910 
911 inline bool Policy::isDouble(const std::string& name) const {
912  try {
913  return (_data->typeOf(name) == typeid(double));
914  } catch (...) {
915  return false;
916  }
917 }
918 
919 inline bool Policy::isString(const std::string& name) const {
920  try {
921  return (_data->typeOf(name) == typeid(std::string));
922  } catch (...) {
923  return false;
924  }
925 }
926 
927 inline bool Policy::isPolicy(const std::string& name) const {
928  try {
929  return _data->isPropertySetPtr(name);
930  } catch (...) {
931  return false;
932  }
933 }
934 
935 inline bool Policy::isFile(const std::string& name) const {
936  try {
937  return (getValueType(name) == FILE);
938  } catch (...) {
939  return false;
940  }
941 }
942 
943 inline const std::type_info& Policy::getTypeInfo(const std::string& name) const {
944  try {
945  return _data->typeOf(name);
947  throw LSST_EXCEPT(NameNotFound, name);
948  }
949 }
950 
951 inline const std::type_info& Policy::typeOf(const std::string& name) const { return getTypeInfo(name); }
952 
955 }
957  return Ptr(new Policy(_data->get<lsst::daf::base::PropertySet::Ptr>(name)));
958 }
959 
961  return _data->getArray<std::string>(name);
962 }
963 
965 
967 
969  POL_GETLIST(name, double, DOUBLE)
970 }
971 
972 inline void Policy::set(const std::string& name, const Ptr& value) {
973  _validate(name, value);
974  _data->set(name, value->asPropertySet());
975 }
976 inline void Policy::set(const std::string& name, bool value) {
977  _validate(name, value);
978  _data->set(name, value);
979 }
980 inline void Policy::set(const std::string& name, int value) {
981  _validate(name, value);
982  _data->set(name, value);
983 }
984 inline void Policy::set(const std::string& name, double value) {
985  _validate(name, value);
986  _data->set(name, value);
987 }
988 inline void Policy::set(const std::string& name, const std::string& value) {
989  _validate(name, value);
990  _data->set(name, value);
991 }
992 inline void Policy::set(const std::string& name, const char* value) {
993  if (value == NULL)
995  std::string("Attempted to assign NULL value to ") + name + ".");
996  _validate(name, std::string(value));
997  _data->set(name, std::string(value));
998 }
999 
1000 #define POL_ADD(name, value) \
1001  try { \
1002  _data->add(name, value); \
1003  } catch (lsst::pex::exceptions::TypeError&) { \
1004  throw LSST_EXCEPT(TypeError, name, getTypeName(name)); \
1005  }
1006 
1007 inline void Policy::add(const std::string& name, const Ptr& value) {
1008  _validate(name, value, valueCount(name));
1009  POL_ADD(name, value->asPropertySet())
1010 }
1011 inline void Policy::add(const std::string& name, bool value) {
1012  _validate(name, value, valueCount(name));
1013  POL_ADD(name, value);
1014 }
1015 inline void Policy::add(const std::string& name, int value) {
1016  _validate(name, value, valueCount(name));
1017  POL_ADD(name, value);
1018 }
1019 inline void Policy::add(const std::string& name, double value) {
1020  _validate(name, value, valueCount(name));
1021  POL_ADD(name, value);
1022 }
1023 inline void Policy::add(const std::string& name, const std::string& value) {
1024  _validate(name, value, valueCount(name));
1025  POL_ADD(name, value);
1026 }
1027 inline void Policy::add(const std::string& name, const char* value) {
1028  std::string v(value);
1029  _validate(name, v, valueCount(name));
1030  POL_ADD(name, v);
1031 }
1032 
1033 // TODO: validate if required value?
1034 inline void Policy::remove(const std::string& name) { _data->remove(name); }
1035 
1036 inline Policy* Policy::createPolicy(PolicySource& input, bool doIncludes, bool validate) {
1037  return _createPolicy(input, doIncludes, boost::filesystem::path(), validate);
1038 }
1039 
1040 inline Policy* Policy::createPolicy(const std::string& input, bool doIncludes, bool validate) {
1041  return _createPolicy(input, doIncludes, boost::filesystem::path(), validate);
1042 }
1043 
1044 inline Policy* Policy::createPolicy(PolicySource& input, const boost::filesystem::path& repository,
1045  bool validate) {
1046  return _createPolicy(input, true, repository, validate);
1047 }
1048 
1049 inline Policy* Policy::createPolicy(PolicySource& input, const std::string& repository, bool validate) {
1050  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1051 }
1052 
1053 inline Policy* Policy::createPolicy(PolicySource& input, const char* repository, bool validate) {
1054  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1055 }
1056 
1057 inline Policy* Policy::createPolicy(const std::string& input, const boost::filesystem::path& repository,
1058  bool validate) {
1059  return _createPolicy(input, true, repository, validate);
1060 }
1061 
1062 inline Policy* Policy::createPolicy(const std::string& input, const std::string& repository, bool validate) {
1063  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1064 }
1065 
1066 inline Policy* Policy::createPolicy(const std::string& input, const char* repository, bool validate) {
1067  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1068 }
1069 
1071 
1072 // general case is disallowed; known types are specialized
1073 template <typename T>
1075  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1076 }
1077 template <>
1078 bool Policy::getValue<bool>(const std::string& name) const;
1079 template <>
1080 int Policy::getValue<int>(const std::string& name) const;
1081 template <>
1082 double Policy::getValue<double>(const std::string& name) const;
1083 template <>
1084 std::string Policy::getValue<std::string>(const std::string& name) const;
1085 template <>
1086 Policy::FilePtr Policy::getValue<Policy::FilePtr>(const std::string& name) const;
1087 template <>
1088 Policy::ConstPtr Policy::getValue<Policy::ConstPtr>(const std::string& name) const;
1089 
1090 // general case is disallowed; known types are specialized
1091 template <typename T>
1093  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1094 }
1095 template <>
1096 std::vector<bool> Policy::getValueArray<bool>(const std::string& name) const;
1097 template <>
1098 std::vector<int> Policy::getValueArray<int>(const std::string& name) const;
1099 template <>
1100 std::vector<double> Policy::getValueArray<double>(const std::string& name) const;
1101 template <>
1102 std::vector<std::string> Policy::getValueArray<std::string>(const std::string& name) const;
1103 template <>
1104 Policy::FilePtrArray Policy::getValueArray<Policy::FilePtr>(const std::string& name) const;
1105 template <>
1106 Policy::PolicyPtrArray Policy::getValueArray<Policy::Ptr>(const std::string& name) const;
1107 template <>
1108 Policy::ConstPolicyPtrArray Policy::getValueArray<Policy::ConstPtr>(const std::string& name) const;
1109 
1110 // general case is disallowed; known types are specialized
1111 template <typename T>
1113  throw LSST_EXCEPT(TypeError, "unknown", "not implemented for this type");
1114 }
1115 template <>
1116 Policy::ValueType Policy::getValueType<bool>();
1117 template <>
1118 Policy::ValueType Policy::getValueType<int>();
1119 template <>
1120 Policy::ValueType Policy::getValueType<double>();
1121 template <>
1122 Policy::ValueType Policy::getValueType<std::string>();
1123 template <>
1124 Policy::ValueType Policy::getValueType<Policy>();
1125 template <>
1126 Policy::ValueType Policy::getValueType<Policy::FilePtr>();
1127 template <>
1128 Policy::ValueType Policy::getValueType<Policy::Ptr>();
1129 template <>
1130 Policy::ValueType Policy::getValueType<Policy::ConstPtr>();
1131 
1132 // general case is disallowed; known types are specialized
1133 template <typename T>
1134 void Policy::setValue(const std::string& name, const T& value) {
1135  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1136 }
1137 template <>
1138 void Policy::setValue<bool>(const std::string& name, const bool& value);
1139 template <>
1140 void Policy::setValue<int>(const std::string& name, const int& value);
1141 template <>
1142 void Policy::setValue<double>(const std::string& name, const double& value);
1143 template <>
1144 void Policy::setValue<std::string>(const std::string& name, const std::string& value);
1145 template <>
1146 void Policy::setValue<Policy::Ptr>(const std::string& name, const Policy::Ptr& value);
1147 template <>
1148 void Policy::setValue<Policy::FilePtr>(const std::string& name, const Policy::FilePtr& value);
1149 
1150 // general case is disallowed; known types are specialized
1151 template <typename T>
1152 void Policy::addValue(const std::string& name, const T& value) {
1153  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1154 }
1155 template <>
1156 void Policy::addValue<bool>(const std::string& name, const bool& value);
1157 template <>
1158 void Policy::addValue<int>(const std::string& name, const int& value);
1159 template <>
1160 void Policy::addValue<double>(const std::string& name, const double& value);
1161 template <>
1162 void Policy::addValue<std::string>(const std::string& name, const std::string& value);
1163 template <>
1164 void Policy::addValue<Policy::Ptr>(const std::string& name, const Policy::Ptr& value);
1165 template <>
1166 void Policy::addValue<Policy::FilePtr>(const std::string& name, const Policy::FilePtr& value);
1167 
1168 } // namespace policy
1169 } // namespace pex
1170 } // namespace lsst
1171 
1172 #endif // LSST_PEX_POLICY_POLICY_H
lsst::pex::policy::Policy::typeOf
const std::type_info & typeOf(const std::string &name) const
return the type information for the underlying type associated with a given name.
Definition: Policy.h:951
lsst::pex::policy::Policy::getBool
bool getBool(const std::string &name) const
return a boolean value associated with the given name.
Definition: Policy.h:567
lsst::pex::policy::Policy::DoubleArray
std::vector< double > DoubleArray
Definition: Policy.h:177
lsst::pex::policy::Policy::getString
const std::string getString(const std::string &name) const
return a string value associated with the given name .
Definition: Policy.h:603
lsst::pex::policy::Policy::asPropertySet
lsst::daf::base::PropertySet::Ptr asPropertySet()
return the internal policy data as a PropertySet pointer.
Definition: Policy.h:1070
lsst::pex::policy::Policy::getBoolArray
BoolArray getBoolArray(const std::string &name) const
return an array of values associated with the given name
Definition: Policy.h:964
lsst::pex::policy::Policy::print
virtual void print(std::ostream &out, const std::string &label="Policy", const std::string &indent="") const
print the contents of this policy to an output stream.
lsst::pex::policy::Policy::isInt
bool isInt(const std::string &name) const
return true if the value pointed to by the given name is an integer
Definition: Policy.h:903
lsst::pex::policy::Policy::getTypeByName
static ValueType getTypeByName(const std::string &name)
Given the human-readable name of a type ("bool", "int", "policy", etc), what is its ValueType (BOOL,...
lsst::pex::policy::Policy::createPolicy
static Policy * createPolicy(PolicySource &input, bool doIncludes=true, bool validate=true)
create a Policy from a file.
Definition: Policy.h:1036
std::string
STL class.
std::shared_ptr
STL class.
POL_ADD
#define POL_ADD(name, value)
Definition: Policy.h:1000
std::list< std::string >
lsst::pex::policy::Policy::ValueType
ValueType
an enumeration for the supported policy types
Definition: Policy.h:186
lsst::pex::policy::Policy::ConstPtr
std::shared_ptr< const Policy > ConstPtr
Definition: Policy.h:170
lsst::pex::policy::Policy::getDoubleArray
DoubleArray getDoubleArray(const std::string &name) const
Definition: Policy.h:968
lsst::pex::policy::Policy::typeName
static const char *const typeName[]
c-string forms for the supported value types.
Definition: Policy.h:193
base
Definition: __init__.py:1
lsst::pex::policy::Policy::loadPolicyFiles
int loadPolicyFiles(bool strict=true)
Recursively replace all PolicyFile values with the contents of the files they refer to.
Definition: Policy.h:747
std::vector
STL class.
std::type_info
lsst::pex::exceptions::NotFoundError
Reports attempts to access elements using an invalid key.
Definition: Runtime.h:151
lsst::pex::policy::Policy::isArray
bool isArray(const std::string &name) const
return true if multiple values can be retrieved via the given name.
Definition: Policy.h:891
lsst::pex::policy::Policy::StringArray
std::vector< std::string > StringArray
Definition: Policy.h:178
lsst::pex::policy::Policy::names
int names(std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const
load the names of parameters into a given list.
Definition: Policy.h:855
lsst::pex::policy::Policy::getDictionary
const ConstDictPtr getDictionary() const
The dictionary (if any) that this policy uses to validate itself, including checking set() and add() ...
ast::append
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33
lsst::pex::policy::Policy::setDictionary
void setDictionary(const Dictionary &dict)
Update this policy's dictionary that it uses to validate itself.
lsst::pex::policy::Policy::Policy
Policy(const lsst::daf::base::PropertySet::Ptr ps)
use a PropertySet as the data for a new Policy object
Definition: Policy.h:817
std::shared_ptr::get
T get(T... args)
lsst::pex::policy::TypeError
an exception indicating that a policy parameter with a given name has a type different from the one t...
Definition: exceptions.h:98
lsst::pex::policy::Policy::Policy
Policy(bool validate, const Dictionary &dict, const boost::filesystem::path &repository="")
Create a default Policy from a Dictionary.
lsst::pex::policy::Policy::ConstDictPtr
std::shared_ptr< const Dictionary > ConstDictPtr
Definition: Policy.h:172
lsst::pex::policy::Policy::PolicyPtrArray
std::vector< Ptr > PolicyPtrArray
Definition: Policy.h:179
lsst::pex::policy::Policy::fileNames
int fileNames(std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const
Definition: Policy.h:864
lsst::pex::policy::Policy::getFileArray
FilePtrArray getFileArray(const std::string &name) const
return an array of PolicyFile pointers associated with the given name.
lsst::pex::policy::Policy::BOOL
@ BOOL
Definition: Policy.h:186
lsst::pex::policy::Policy::Policy
Policy(const std::string &pathOrUrn)
Create a Policy from a named file or URN of the form "urn:eupspkg:<package>[:<repos>]:<path>".
lsst::pex::policy::Policy
a container for holding hierarchical configuration data in memory.
Definition: Policy.h:167
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
lsst::pex::policy::Policy::Policy
Policy(const PolicySource &source)
Create a Policy from a PolicySource (usually, a PolicyFile)
lsst::pex::policy::Policy::validate
void validate(ValidationError *errs=0) const
Validate this policy, using its stored dictionary.
lsst::pex::policy::Policy::add
void add(const std::string &name, const FilePtr &value)
pex
Definition: __init__.py:1
lsst::pex::policy::Policy::BoolArray
std::vector< bool > BoolArray
Definition: Policy.h:175
lsst::pex::policy::Policy::exists
bool exists(const std::string &name) const
return true if a value exists in this policy for the given name.
Definition: Policy.h:893
lsst::pex::policy::Policy::FilePtrArray
std::vector< FilePtr > FilePtrArray
Definition: Policy.h:180
Persistable.h
Interface for Persistable base class.
lsst::pex::policy::Policy::getFile
FilePtr getFile(const std::string &name) const
return a PolicyFile (a reference to a file with "sub-Policy" data) identified by a given name.
lsst::pex::policy::Policy::isFile
bool isFile(const std::string &name) const
return true if the value pointed to by the given name is a PolicyFile
Definition: Policy.h:935
lsst::pex::policy::Policy::paramNames
int paramNames(std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const
Definition: Policy.h:858
lsst::pex::policy::Policy::ConstPolicyPtrArray
std::vector< ConstPtr > ConstPolicyPtrArray
Definition: Policy.h:181
lsst::pex::policy::Policy::isDouble
bool isDouble(const std::string &name) const
return true if the value pointed to by the given name is a double
Definition: Policy.h:911
lsst::pex::policy::Policy::getDouble
double getDouble(const std::string &name) const
return a double value associated with the given name.
Definition: Policy.h:591
lsst::pex::policy::Policy::UNDETERMINED
@ UNDETERMINED
Definition: Policy.h:186
ast::detail::source
const char * source()
Source function that allows astChannel to source from a Stream.
Definition: Stream.h:224
lsst::pex::policy::Policy::STRING
@ STRING
Definition: Policy.h:186
lsst::pex::policy::Policy::Policy
Policy(const Policy &pol)
deep-copy a Policy.
lsst::pex::policy::Policy::getStringArray
StringArray getStringArray(const std::string &name) const
Definition: Policy.h:960
lsst::pex::policy::Policy::Ptr
std::shared_ptr< Policy > Ptr
Definition: Policy.h:169
lsst::pex::policy::Policy::FilePtr
std::shared_ptr< PolicyFile > FilePtr
Definition: Policy.h:173
lsst::pex::policy::Policy::Policy
Policy(const char *pathOrUrn)
std::ostream
STL class.
lsst::pex::policy::Policy::getValueArray
std::vector< T > getValueArray(const std::string &name) const
Template-ized version of getIntArray, getPolicyPtrArray, etc.
Definition: Policy.h:1092
lsst::pex::policy::Policy::Policy
Policy(Policy &pol, bool deep=false)
copy a Policy.
lsst::pex::policy::Policy::getValueType
static ValueType getValueType()
A template-ized way to get the ValueType.
Definition: Policy.h:1112
PropertySet.h
lsst::pex::policy::PolicySource
an abstract class representing a source of serialized Policy parameter data.
Definition: PolicySource.h:52
lsst::pex::policy::Policy::mergeDefaults
int mergeDefaults(const Policy &defaultPol, bool keepForValidation=true, ValidationError *errs=0)
use the values found in the given policy as default values for parameters not specified in this polic...
lsst::pex::policy::Policy::IntArray
std::vector< int > IntArray
Definition: Policy.h:176
lsst::pex::policy::Policy::getPolicyArray
PolicyPtrArray getPolicyArray(const std::string &name) const
return an array of Policy pointers associated with the given name.
lsst::pex::policy::Policy::getPolicy
ConstPtr getPolicy(const std::string &name) const
return a "sub-Policy" identified by a given name.
Definition: Policy.h:953
lsst::pex::policy::Policy::isBool
bool isBool(const std::string &name) const
return true if the value pointed to by the given name is a boolean
Definition: Policy.h:895
lsst::pex::policy::Policy::isString
bool isString(const std::string &name) const
return true if the value pointed to by the given name is a string
Definition: Policy.h:919
POL_GETSCALAR
#define POL_GETSCALAR(name, type, vtype)
Definition: Policy.h:51
lsst::pex::policy::operator<<
std::ostream & operator<<(std::ostream &os, const Policy &p)
Definition: Policy.h:848
lsst::pex::policy::Policy::loadPolicyFiles
virtual int loadPolicyFiles(const boost::filesystem::path &repository, bool strict=true)
Recursively replace all PolicyFile values with the contents of the files they refer to.
lsst::pex::policy::Policy::DictPtr
std::shared_ptr< Dictionary > DictPtr
Definition: Policy.h:171
lsst::pex::policy::Policy::getTypeName
const char * getTypeName(const std::string &name) const
return a string name for the type associated with the parameter of a given name.
Definition: Policy.h:507
lsst::pex::policy::Policy::setValue
void setValue(const std::string &name, const T &value)
Set a value with the given name.
Definition: Policy.h:1134
lsst::pex::policy::Policy::getIntArray
IntArray getIntArray(const std::string &name) const
Definition: Policy.h:966
lsst::pex::policy::Policy::isDictionary
bool isDictionary() const
return true if it appears that this Policy actually contains dictionary definition data.
Definition: Policy.h:392
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::pex::policy::Policy::policyNames
int policyNames(std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const
Definition: Policy.h:861
lsst::pex::policy::Policy::remove
void remove(const std::string &name)
Remove all values with a given name.
Definition: Policy.h:1034
lsst::pex::policy::Policy::canValidate
bool canValidate() const
Can this policy validate itself – that is, does it have a dictionary that it can use to validate itse...
lsst::pex::policy::Policy::str
virtual std::string str(const std::string &name, const std::string &indent="") const
return a string representation of the value given by a name.
os
std::ostream * os
Definition: Schema.cc:746
lsst::pex::policy::Policy::createPolicyFile
static FilePtr createPolicyFile(const std::string &pathOrUrn, bool strict=false)
Create a PolicyFile or UrnPolicyFile from pathOrUrn.
lsst::pex::exceptions::InvalidParameterError
Reports invalid arguments.
Definition: Runtime.h:66
lsst::daf::base::Persistable
Base class for all persistable classes.
Definition: Persistable.h:75
exceptions.h
definition of Policy-specific exceptions classes
lsst::pex::policy::Policy::addValue
void addValue(const std::string &name, const T &value)
Add a value to an array of values with a given name.
Definition: Policy.h:1152
lsst::daf::base::Persistable::Persistable
Persistable(void)
Default constructor.
Definition: Persistable.cc:45
lsst::pex::policy::Policy::createPolicyFromUrn
static Policy * createPolicyFromUrn(const std::string &urn, bool validate=true)
Create a Policy from a file specified by a URN.
POL_GETLIST
#define POL_GETLIST(name, type, vtype)
Definition: Policy.h:62
lsst::pex::policy::Policy::UNDEF
@ UNDEF
Definition: Policy.h:186
lsst::pex::policy::Policy::getConstPolicyArray
ConstPolicyPtrArray getConstPolicyArray(const std::string &name) const
lsst::pex::policy::Policy::add
void add(const std::string &name, const Ptr &value)
Definition: Policy.h:1007
lsst::pex::policy::Policy::toString
std::string toString() const
convert the entire contents of this policy to a string.
lsst::pex::policy::Policy::~Policy
virtual ~Policy()
destroy this policy
lsst::pex::policy::Policy::POLICY
@ POLICY
Definition: Policy.h:186
lsst::pex::policy::Policy::getInt
int getInt(const std::string &name) const
return an integer value associated with the given name.
Definition: Policy.h:579
lsst::pex::policy::NameNotFound
an exception indicating that a policy parameter of a given name can not be found in a Policy object.
Definition: exceptions.h:83
lsst::pex::policy::Policy::valueCount
size_t valueCount(const std::string &name) const
return the number of values currently associated with a given name
Definition: Policy.h:889
lsst::pex::policy::Policy::set
void set(const std::string &name, const FilePtr &value)
lsst::pex::policy::Policy::set
void set(const std::string &name, const Ptr &value)
Definition: Policy.h:972
lsst::pex::policy::Policy::isPolicy
bool isPolicy(const std::string &name) const
return true if the value pointed to by the given name is a Policy
Definition: Policy.h:927
lsst::pex::policy::Policy::getTypeInfo
const std::type_info & getTypeInfo(const std::string &name) const
return the type information for the underlying type associated with a given name.
Definition: Policy.h:943
lsst::pex::policy::Policy::FILE
@ FILE
Definition: Policy.h:186
lsst::pex::policy::Policy::getValueType
ValueType getValueType(const std::string &name) const
return the ValueType enum identifier for the underlying type associated with a given name.
lsst::pex::policy::Policy::getValue
T getValue(const std::string &name) const
Template-ized version of getInt, getPolicy, etc.
Definition: Policy.h:1074
lsst::pex::policy::Policy::INT
@ INT
Definition: Policy.h:186
lsst::pex::policy::Policy::Policy
Policy()
Create an empty policy.
pex.config.wrap.validate
validate
Definition: wrap.py:295
lsst::pex::policy::Policy::nameCount
int nameCount() const
How many names of parameters does this policy file have?
Definition: Policy.h:341
lsst::pex::policy::Policy::DOUBLE
@ DOUBLE
Definition: Policy.h:186