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
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
lsst::pex::policy::Policy Class Reference

a container for holding hierarchical configuration data in memory. More...

#include <Policy.h>

Inheritance diagram for lsst::pex::policy::Policy:
lsst::daf::base::Citizen lsst::daf::base::Persistable

Public Types

enum  ValueType {
  UNDETERMINED = -1, UNDEF, BOOL, INT,
  DOUBLE, STRING, POLICY, FILE
}
 
typedef boost::shared_ptr< PolicyPtr
 
typedef boost::shared_ptr
< const Policy
ConstPtr
 
typedef boost::shared_ptr
< Dictionary > 
DictPtr
 
typedef boost::shared_ptr
< const Dictionary > 
ConstDictPtr
 
typedef boost::shared_ptr
< PolicyFile
FilePtr
 
typedef std::vector< bool > BoolArray
 
typedef std::vector< int > IntArray
 
typedef std::vector< double > DoubleArray
 
typedef std::vector< std::string > StringArray
 
typedef std::vector< PtrPolicyPtrArray
 
typedef std::vector< FilePtrFilePtrArray
 
typedef std::vector< ConstPtrConstPolicyPtrArray
 
- Public Types inherited from lsst::daf::base::Citizen
enum  { magicSentinel = 0xdeadbeef }
 
typedef unsigned long memId
 Type of the block's ID. More...
 
typedef memId(* memNewCallback )(const memId cid)
 A function used to register a callback. More...
 
typedef memId(* memCallback )(const Citizen *ptr)
 
- Public Types inherited from lsst::daf::base::Persistable
typedef boost::shared_ptr
< Persistable
Ptr
 

Public Member Functions

 Policy ()
 
 Policy (const PolicySource &source)
 
 Policy (bool validate, const Dictionary &dict, const boost::filesystem::path &repository="")
 
 Policy (Policy &pol, bool deep=false)
 
 Policy (const Policy &pol)
 
virtual ~Policy ()
 
int nameCount () const
 
bool isDictionary () const
 
bool canValidate () const
 
const ConstDictPtr getDictionary () const
 
void setDictionary (const Dictionary &dict)
 
void validate (ValidationError *errs=0) const
 
size_t valueCount (const std::string &name) const
 
bool isArray (const std::string &name) const
 
bool exists (const std::string &name) const
 
bool isBool (const std::string &name) const
 
bool isInt (const std::string &name) const
 
bool isDouble (const std::string &name) const
 
bool isString (const std::string &name) const
 
bool isPolicy (const std::string &name) const
 
bool isFile (const std::string &name) const
 
const std::type_info & getTypeInfo (const std::string &name) const
 
const std::type_info & typeOf (const std::string &name) const
 
ValueType getValueType (const std::string &name) const
 
const char * getTypeName (const std::string &name) const
 
template<typename T >
getValue (const std::string &name) const
 
template<typename T >
std::vector< T > getValueArray (const std::string &name) const
 
FilePtr getFile (const std::string &name) const
 
bool getBool (const std::string &name) const
 
int getInt (const std::string &name) const
 
double getDouble (const std::string &name) const
 
const std::string getString (const std::string &name) const
 
FilePtrArray getFileArray (const std::string &name) const
 
void remove (const std::string &name)
 
int loadPolicyFiles (bool strict=true)
 
virtual int loadPolicyFiles (const boost::filesystem::path &repository, bool strict=true)
 
int mergeDefaults (const Policy &defaultPol, bool keepForValidation=true, ValidationError *errs=0)
 
virtual std::string str (const std::string &name, const std::string &indent="") const
 
virtual void print (std::ostream &out, const std::string &label="Policy", const std::string &indent="") const
 
std::string toString () const
 
lsst::daf::base::PropertySet::Ptr asPropertySet ()
 
template<>
bool getValue (const std::string &name) const
 
template<>
int getValue (const std::string &name) const
 
template<>
double getValue (const std::string &name) const
 
template<>
std::vector< bool > getValueArray (const std::string &name) const
 
template<>
std::vector< int > getValueArray (const std::string &name) const
 
template<>
std::vector< double > getValueArray (const std::string &name) const
 
template<>
Policy::ValueType getValueType ()
 
template<>
Policy::ValueType getValueType ()
 
template<>
Policy::ValueType getValueType ()
 
template<>
Policy::ValueType getValueType ()
 
template<>
void setValue (const std::string &name, const bool &value)
 
template<>
void setValue (const std::string &name, const int &value)
 
template<>
void setValue (const std::string &name, const double &value)
 
template<>
void addValue (const std::string &name, const bool &value)
 
template<>
void addValue (const std::string &name, const int &value)
 
template<>
void addValue (const std::string &name, const double &value)
 
 Policy (const std::string &pathOrUrn)
 
 Policy (const char *pathOrUrn)
 
int names (std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const
 
int paramNames (std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const
 
int policyNames (std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const
 
int fileNames (std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const
 
StringArray names (bool topLevelOnly=false) const
 
StringArray paramNames (bool topLevelOnly=false) const
 
StringArray policyNames (bool topLevelOnly=false) const
 
StringArray fileNames (bool topLevelOnly=false) const
 
ConstPtr getPolicy (const std::string &name) const
 
Ptr getPolicy (const std::string &name)
 
PolicyPtrArray getPolicyArray (const std::string &name) const
 
ConstPolicyPtrArray getConstPolicyArray (const std::string &name) const
 
BoolArray getBoolArray (const std::string &name) const
 
IntArray getIntArray (const std::string &name) const
 
DoubleArray getDoubleArray (const std::string &name) const
 
StringArray getStringArray (const std::string &name) const
 
template<typename T >
void setValue (const std::string &name, const T &value)
 
void set (const std::string &name, const Ptr &value)
 
void set (const std::string &name, const FilePtr &value)
 
void set (const std::string &name, bool value)
 
void set (const std::string &name, int value)
 
void set (const std::string &name, double value)
 
void set (const std::string &name, const std::string &value)
 
void set (const std::string &name, const char *value)
 
template<typename T >
void addValue (const std::string &name, const T &value)
 
void add (const std::string &name, const Ptr &value)
 
void add (const std::string &name, const FilePtr &value)
 
void add (const std::string &name, bool value)
 
void add (const std::string &name, int value)
 
void add (const std::string &name, double value)
 
void add (const std::string &name, const std::string &value)
 
void add (const std::string &name, const char *value)
 
- Public Member Functions inherited from lsst::daf::base::Citizen
 Citizen (const std::type_info &)
 
 Citizen (Citizen const &)
 
 ~Citizen ()
 
Citizenoperator= (Citizen const &)
 
std::string repr () const
 Return a string representation of a Citizen. More...
 
void markPersistent (void)
 Mark a Citizen as persistent and not destroyed until process end. More...
 
memId getId () const
 Return the Citizen's ID. More...
 
- Public Member Functions inherited from lsst::daf::base::Persistable
 Persistable (void)
 
virtual ~Persistable (void)
 
template<class Archive >
void serialize (Archive &, unsigned int const)
 

Static Public Member Functions

static PolicycreatePolicyFromUrn (const std::string &urn, bool validate=true)
 
static FilePtr createPolicyFile (const std::string &pathOrUrn, bool strict=false)
 
template<typename T >
static ValueType getValueType ()
 
static ValueType getTypeByName (const std::string &name)
 
static PolicycreatePolicy (PolicySource &input, bool doIncludes=true, bool validate=true)
 
static PolicycreatePolicy (const std::string &input, bool doIncludes=true, bool validate=true)
 
static PolicycreatePolicy (PolicySource &input, const boost::filesystem::path &repos, bool validate=true)
 
static PolicycreatePolicy (PolicySource &input, const std::string &repos, bool validate=true)
 
static PolicycreatePolicy (PolicySource &input, const char *repos, bool validate=true)
 
static PolicycreatePolicy (const std::string &input, const boost::filesystem::path &repos, bool validate=true)
 
static PolicycreatePolicy (const std::string &input, const std::string &repos, bool validate=true)
 
static PolicycreatePolicy (const std::string &input, const char *repos, bool validate=true)
 
- Static Public Member Functions inherited from lsst::daf::base::Citizen
static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector
< const Citizen * > * 
census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 
static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 

Static Public Attributes

static const char *const typeName []
 

Protected Member Functions

 Policy (const lsst::daf::base::PropertySet::Ptr ps)
 

Private Member Functions

int _names (std::list< std::string > &names, bool topLevelOnly=false, bool append=false, int want=3) const
 
int _names (std::vector< std::string > &names, bool topLevelOnly=false, bool append=false, int want=3) const
 
template<typename T >
void _validate (const std::string &name, const T &value, int curCount=0)
 
std::vector
< lsst::daf::base::Persistable::Ptr
_getPersistList (const std::string &name) const
 
std::vector
< lsst::daf::base::PropertySet::Ptr
_getPropSetList (const std::string &name) const
 

Static Private Member Functions

static Policy_createPolicy (PolicySource &input, bool doIncludes, const boost::filesystem::path &repos, bool validate)
 
static Policy_createPolicy (const std::string &input, bool doIncludes, const boost::filesystem::path &repos, bool validate)
 

Private Attributes

lsst::daf::base::PropertySet::Ptr _data
 
DictPtr _dictionary
 

Detailed Description

a container for holding hierarchical configuration data in memory.

A policy is a set of named parameters that can be used to configure the internal data and behavior of an object within an application. An important feature Policy objects is that the parameters can be loaded in from a file. Thus, it allows applications fine-grained control of objects even if much of the configuration parameters they provide are normally set to defaults and otherwise do not change.

The Policy interface allows an application to pull out parameter values by name. Typically, the application "knows" the names it needs from a Policy to configure itself–that is, these names and the use of their values are hard-coded into the application. The application simply calls one of the get methods to retrieve a typed value for the parameter. (Nevertheless, if necessary, the parameter names contained in a policy can be retrieved via the names() member function.)

Policy parameters values are restricted to a limited set of types to ensure simple, well-defined ASCII text serialization format. These types are In particular, a Policy parameter can be one of:

As implied by the inclusion of Policy as a value type, a Policy can be hierarchical (like a PropertySet). Values deep within the hierarchy can be retrieved via a hiearchical name. Such a name is made up of name fields delimited by dots (.) where each name field represents a level of the hierarchy. The first field represents the top level of the hierarchy. If a given name does not resolve to value, a NameNotFound exception is thrown. If one expects a different value type for a name than what is actually stored, (e.g. one calls getInt(name) for a parameter that is actually a string), a TypeError exception is thrown.

A hierarchical Policy allows an application to configure a whole hierarchy of objects, even if the object classes (and their associated policy parameters) were developed by different people. In particular, if an application that is configuring one of the objects it uses, it can either pull out the relevent values directly by their hierarchical names, or if that object supports configuration from a Policy, it can pull all of the values for the object by retrieving a Policy (via getPolicy(name) ) and passing it to the object.

It is important to note that parameter names relative the Policy that contains them. For example, suppose you have a parameter accessible via the name "foo.bar.zub". This implies that the name "foo.bar" will resolve to a Policy object. You can retrieve the "zub" parameter from that "sub-Policy" object by asking for "zub".

Loading a Policy File

One can read Policy data via the constructors that take a file name in some form as an input argument; however the prefered manner is via one of the createPolicy() functions. The latter is able to intelligently differentiate between simple Policy file and a Dictionary file. In either case, the formats supported would be restricted by default to those currently built into this package. Support for other formats can be plugged in using the PolicyFile and SupportFormats classes.

For more information about about Policy files, file formats, and dictionaries, see the package overview as well as the PolicyFile and Dictionary class descriptions.

Default Policy Data

When an object using a Policy fails to find a parameter it was expecting, it is a little inelegant to provide a default hard-coded in the object's implementation, by design. Instead it is recommended that defaults be loaded from another Policy. The intended way to do this is to load defaults via a DefaultPolicyFile (which can locate a policy file from any EUPS-setup installation directory) and to merge them into to the primary Policy instance via the mergeDefaults() function.

Version Notes

With version 3.1, support for the JSON format was dropped.

After version 3.2, Policy's internal implementation was changed to be a wrapper around PropertySet. Prior to this, it used its own internal data map. The API (which had been optimized for the old implementation), remained largely unchanged for the purposes of backward compatibility. The changes include (1) dropping support for providing default values to the get*() functions, (2) returning array values by value rather than reference, and (3) added functions for greater consistancy with PropertySet.

After 3.3.3, loading default data (including from Dictionarys) was improved. This included adding mergeDefaults()

Definition at line 169 of file Policy.h.

Member Typedef Documentation

typedef std::vector<bool> lsst::pex::policy::Policy::BoolArray

Definition at line 178 of file Policy.h.

typedef boost::shared_ptr<const Dictionary> lsst::pex::policy::Policy::ConstDictPtr

Definition at line 175 of file Policy.h.

Definition at line 184 of file Policy.h.

typedef boost::shared_ptr<const Policy> lsst::pex::policy::Policy::ConstPtr

Definition at line 173 of file Policy.h.

typedef boost::shared_ptr<Dictionary> lsst::pex::policy::Policy::DictPtr

Definition at line 174 of file Policy.h.

typedef std::vector<double> lsst::pex::policy::Policy::DoubleArray

Definition at line 180 of file Policy.h.

typedef boost::shared_ptr<PolicyFile> lsst::pex::policy::Policy::FilePtr

Definition at line 176 of file Policy.h.

Definition at line 183 of file Policy.h.

typedef std::vector<int> lsst::pex::policy::Policy::IntArray

Definition at line 179 of file Policy.h.

Definition at line 182 of file Policy.h.

typedef boost::shared_ptr<Policy> lsst::pex::policy::Policy::Ptr

Definition at line 172 of file Policy.h.

typedef std::vector<std::string> lsst::pex::policy::Policy::StringArray

Definition at line 181 of file Policy.h.

Member Enumeration Documentation

an enumeration for the supported policy types

Enumerator
UNDETERMINED 
UNDEF 
BOOL 
INT 
DOUBLE 
STRING 
POLICY 
FILE 

Definition at line 189 of file Policy.h.

Constructor & Destructor Documentation

lsst::pex::policy::Policy::Policy ( )

Create an empty policy

lsst::pex::policy::Policy::Policy ( const std::string &  pathOrUrn)
explicit

Create a Policy from a named file or URN of the form "urn:eupspkg:<package>[:<repos>]:<path>". For more details on the format of the URN, see UrnPolicyFile.

Parameters
pathOrUrncan be a local file name, file path, or URN.
lsst::pex::policy::Policy::Policy ( const char *  pathOrUrn)
explicit

Create a Policy from a named file or URN of the form "urn:eupspkg:<package>[:<repos>]:<path>". For more details on the format of the URN, see UrnPolicyFile.

Parameters
pathOrUrncan be a local file name, file path, or URN.
lsst::pex::policy::Policy::Policy ( const PolicySource source)
explicit

Create a Policy from a PolicySource (usually, a PolicyFile)

Parameters
source
lsst::pex::policy::Policy::Policy ( bool  validate,
const Dictionary &  dict,
const boost::filesystem::path &  repository = "" 
)

Create a default Policy from a Dictionary. If the Dictionary references files containing dictionaries for sub-Policies, an attempt is made to open them and extract the default data, and if that attempt fails, an exception is thrown (probably an IoError or ParseError).

Parameters
validateif true, a shallow copy of the Dictionary will be held onto by this Policy and used to validate future updates.
dictthe Dictionary to load defaults from
repositorythe directory to look for dictionary files referenced in dict. The default is the current directory.
lsst::pex::policy::Policy::Policy ( Policy pol,
bool  deep = false 
)

copy a Policy.

Parameters
polthe policy to copy
deepif true, do a deep copy. Otherwise, Policy data will be shared.
lsst::pex::policy::Policy::Policy ( const Policy pol)

deep-copy a Policy.

virtual lsst::pex::policy::Policy::~Policy ( )
virtual

destroy this policy

lsst::pex::policy::Policy::Policy ( const lsst::daf::base::PropertySet::Ptr  ps)
inlineprotected

use a PropertySet as the data for a new Policy object

Definition at line 850 of file Policy.h.

851  : Citizen(typeid(this)), lsst::daf::base::Persistable(), _data(ps)
852  { }
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
Citizen(const std::type_info &)
Definition: Citizen.cc:173
Base class for all persistable classes.
Definition: Persistable.h:74

Member Function Documentation

static Policy* lsst::pex::policy::Policy::_createPolicy ( PolicySource input,
bool  doIncludes,
const boost::filesystem::path &  repos,
bool  validate 
)
staticprivate
static Policy* lsst::pex::policy::Policy::_createPolicy ( const std::string &  input,
bool  doIncludes,
const boost::filesystem::path &  repos,
bool  validate 
)
staticprivate
std::vector<lsst::daf::base::Persistable::Ptr> lsst::pex::policy::Policy::_getPersistList ( const std::string &  name) const
inlineprivate

Definition at line 872 of file Policy.h.

873  {
874  POL_GETLIST(name, Persistable::Ptr, FILE)
875  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_GETLIST(name, type, vtype)
Definition: Policy.h:63
std::vector<lsst::daf::base::PropertySet::Ptr> lsst::pex::policy::Policy::_getPropSetList ( const std::string &  name) const
inlineprivate

Definition at line 877 of file Policy.h.

878  {
880  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
#define POL_GETLIST(name, type, vtype)
Definition: Policy.h:63
int lsst::pex::policy::Policy::_names ( std::list< std::string > &  names,
bool  topLevelOnly = false,
bool  append = false,
int  want = 3 
) const
private
int lsst::pex::policy::Policy::_names ( std::vector< std::string > &  names,
bool  topLevelOnly = false,
bool  append = false,
int  want = 3 
) const
private
template<typename T >
void lsst::pex::policy::Policy::_validate ( const std::string &  name,
const T &  value,
int  curCount = 0 
)
private

If _dictionary is non-null, validate value against it, assuming curCount current values for name.

void lsst::pex::policy::Policy::add ( const std::string &  name,
const Ptr value 
)
inline

Add a value to an array of values with a given name.

If a value was previously set using the set() function, that previous value will be retained as the first value of the array.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this is part of a sequence of

operations.

Note that

add(const string&, const string&)

and

add(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif the existing array of values is not of the requested type, or if this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1075 of file Policy.h.

1075  {
1076  _validate(name, value, valueCount(name));
1077  POL_ADD(name, value->asPropertySet())
1078 }
size_t valueCount(const std::string &name) const
Definition: Policy.h:936
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_ADD(name, value)
Definition: Policy.h:1069
void _validate(const std::string &name, const T &value, int curCount=0)
void lsst::pex::policy::Policy::add ( const std::string &  name,
const FilePtr value 
)

Add a value to an array of values with a given name.

If a value was previously set using the set() function, that previous value will be retained as the first value of the array.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this is part of a sequence of

operations.

Note that

add(const string&, const string&)

and

add(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif the existing array of values is not of the requested type, or if this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.
void lsst::pex::policy::Policy::add ( const std::string &  name,
bool  value 
)
inline

Add a value to an array of values with a given name.

If a value was previously set using the set() function, that previous value will be retained as the first value of the array.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this is part of a sequence of

operations.

Note that

add(const string&, const string&)

and

add(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif the existing array of values is not of the requested type, or if this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1079 of file Policy.h.

1079  {
1080  _validate(name, value, valueCount(name));
1081  POL_ADD(name, value);
1082 }
size_t valueCount(const std::string &name) const
Definition: Policy.h:936
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_ADD(name, value)
Definition: Policy.h:1069
void _validate(const std::string &name, const T &value, int curCount=0)
void lsst::pex::policy::Policy::add ( const std::string &  name,
int  value 
)
inline

Add a value to an array of values with a given name.

If a value was previously set using the set() function, that previous value will be retained as the first value of the array.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this is part of a sequence of

operations.

Note that

add(const string&, const string&)

and

add(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif the existing array of values is not of the requested type, or if this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1083 of file Policy.h.

1083  {
1084  _validate(name, value, valueCount(name));
1085  POL_ADD(name, value);
1086 }
size_t valueCount(const std::string &name) const
Definition: Policy.h:936
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_ADD(name, value)
Definition: Policy.h:1069
void _validate(const std::string &name, const T &value, int curCount=0)
void lsst::pex::policy::Policy::add ( const std::string &  name,
double  value 
)
inline

Add a value to an array of values with a given name.

If a value was previously set using the set() function, that previous value will be retained as the first value of the array.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this is part of a sequence of

operations.

Note that

add(const string&, const string&)

and

add(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif the existing array of values is not of the requested type, or if this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1087 of file Policy.h.

1087  {
1088  _validate(name, value, valueCount(name));
1089  POL_ADD(name, value);
1090 }
size_t valueCount(const std::string &name) const
Definition: Policy.h:936
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_ADD(name, value)
Definition: Policy.h:1069
void _validate(const std::string &name, const T &value, int curCount=0)
void lsst::pex::policy::Policy::add ( const std::string &  name,
const std::string &  value 
)
inline

Add a value to an array of values with a given name.

If a value was previously set using the set() function, that previous value will be retained as the first value of the array.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this is part of a sequence of

operations.

Note that

add(const string&, const string&)

and

add(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif the existing array of values is not of the requested type, or if this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1091 of file Policy.h.

1091  {
1092  _validate(name, value, valueCount(name));
1093  POL_ADD(name, value);
1094 }
size_t valueCount(const std::string &name) const
Definition: Policy.h:936
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_ADD(name, value)
Definition: Policy.h:1069
void _validate(const std::string &name, const T &value, int curCount=0)
void lsst::pex::policy::Policy::add ( const std::string &  name,
const char *  value 
)
inline

Add a value to an array of values with a given name.

If a value was previously set using the set() function, that previous value will be retained as the first value of the array.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this is part of a sequence of

operations.

Note that

add(const string&, const string&)

and

add(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif the existing array of values is not of the requested type, or if this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1095 of file Policy.h.

1095  {
1096  std::string v(value);
1097  _validate(name, v, valueCount(name));
1098  POL_ADD(name, v);
1099 }
size_t valueCount(const std::string &name) const
Definition: Policy.h:936
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_ADD(name, value)
Definition: Policy.h:1069
void _validate(const std::string &name, const T &value, int curCount=0)
template<typename T >
void lsst::pex::policy::Policy::addValue ( const std::string &  name,
const T &  value 
)

Add a value to an array of values with a given name.

If a value was previously set using the set() function, that previous value will be retained as the first value of the array.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this is part of a sequence of

operations.

Note that

add(const string&, const string&)

and

add(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif the existing array of values is not of the requested type, or if this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1210 of file Policy.h.

1210  {
1211  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1212 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<>
void lsst::pex::policy::Policy::addValue ( const std::string &  name,
const bool &  value 
)
template<>
void lsst::pex::policy::Policy::addValue ( const std::string &  name,
const int &  value 
)
template<>
void lsst::pex::policy::Policy::addValue ( const std::string &  name,
const double &  value 
)
lsst::daf::base::PropertySet::Ptr lsst::pex::policy::Policy::asPropertySet ( )
inline

return the internal policy data as a PropertySet pointer. All sub-policy data will appear as PropertySets.

Definition at line 1160 of file Policy.h.

1160 { return _data; }
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
bool lsst::pex::policy::Policy::canValidate ( ) const

Can this policy validate itself – that is, does it have a dictionary that it can use to validate itself? If true, then set() and add() operations will be checked against it.

Policy * lsst::pex::policy::Policy::createPolicy ( PolicySource input,
bool  doIncludes = true,
bool  validate = true 
)
inlinestatic

create a Policy from a file. The caller is responsible for deleting the returned value. This is the preferred way to obtain a Policy file if you don't care to know if the input file is an actual policy file or a policy dictionary. If it turns out to be a dictionary file, the defined defaults will be loaded into the return policy.

Parameters
inputthe input file or stream to load data from.
doIncludesif true, any references found to external Policy files will be resolved into sub-policy values. The files will be looked for in a directory relative the current directory.
validateif true and the input file is a policy dictionary, it will be given to the returned policy and used to validate future updates to the Policy.

Definition at line 1106 of file Policy.h.

1108 {
1109  return _createPolicy(input, doIncludes, boost::filesystem::path(), validate);
1110 }
static Policy * _createPolicy(PolicySource &input, bool doIncludes, const boost::filesystem::path &repos, bool validate)
void validate(ValidationError *errs=0) const
Policy * lsst::pex::policy::Policy::createPolicy ( const std::string &  input,
bool  doIncludes = true,
bool  validate = true 
)
inlinestatic

create a Policy from a file. The caller is responsible for deleting the returned value. This is the preferred way to obtain a Policy file if you don't care to know if the input file is an actual policy file or a policy dictionary. If it turns out to be a dictionary file, the defined defaults will be loaded into the return policy.

Parameters
inputthe input file or stream to load data from.
doIncludesif true, any references found to external Policy files will be resolved into sub-policy values. The files will be looked for in a directory relative the current directory.
validateif true and the input file is a policy dictionary, it will be given to the returned policy and used to validate future updates to the Policy.

Definition at line 1112 of file Policy.h.

1114 {
1115  return _createPolicy(input, doIncludes, boost::filesystem::path(), validate);
1116 }
static Policy * _createPolicy(PolicySource &input, bool doIncludes, const boost::filesystem::path &repos, bool validate)
void validate(ValidationError *errs=0) const
Policy * lsst::pex::policy::Policy::createPolicy ( PolicySource input,
const boost::filesystem::path &  repos,
bool  validate = true 
)
inlinestatic

create a Policy from a file. The caller is responsible for deleting the returned value. This is the preferred way to obtain a Policy file if you don't care to know if the input file is an actual policy file or a policy dictionary. If it turns out to be a dictionary file, the defined defaults will be loaded into the return policy.

Parameters
inputthe input file or stream to load data from.
reposa directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this.
validateif true and the input file is a policy dictionary, it will be given to the returned policy and used to validate future updates to the Policy.

Definition at line 1118 of file Policy.h.

1121 {
1122  return _createPolicy(input, true, repository, validate);
1123 }
static Policy * _createPolicy(PolicySource &input, bool doIncludes, const boost::filesystem::path &repos, bool validate)
void validate(ValidationError *errs=0) const
Policy * lsst::pex::policy::Policy::createPolicy ( PolicySource input,
const std::string &  repos,
bool  validate = true 
)
inlinestatic

create a Policy from a file. The caller is responsible for deleting the returned value. This is the preferred way to obtain a Policy file if you don't care to know if the input file is an actual policy file or a policy dictionary. If it turns out to be a dictionary file, the defined defaults will be loaded into the return policy.

Parameters
inputthe input file or stream to load data from.
reposa directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this.
validateif true and the input file is a policy dictionary, it will be given to the returned policy and used to validate future updates to the Policy.

Definition at line 1125 of file Policy.h.

1128 {
1129  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1130 }
static Policy * _createPolicy(PolicySource &input, bool doIncludes, const boost::filesystem::path &repos, bool validate)
void validate(ValidationError *errs=0) const
Policy * lsst::pex::policy::Policy::createPolicy ( PolicySource input,
const char *  repos,
bool  validate = true 
)
inlinestatic

create a Policy from a file. The caller is responsible for deleting the returned value. This is the preferred way to obtain a Policy file if you don't care to know if the input file is an actual policy file or a policy dictionary. If it turns out to be a dictionary file, the defined defaults will be loaded into the return policy.

Parameters
inputthe input file or stream to load data from.
reposa directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this.
validateif true and the input file is a policy dictionary, it will be given to the returned policy and used to validate future updates to the Policy.

Definition at line 1132 of file Policy.h.

1135 {
1136  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1137 }
static Policy * _createPolicy(PolicySource &input, bool doIncludes, const boost::filesystem::path &repos, bool validate)
void validate(ValidationError *errs=0) const
Policy * lsst::pex::policy::Policy::createPolicy ( const std::string &  input,
const boost::filesystem::path &  repos,
bool  validate = true 
)
inlinestatic

create a Policy from a file. The caller is responsible for deleting the returned value. This is the preferred way to obtain a Policy file if you don't care to know if the input file is an actual policy file or a policy dictionary. If it turns out to be a dictionary file, the defined defaults will be loaded into the return policy.

Parameters
inputthe input file or stream to load data from.
reposa directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this.
validateif true and the input file is a policy dictionary, it will be given to the returned policy and used to validate future updates to the Policy.

Definition at line 1139 of file Policy.h.

1142 {
1143  return _createPolicy(input, true, repository, validate);
1144 }
static Policy * _createPolicy(PolicySource &input, bool doIncludes, const boost::filesystem::path &repos, bool validate)
void validate(ValidationError *errs=0) const
Policy * lsst::pex::policy::Policy::createPolicy ( const std::string &  input,
const std::string &  repos,
bool  validate = true 
)
inlinestatic

create a Policy from a file. The caller is responsible for deleting the returned value. This is the preferred way to obtain a Policy file if you don't care to know if the input file is an actual policy file or a policy dictionary. If it turns out to be a dictionary file, the defined defaults will be loaded into the return policy.

Parameters
inputthe input file or stream to load data from.
reposa directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this.
validateif true and the input file is a policy dictionary, it will be given to the returned policy and used to validate future updates to the Policy.

Definition at line 1146 of file Policy.h.

1149 {
1150  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1151 }
static Policy * _createPolicy(PolicySource &input, bool doIncludes, const boost::filesystem::path &repos, bool validate)
void validate(ValidationError *errs=0) const
Policy * lsst::pex::policy::Policy::createPolicy ( const std::string &  input,
const char *  repos,
bool  validate = true 
)
inlinestatic

create a Policy from a file. The caller is responsible for deleting the returned value. This is the preferred way to obtain a Policy file if you don't care to know if the input file is an actual policy file or a policy dictionary. If it turns out to be a dictionary file, the defined defaults will be loaded into the return policy.

Parameters
inputthe input file or stream to load data from.
reposa directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this.
validateif true and the input file is a policy dictionary, it will be given to the returned policy and used to validate future updates to the Policy.

Definition at line 1153 of file Policy.h.

1156 {
1157  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1158 }
static Policy * _createPolicy(PolicySource &input, bool doIncludes, const boost::filesystem::path &repos, bool validate)
void validate(ValidationError *errs=0) const
static FilePtr lsst::pex::policy::Policy::createPolicyFile ( const std::string &  pathOrUrn,
bool  strict = false 
)
static

Create a PolicyFile or UrnPolicyFile from pathOrUrn.

Parameters
pathOrUrnif this looks like a Policy URN, create a UrnPolicyFile; otherwise, create a plain PolicyFile.
strictif false, "@" will be accepted as a substitute for "urn:eupspkg:"; if true, urn:eupspkg must be present in a URN.
static Policy* lsst::pex::policy::Policy::createPolicyFromUrn ( const std::string &  urn,
bool  validate = true 
)
static

Create a Policy from a file specified by a URN. The caller is responsible for deleting the returned value. This is the preferred way to obtain a Policy file if you don't care to know if the input file is an actual policy file or a policy dictionary. If it turns out to be a dictionary file, the defined defaults will be loaded into the return policy.

Parameters
urnA URN of the form "urn:eupspkg:<package>[:<repository>]:<path> to load data from, as described in UrnPolicyFile.
validateif true and the input file is a policy dictionary, it will be given to the returned policy and used to validate future updates to the Policy.
bool lsst::pex::policy::Policy::exists ( const std::string &  name) const
inline

return true if a value exists in this policy for the given name. This is semantically equivalent to (valuecount(name) > 0) (though its implementation is slightly more efficient).

Parameters
namethe (possibly) hierarchical name of the property of interest.

Definition at line 944 of file Policy.h.

944  {
945  return _data->exists(name);
946 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
int lsst::pex::policy::Policy::fileNames ( std::list< std::string > &  names,
bool  topLevelOnly = false,
bool  append = false 
) const
inline

load the names of parameters into a given list. names() returns all names, paramNames() only returns the names that resolve to non-Policy and non-PolicyFile type parameters, policyNames() only returns the Policy names, and fileNames() only returns PolicyFile names. These versions are provided for backward compatibility but are deprecated; use the versions that return vector values.

Parameters
namesthe list object to be loaded
topLevelOnlyif true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included.
appendif false, the contents of the given list will be erased before loading the names.
Returns
int the number of names added

Definition at line 913 of file Policy.h.

915 {
916  return _names(names, topLevelOnly, append, 2);
917 }
int _names(std::list< std::string > &names, bool topLevelOnly=false, bool append=false, int want=3) const
Policy::StringArray lsst::pex::policy::Policy::fileNames ( bool  topLevelOnly = false) const
inline

return the names of parameters. names() returns all names, paramNames() only returns the names that resolve to non-Policy and non-PolicyFile type parameters, policyNames() only returns the Policy names, and fileNames() only returns PolicyFile names.

Parameters
topLevelOnlyif true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included.

Definition at line 930 of file Policy.h.

930  {
931  StringArray out;
932  _names(out, topLevelOnly, true, 2);
933  return out;
934 }
int _names(std::list< std::string > &names, bool topLevelOnly=false, bool append=false, int want=3) const
std::vector< std::string > StringArray
Definition: Policy.h:181
bool lsst::pex::policy::Policy::getBool ( const std::string &  name) const
inline

return a boolean value associated with the given name. If the underlying value is an array, only the last value added will be returned.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not a boolean type.

Definition at line 589 of file Policy.h.

589  {
590  POL_GETSCALAR(name, bool, BOOL)
591  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_GETSCALAR(name, type, vtype)
Definition: Policy.h:52
Policy::BoolArray lsst::pex::policy::Policy::getBoolArray ( const std::string &  name) const
inline

return an array of values associated with the given name

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not the expected type.

Definition at line 1027 of file Policy.h.

1027  {
1028  POL_GETLIST(name, bool, BOOL)
1029 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_GETLIST(name, type, vtype)
Definition: Policy.h:63
ConstPolicyPtrArray lsst::pex::policy::Policy::getConstPolicyArray ( const std::string &  name) const

return an array of Policy pointers associated with the given name.

Adding an element to the returned array (using push_back()) is equivalent adding a value with add(const string&, const Policy::Ptr&).

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not a Policy type.
const ConstDictPtr lsst::pex::policy::Policy::getDictionary ( ) const

The dictionary (if any) that this policy uses to validate itself, including checking set() and add() operations for validity.

double lsst::pex::policy::Policy::getDouble ( const std::string &  name) const
inline

return a double value associated with the given name. If the underlying value is an array, only the last value added will be returned.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not a double type.

Definition at line 617 of file Policy.h.

617  {
618  POL_GETSCALAR(name, double, DOUBLE)
619  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_GETSCALAR(name, type, vtype)
Definition: Policy.h:52
Policy::DoubleArray lsst::pex::policy::Policy::getDoubleArray ( const std::string &  name) const
inline

return an array of values associated with the given name

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not the expected type.

Definition at line 1036 of file Policy.h.

1036  {
1037  POL_GETLIST(name, double, DOUBLE)
1038 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_GETLIST(name, type, vtype)
Definition: Policy.h:63
FilePtr lsst::pex::policy::Policy::getFile ( const std::string &  name) const

return a PolicyFile (a reference to a file with "sub-Policy" data) identified by a given name.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not a Policy type.
FilePtrArray lsst::pex::policy::Policy::getFileArray ( const std::string &  name) const

return an array of PolicyFile pointers associated with the given name.

Adding an element to the returned array (using push_back()) is equivalent adding a value with add(const string&, const Policy::FilePtr&).

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not a Policy type.
int lsst::pex::policy::Policy::getInt ( const std::string &  name) const
inline

return an integer value associated with the given name. If the underlying value is an array, only the last value added will be returned.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not an integer type.

Definition at line 603 of file Policy.h.

603  {
604  POL_GETSCALAR(name, int, INT)
605  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_GETSCALAR(name, type, vtype)
Definition: Policy.h:52
Policy::IntArray lsst::pex::policy::Policy::getIntArray ( const std::string &  name) const
inline

return an array of values associated with the given name

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not the expected type.

Definition at line 1031 of file Policy.h.

1031  {
1032  POL_GETLIST(name, int, INT)
1033 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_GETLIST(name, type, vtype)
Definition: Policy.h:63
Policy::ConstPtr lsst::pex::policy::Policy::getPolicy ( const std::string &  name) const
inline

return a "sub-Policy" identified by a given name.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not a Policy type.

Definition at line 1015 of file Policy.h.

1015  {
1017 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< const Policy > ConstPtr
Definition: Policy.h:173
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
Policy::Ptr lsst::pex::policy::Policy::getPolicy ( const std::string &  name)
inline

return a "sub-Policy" identified by a given name.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not a Policy type.

Definition at line 1018 of file Policy.h.

1018  {
1020 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
boost::shared_ptr< Policy > Ptr
Definition: Policy.h:172
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
PolicyPtrArray lsst::pex::policy::Policy::getPolicyArray ( const std::string &  name) const

return an array of Policy pointers associated with the given name.

Adding an element to the returned array (using push_back()) is equivalent adding a value with add(const string&, const Policy::Ptr&).

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not a Policy type.
const std::string lsst::pex::policy::Policy::getString ( const std::string &  name) const
inline

return a string value associated with the given name . If the underlying value is an array, only the last value added will be returned.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not an integer type.

Definition at line 631 of file Policy.h.

631  {
632  POL_GETSCALAR(name, std::string, STRING)
633  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define POL_GETSCALAR(name, type, vtype)
Definition: Policy.h:52
Policy::StringArray lsst::pex::policy::Policy::getStringArray ( const std::string &  name) const
inline

return an array of values associated with the given name

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
Exceptions
NameNotFoundif no value is associated with the given name.
TypeErrorif the value associated the given name is not the expected type.

Definition at line 1023 of file Policy.h.

1023  {
1024  return _data->getArray<std::string>(name);
1025 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
static ValueType lsst::pex::policy::Policy::getTypeByName ( const std::string &  name)
static

Given the human-readable name of a type ("bool", "int", "policy", etc), what is its ValueType (BOOL, STRING, etc.)? Throws BadNameError if unknown.

const std::type_info & lsst::pex::policy::Policy::getTypeInfo ( const std::string &  name) const
inline

return the type information for the underlying type associated with a given name. This is equivalent to typeOf() and is provided for backward compatibility.

Definition at line 1003 of file Policy.h.

1004 {
1005  try { return _data->typeOf(name); }
1006  catch (lsst::pex::exceptions::NotFoundError& e) {
1007  throw LSST_EXCEPT(NameNotFound, name);
1008  }
1009 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
const char* lsst::pex::policy::Policy::getTypeName ( const std::string &  name) const
inline

return a string name for the type associated with the parameter of a given name. If a parameter with that name has not been set, the returned string will be "undefined".

Definition at line 534 of file Policy.h.

534  {
535  try { return typeName[getValueType(name)]; }
536  catch (NameNotFound&) { return typeName[UNDEF]; }
537  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
static const char *const typeName[]
Definition: Policy.h:205
static ValueType getValueType()
Definition: Policy.h:1186
template<typename T >
T lsst::pex::policy::Policy::getValue ( const std::string &  name) const

Template-ized version of getInt, getPolicy, etc. General case is disallowed, but specific types are implemented: bool, int, double, string, FilePtr (aka shared_ptr<PolicyFile>), ConstPtr (aka shared_ptr<const Policy>).

Definition at line 1163 of file Policy.h.

1163  {
1164  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1165 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<>
bool lsst::pex::policy::Policy::getValue ( const std::string &  name) const
template<>
int lsst::pex::policy::Policy::getValue ( const std::string &  name) const
template<>
double lsst::pex::policy::Policy::getValue ( const std::string &  name) const
template<typename T >
std::vector< T > lsst::pex::policy::Policy::getValueArray ( const std::string &  name) const

Template-ized version of getIntArray, getPolicyPtrArray, etc. General case is disallowed, but specific types are implemented: bool, int, double, string, FilePtr (aka shared_ptr<PolicyFile>, returns FilePtrArray), Ptr (aka shared_ptr<Policy>, returns PolicyPtrArray).

Definition at line 1174 of file Policy.h.

1174  {
1175  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1176 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<>
std::vector<int> lsst::pex::policy::Policy::getValueArray ( const std::string &  name) const
template<>
std::vector<bool> lsst::pex::policy::Policy::getValueArray ( const std::string &  name) const
template<>
std::vector<double> lsst::pex::policy::Policy::getValueArray ( const std::string &  name) const
template<typename T >
Policy::ValueType lsst::pex::policy::Policy::getValueType ( )
static

A template-ized way to get the ValueType. General case is disallowed, but specific types are implemented: bool, int, double, string, Policy, FilePtr (aka shared_ptr<PolicyFile>), Ptr (aka shared_ptr<Policy>), ConstPtr (aka shared_ptr<const Policy>).

Definition at line 1186 of file Policy.h.

1186  {
1187  throw LSST_EXCEPT(TypeError, "unknown", "not implemented for this type");
1188 }
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
ValueType lsst::pex::policy::Policy::getValueType ( const std::string &  name) const

return the ValueType enum identifier for the underlying type associated with a given name. If a parameter with that name has not been set, Policy::UNDEF is returned.

template<>
Policy::ValueType lsst::pex::policy::Policy::getValueType ( )
template<>
Policy::ValueType lsst::pex::policy::Policy::getValueType ( )
template<>
Policy::ValueType lsst::pex::policy::Policy::getValueType ( )
template<>
Policy::ValueType lsst::pex::policy::Policy::getValueType ( )
bool lsst::pex::policy::Policy::isArray ( const std::string &  name) const
inline

return true if multiple values can be retrieved via the given name. False is returned if the name does not exist. This is equivalent to (valueCount(name) > 1).

Parameters
namethe (possibly) hierarchical name of the property of interest.

Definition at line 940 of file Policy.h.

940  {
941  return _data->isArray(name);
942 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
bool lsst::pex::policy::Policy::isBool ( const std::string &  name) const
inline

return true if the value pointed to by the given name is a boolean

Definition at line 948 of file Policy.h.

948  {
949  try {
950  return (_data->typeOf(name) == typeid(bool));
951  }
952  catch (...) {
953  return false;
954  }
955 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
bool lsst::pex::policy::Policy::isDictionary ( ) const
inline

return true if it appears that this Policy actually contains dictionary definition data.

Definition at line 419 of file Policy.h.

419 { return exists("definitions"); }
bool exists(const std::string &name) const
Definition: Policy.h:944
bool lsst::pex::policy::Policy::isDouble ( const std::string &  name) const
inline

return true if the value pointed to by the given name is a double

Definition at line 966 of file Policy.h.

966  {
967  try {
968  return (_data->typeOf(name) == typeid(double));
969  }
970  catch (...) {
971  return false;
972  }
973 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
bool lsst::pex::policy::Policy::isFile ( const std::string &  name) const
inline

return true if the value pointed to by the given name is a PolicyFile

Definition at line 993 of file Policy.h.

993  {
994 
995  try {
996  return (getValueType(name) == FILE);
997  }
998  catch (...) {
999  return false;
1000  }
1001 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
static ValueType getValueType()
Definition: Policy.h:1186
bool lsst::pex::policy::Policy::isInt ( const std::string &  name) const
inline

return true if the value pointed to by the given name is an integer

Definition at line 957 of file Policy.h.

957  {
958  try {
959  return (_data->typeOf(name) == typeid(int));
960  }
961  catch (...) {
962  return false;
963  }
964 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
bool lsst::pex::policy::Policy::isPolicy ( const std::string &  name) const
inline

return true if the value pointed to by the given name is a Policy

Definition at line 984 of file Policy.h.

984  {
985  try {
986  return (_data->typeOf(name) == typeid(lsst::daf::base::PropertySet::Ptr));
987  }
988  catch (...) {
989  return false;
990  }
991 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
bool lsst::pex::policy::Policy::isString ( const std::string &  name) const
inline

return true if the value pointed to by the given name is a string

Definition at line 975 of file Policy.h.

975  {
976  try {
977  return (_data->typeOf(name) == typeid(std::string));
978  }
979  catch (...) {
980  return false;
981  }
982 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
int lsst::pex::policy::Policy::loadPolicyFiles ( bool  strict = true)
inline

Recursively replace all PolicyFile values with the contents of the files they refer to. The type of a parameter containing a PolicyFile will consequently change to a Policy upon successful completion. If the value is an array, all PolicyFiles in the array must load without error before the PolicyFile values themselves are erased.

Parameters
strictIf true, throw an exception if an error occurs while reading and/or parsing the file (probably an IoError or ParseError). Otherwise, replace the file reference with a partial or empty sub-policy (that is, "{}").
Returns
the number of files loaded

Definition at line 775 of file Policy.h.

775  {
776  return loadPolicyFiles(boost::filesystem::path(), strict);
777  }
int loadPolicyFiles(bool strict=true)
Definition: Policy.h:775
virtual int lsst::pex::policy::Policy::loadPolicyFiles ( const boost::filesystem::path &  repository,
bool  strict = true 
)
virtual

Recursively replace all PolicyFile values with the contents of the files they refer to. The type of a parameter containing a PolicyFile will consequently change to a Policy upon successful completion. If the value is an array, all PolicyFiles in the array must load without error before the PolicyFile values themselves are erased.

Parameters
strictIf true, throw an exception if an error occurs while reading and/or parsing the file (probably an IoError or ParseError). Otherwise, replace the file reference with a partial or empty sub-policy (that is, "{}").
Returns
the number of files loaded
Parameters
repositorya directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this. If empty or not provided, the directorywill be assumed to be the current one.
int lsst::pex::policy::Policy::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 policy. This function will iterate through the parameter names in the given policy, and if the name is not found in this policy, the value from the given one will be copied into this one. No attempt is made to match the number of values available per name.

Parameters
defaultPolthe policy to pull default values from. This may be a Dictionary; if so, the default values will drawn from the appropriate default keyword.
keepForValidationif true, and if defaultPol is a Dictionary, keep a reference to it for validation future updates to this Policy.
errsan exception to load errors into – only relevant if defaultPol is a Dictionary or if this Policy already has a dictionary to validate against; if a validation error is encountered, it will be added to errs if errs is non-null, and an exception will not be raised; however, if errs is null, an exception will be thrown if a validation error is encountered.
Returns
int the number of parameter names copied over
int lsst::pex::policy::Policy::nameCount ( ) const
inline

How many names of parameters does this policy file have?

Definition at line 362 of file Policy.h.

362  {
363  return _data->nameCount();
364  }
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
int lsst::pex::policy::Policy::names ( std::list< std::string > &  names,
bool  topLevelOnly = false,
bool  append = false 
) const
inline

load the names of parameters into a given list. names() returns all names, paramNames() only returns the names that resolve to non-Policy and non-PolicyFile type parameters, policyNames() only returns the Policy names, and fileNames() only returns PolicyFile names. These versions are provided for backward compatibility but are deprecated; use the versions that return vector values.

Parameters
namesthe list object to be loaded
topLevelOnlyif true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included.
appendif false, the contents of the given list will be erased before loading the names.
Returns
int the number of names added

Definition at line 897 of file Policy.h.

899 {
900  return _names(names, topLevelOnly, append, 7);
901 }
int _names(std::list< std::string > &names, bool topLevelOnly=false, bool append=false, int want=3) const
Policy::StringArray lsst::pex::policy::Policy::names ( bool  topLevelOnly = false) const
inline

return the names of parameters. names() returns all names, paramNames() only returns the names that resolve to non-Policy and non-PolicyFile type parameters, policyNames() only returns the Policy names, and fileNames() only returns PolicyFile names.

Parameters
topLevelOnlyif true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included.

Definition at line 919 of file Policy.h.

919  {
920  return _data->names();
921 }
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
int lsst::pex::policy::Policy::paramNames ( std::list< std::string > &  names,
bool  topLevelOnly = false,
bool  append = false 
) const
inline

load the names of parameters into a given list. names() returns all names, paramNames() only returns the names that resolve to non-Policy and non-PolicyFile type parameters, policyNames() only returns the Policy names, and fileNames() only returns PolicyFile names. These versions are provided for backward compatibility but are deprecated; use the versions that return vector values.

Parameters
namesthe list object to be loaded
topLevelOnlyif true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included.
appendif false, the contents of the given list will be erased before loading the names.
Returns
int the number of names added

Definition at line 902 of file Policy.h.

904 {
905  return _names(names, topLevelOnly, append, 4);
906 }
int _names(std::list< std::string > &names, bool topLevelOnly=false, bool append=false, int want=3) const
Policy::StringArray lsst::pex::policy::Policy::paramNames ( bool  topLevelOnly = false) const
inline

return the names of parameters. names() returns all names, paramNames() only returns the names that resolve to non-Policy and non-PolicyFile type parameters, policyNames() only returns the Policy names, and fileNames() only returns PolicyFile names.

Parameters
topLevelOnlyif true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included.

Definition at line 922 of file Policy.h.

922  {
923  StringArray out;
924  _names(out, topLevelOnly, true, 4);
925  return out;
926 }
int _names(std::list< std::string > &names, bool topLevelOnly=false, bool append=false, int want=3) const
std::vector< std::string > StringArray
Definition: Policy.h:181
int lsst::pex::policy::Policy::policyNames ( std::list< std::string > &  names,
bool  topLevelOnly = false,
bool  append = false 
) const
inline

load the names of parameters into a given list. names() returns all names, paramNames() only returns the names that resolve to non-Policy and non-PolicyFile type parameters, policyNames() only returns the Policy names, and fileNames() only returns PolicyFile names. These versions are provided for backward compatibility but are deprecated; use the versions that return vector values.

Parameters
namesthe list object to be loaded
topLevelOnlyif true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included.
appendif false, the contents of the given list will be erased before loading the names.
Returns
int the number of names added

Definition at line 907 of file Policy.h.

910 {
911  return _names(names, topLevelOnly, append, 1);
912 }
int _names(std::list< std::string > &names, bool topLevelOnly=false, bool append=false, int want=3) const
Policy::StringArray lsst::pex::policy::Policy::policyNames ( bool  topLevelOnly = false) const
inline

return the names of parameters. names() returns all names, paramNames() only returns the names that resolve to non-Policy and non-PolicyFile type parameters, policyNames() only returns the Policy names, and fileNames() only returns PolicyFile names.

Parameters
topLevelOnlyif true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included.

Definition at line 927 of file Policy.h.

927  {
928  return _data->propertySetNames(topLevelOnly);
929 }
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
virtual void lsst::pex::policy::Policy::print ( std::ostream &  out,
const std::string &  label = "Policy",
const std::string &  indent = "" 
) const
virtual

print the contents of this policy to an output stream. This is mainly intended for debugging purposes.

Parameters
outthe output stream to write contents to
labela labeling string to lead the listing with.
indenta string to prepend each line with.
void lsst::pex::policy::Policy::remove ( const std::string &  name)
inline

Remove all values with a given name.

Parameters
nameThe name of the parameter to remove. Can be hierarchical name with fields delimited with ".".

Definition at line 1102 of file Policy.h.

1102  {
1103  _data->remove(name);
1104 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
void lsst::pex::policy::Policy::set ( const std::string &  name,
const Ptr value 
)
inline

Set a value with the given name.

Any previous value set with the same name will be overwritten. In particular, if the property previously pointed to an array of values, all those values will be forgotten.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this will be followed by

operations.

Note that

set(const string&, const string&)

and

set(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1040 of file Policy.h.

1040  {
1041  _validate(name, value);
1042  _data->set(name, value->asPropertySet());
1043 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void _validate(const std::string &name, const T &value, int curCount=0)
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
void lsst::pex::policy::Policy::set ( const std::string &  name,
const FilePtr value 
)

Set a value with the given name.

Any previous value set with the same name will be overwritten. In particular, if the property previously pointed to an array of values, all those values will be forgotten.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this will be followed by

operations.

Note that

set(const string&, const string&)

and

set(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.
void lsst::pex::policy::Policy::set ( const std::string &  name,
bool  value 
)
inline

Set a value with the given name.

Any previous value set with the same name will be overwritten. In particular, if the property previously pointed to an array of values, all those values will be forgotten.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this will be followed by

operations.

Note that

set(const string&, const string&)

and

set(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1044 of file Policy.h.

1044  {
1045  _validate(name, value);
1046  _data->set(name, value);
1047 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void _validate(const std::string &name, const T &value, int curCount=0)
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
void lsst::pex::policy::Policy::set ( const std::string &  name,
int  value 
)
inline

Set a value with the given name.

Any previous value set with the same name will be overwritten. In particular, if the property previously pointed to an array of values, all those values will be forgotten.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this will be followed by

operations.

Note that

set(const string&, const string&)

and

set(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1048 of file Policy.h.

1048  {
1049  _validate(name, value);
1050  _data->set(name, value);
1051 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void _validate(const std::string &name, const T &value, int curCount=0)
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
void lsst::pex::policy::Policy::set ( const std::string &  name,
double  value 
)
inline

Set a value with the given name.

Any previous value set with the same name will be overwritten. In particular, if the property previously pointed to an array of values, all those values will be forgotten.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this will be followed by

operations.

Note that

set(const string&, const string&)

and

set(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1052 of file Policy.h.

1052  {
1053  _validate(name, value);
1054  _data->set(name, value);
1055 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void _validate(const std::string &name, const T &value, int curCount=0)
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
void lsst::pex::policy::Policy::set ( const std::string &  name,
const std::string &  value 
)
inline

Set a value with the given name.

Any previous value set with the same name will be overwritten. In particular, if the property previously pointed to an array of values, all those values will be forgotten.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this will be followed by

operations.

Note that

set(const string&, const string&)

and

set(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1056 of file Policy.h.

1056  {
1057  _validate(name, value);
1058  _data->set(name, value);
1059 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void _validate(const std::string &name, const T &value, int curCount=0)
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
void lsst::pex::policy::Policy::set ( const std::string &  name,
const char *  value 
)
inline

Set a value with the given name.

Any previous value set with the same name will be overwritten. In particular, if the property previously pointed to an array of values, all those values will be forgotten.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this will be followed by

operations.

Note that

set(const string&, const string&)

and

set(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1060 of file Policy.h.

1060  {
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 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void _validate(const std::string &name, const T &value, int curCount=0)
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
void lsst::pex::policy::Policy::setDictionary ( const Dictionary &  dict)

Update this policy's dictionary that it uses to validate itself. Note that this will not trigger validation – you will need to call

afterwards.

template<typename T >
void lsst::pex::policy::Policy::setValue ( const std::string &  name,
const T &  value 
)

Set a value with the given name.

Any previous value set with the same name will be overwritten. In particular, if the property previously pointed to an array of values, all those values will be forgotten.

If this policy has a

Dictionary

(see

), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a

* ValidationError

will be thrown. With the exception that the minimum number of values (in the case of an array) will not be checked, in case this will be followed by

operations.

Note that

set(const string&, const string&)

and

set(const string&, const char *)

are equivalent.

Parameters
namethe name of the parameter. This can be a hierarchical name with fields delimited with "."
valuethe value–int, double, string or Policy–to associate with the name.
Exceptions
TypeErrorif this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name.

Definition at line 1199 of file Policy.h.

1199  {
1200  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1201 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
template<>
void lsst::pex::policy::Policy::setValue ( const std::string &  name,
const bool &  value 
)
template<>
void lsst::pex::policy::Policy::setValue ( const std::string &  name,
const int &  value 
)
template<>
void lsst::pex::policy::Policy::setValue ( const std::string &  name,
const double &  value 
)
virtual std::string lsst::pex::policy::Policy::str ( const std::string &  name,
const std::string &  indent = "" 
) const
virtual

return a string representation of the value given by a name. The string "<null>" is printed if the name does not exist.

Parameters
namethe name of the parameter to string-ify
indenta string to prepend each line with. If the string includes embedded newline characters, each line should be preceded by this indent string.
std::string lsst::pex::policy::Policy::toString ( ) const

convert the entire contents of this policy to a string. This is mainly intended for debugging purposes.

const std::type_info & lsst::pex::policy::Policy::typeOf ( const std::string &  name) const
inline

return the type information for the underlying type associated with a given name. This is equivalent to getTypeInfo() and is provided for consistency with PropertySet.

Definition at line 1011 of file Policy.h.

1011  {
1012  return getTypeInfo(name);
1013 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
const std::type_info & getTypeInfo(const std::string &name) const
Definition: Policy.h:1003
void lsst::pex::policy::Policy::validate ( ValidationError *  errs = 0) const

Validate this policy, using its stored dictionary. If

is false, this will throw a LogicError.

If validation errors are found and

err

is null, a ValidationError will be thrown.

Parameters
errsif non-null, any validation errors will be stored here instead of being thrown.
size_t lsst::pex::policy::Policy::valueCount ( const std::string &  name) const
inline

return the number of values currently associated with a given name

Parameters
namethe (possibly) hierarchical name of the property of interest.

Definition at line 936 of file Policy.h.

936  {
937  return _data->valueCount(name);
938 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
lsst::daf::base::PropertySet::Ptr _data
Definition: Policy.h:855

Member Data Documentation

lsst::daf::base::PropertySet::Ptr lsst::pex::policy::Policy::_data
private

Definition at line 855 of file Policy.h.

DictPtr lsst::pex::policy::Policy::_dictionary
private

Definition at line 857 of file Policy.h.

const char* const lsst::pex::policy::Policy::typeName[]
static

c-string forms for the supported value types. The ValueType enum values can be used a indexes into the array to return the name of the corresping type.

Definition at line 205 of file Policy.h.


The documentation for this class was generated from the following file: