LSSTApplications
17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
LSSTDataManagementBasePackage
|
a container for holding hierarchical configuration data in memory. More...
#include <Policy.h>
Public Types | |
enum | ValueType { UNDETERMINED = -1, UNDEF, BOOL, INT, DOUBLE, STRING, POLICY, FILE } |
an enumeration for the supported policy types More... | |
typedef std::shared_ptr< Policy > | Ptr |
typedef std::shared_ptr< const Policy > | ConstPtr |
typedef std::shared_ptr< Dictionary > | DictPtr |
typedef std::shared_ptr< const Dictionary > | ConstDictPtr |
typedef std::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< Ptr > | PolicyPtrArray |
typedef std::vector< FilePtr > | FilePtrArray |
typedef std::vector< ConstPtr > | ConstPolicyPtrArray |
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 Member Functions | |
Policy () | |
Create an empty policy. More... | |
Policy (const PolicySource &source) | |
Create a Policy from a PolicySource (usually, a PolicyFile) More... | |
Policy (bool validate, const Dictionary &dict, const boost::filesystem::path &repository="") | |
Create a default Policy from a Dictionary. More... | |
Policy (Policy &pol, bool deep=false) | |
copy a Policy. More... | |
Policy (const Policy &pol) | |
deep-copy a Policy. More... | |
virtual | ~Policy () |
destroy this policy More... | |
int | nameCount () const |
How many names of parameters does this policy file have? More... | |
bool | isDictionary () const |
return true if it appears that this Policy actually contains dictionary definition data. More... | |
bool | 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. More... | |
const ConstDictPtr | getDictionary () const |
The dictionary (if any) that this policy uses to validate itself, including checking set() and add() operations for validity. More... | |
void | setDictionary (const Dictionary &dict) |
Update this policy's dictionary that it uses to validate itself. More... | |
void | validate (ValidationError *errs=0) const |
Validate this policy, using its stored dictionary. More... | |
size_t | valueCount (const std::string &name) const |
return the number of values currently associated with a given name More... | |
bool | isArray (const std::string &name) const |
return true if multiple values can be retrieved via the given name. More... | |
bool | exists (const std::string &name) const |
return true if a value exists in this policy for the given name. More... | |
bool | isBool (const std::string &name) const |
return true if the value pointed to by the given name is a boolean More... | |
bool | isInt (const std::string &name) const |
return true if the value pointed to by the given name is an integer More... | |
bool | isDouble (const std::string &name) const |
return true if the value pointed to by the given name is a double More... | |
bool | isString (const std::string &name) const |
return true if the value pointed to by the given name is a string More... | |
bool | isPolicy (const std::string &name) const |
return true if the value pointed to by the given name is a Policy More... | |
bool | isFile (const std::string &name) const |
return true if the value pointed to by the given name is a PolicyFile More... | |
const std::type_info & | getTypeInfo (const std::string &name) const |
return the type information for the underlying type associated with a given name. More... | |
const std::type_info & | typeOf (const std::string &name) const |
return the type information for the underlying type associated with a given name. More... | |
ValueType | getValueType (const std::string &name) const |
return the ValueType enum identifier for the underlying type associated with a given name. More... | |
const char * | getTypeName (const std::string &name) const |
return a string name for the type associated with the parameter of a given name. More... | |
template<typename T > | |
T | getValue (const std::string &name) const |
Template-ized version of getInt, getPolicy, etc. More... | |
template<typename T > | |
std::vector< T > | getValueArray (const std::string &name) const |
Template-ized version of getIntArray, getPolicyPtrArray, etc. More... | |
FilePtr | getFile (const std::string &name) const |
return a PolicyFile (a reference to a file with "sub-Policy" data) identified by a given name. More... | |
bool | getBool (const std::string &name) const |
return a boolean value associated with the given name. More... | |
int | getInt (const std::string &name) const |
return an integer value associated with the given name. More... | |
double | getDouble (const std::string &name) const |
return a double value associated with the given name. More... | |
const std::string | getString (const std::string &name) const |
return a string value associated with the given name . More... | |
FilePtrArray | getFileArray (const std::string &name) const |
return an array of PolicyFile pointers associated with the given name. More... | |
void | remove (const std::string &name) |
Remove all values with a given name. More... | |
int | loadPolicyFiles (bool strict=true) |
Recursively replace all PolicyFile values with the contents of the files they refer to. More... | |
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. More... | |
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 policy. More... | |
virtual std::string | str (const std::string &name, const std::string &indent="") const |
return a string representation of the value given by a name. More... | |
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. More... | |
std::string | toString () const |
convert the entire contents of this policy to a string. More... | |
lsst::daf::base::PropertySet::Ptr | asPropertySet () |
return the internal policy data as a PropertySet pointer. More... | |
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) |
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... | |
template<class Archive > | |
void | serialize (Archive &, unsigned int const) |
Template boost::serialization function for the base class. More... | |
Policy (const std::string &pathOrUrn) | |
Create a Policy from a named file or URN of the form "urn:eupspkg:<package>[:<repos>]:<path>". More... | |
Policy (const char *pathOrUrn) | |
Create a Policy from a named file or URN of the form "urn:eupspkg:<package>[:<repos>]:<path>". More... | |
int | names (std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const |
load the names of parameters into a given list. More... | |
int | paramNames (std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const |
load the names of parameters into a given list. More... | |
int | policyNames (std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const |
load the names of parameters into a given list. More... | |
int | fileNames (std::list< std::string > &names, bool topLevelOnly=false, bool append=false) const |
load the names of parameters into a given list. More... | |
StringArray | names (bool topLevelOnly=false) const |
return the names of parameters. More... | |
StringArray | paramNames (bool topLevelOnly=false) const |
return the names of parameters. More... | |
StringArray | policyNames (bool topLevelOnly=false) const |
return the names of parameters. More... | |
StringArray | fileNames (bool topLevelOnly=false) const |
return the names of parameters. More... | |
ConstPtr | getPolicy (const std::string &name) const |
return a "sub-Policy" identified by a given name. More... | |
Ptr | getPolicy (const std::string &name) |
return a "sub-Policy" identified by a given name. More... | |
PolicyPtrArray | getPolicyArray (const std::string &name) const |
return an array of Policy pointers associated with the given name. More... | |
ConstPolicyPtrArray | getConstPolicyArray (const std::string &name) const |
return an array of Policy pointers associated with the given name. More... | |
BoolArray | getBoolArray (const std::string &name) const |
return an array of values associated with the given name More... | |
IntArray | getIntArray (const std::string &name) const |
return an array of values associated with the given name More... | |
DoubleArray | getDoubleArray (const std::string &name) const |
return an array of values associated with the given name More... | |
StringArray | getStringArray (const std::string &name) const |
return an array of values associated with the given name More... | |
template<typename T > | |
void | setValue (const std::string &name, const T &value) |
Set a value with the given name. More... | |
void | set (const std::string &name, const Ptr &value) |
Set a value with the given name. More... | |
void | set (const std::string &name, const FilePtr &value) |
Set a value with the given name. More... | |
void | set (const std::string &name, bool value) |
Set a value with the given name. More... | |
void | set (const std::string &name, int value) |
Set a value with the given name. More... | |
void | set (const std::string &name, double value) |
Set a value with the given name. More... | |
void | set (const std::string &name, const std::string &value) |
Set a value with the given name. More... | |
void | set (const std::string &name, const char *value) |
Set a value with the given name. More... | |
template<typename T > | |
void | addValue (const std::string &name, const T &value) |
Add a value to an array of values with a given name. More... | |
void | add (const std::string &name, const Ptr &value) |
Add a value to an array of values with a given name. More... | |
void | add (const std::string &name, const FilePtr &value) |
Add a value to an array of values with a given name. More... | |
void | add (const std::string &name, bool value) |
Add a value to an array of values with a given name. More... | |
void | add (const std::string &name, int value) |
Add a value to an array of values with a given name. More... | |
void | add (const std::string &name, double value) |
Add a value to an array of values with a given name. More... | |
void | add (const std::string &name, const std::string &value) |
Add a value to an array of values with a given name. More... | |
void | add (const std::string &name, const char *value) |
Add a value to an array of values with a given name. More... | |
Static Public Member Functions | |
static Policy * | createPolicyFromUrn (const std::string &urn, bool validate=true) |
Create a Policy from a file specified by a URN. More... | |
static FilePtr | createPolicyFile (const std::string &pathOrUrn, bool strict=false) |
Create a PolicyFile or UrnPolicyFile from pathOrUrn . More... | |
template<typename T > | |
static ValueType | getValueType () |
A template-ized way to get the ValueType. More... | |
static ValueType | getTypeByName (const std::string &name) |
Given the human-readable name of a type ("bool", "int", "policy", etc), what is its ValueType (BOOL, STRING, etc.)? Throws BadNameError if unknown. More... | |
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 Policy * | createPolicy (PolicySource &input, bool doIncludes=true, bool validate=true) |
create a Policy from a file. More... | |
static Policy * | createPolicy (const std::string &input, bool doIncludes=true, bool validate=true) |
create a Policy from a file. More... | |
static Policy * | createPolicy (PolicySource &input, const boost::filesystem::path &repos, bool validate=true) |
create a Policy from a file. More... | |
static Policy * | createPolicy (PolicySource &input, const std::string &repos, bool validate=true) |
create a Policy from a file. More... | |
static Policy * | createPolicy (PolicySource &input, const char *repos, bool validate=true) |
create a Policy from a file. More... | |
static Policy * | createPolicy (const std::string &input, const boost::filesystem::path &repos, bool validate=true) |
create a Policy from a file. More... | |
static Policy * | createPolicy (const std::string &input, const std::string &repos, bool validate=true) |
create a Policy from a file. More... | |
static Policy * | createPolicy (const std::string &input, const char *repos, bool validate=true) |
create a Policy from a file. More... | |
Census | |
Provide a list of current Citizens | |
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... | |
callbackIDs | |
Set callback Ids. The old Id is returned | |
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... | |
callbacks | |
Set the New/Delete callback functions; in each case the previously installed callback is returned. These callback functions return a value which is Added to the previously registered id. The default callback functions are called default{New,Delete}Callback; you may want to set a break point in these callbacks from your favourite debugger | |
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 [] |
c-string forms for the supported value types. More... | |
Protected Member Functions | |
Policy (const lsst::daf::base::PropertySet::Ptr ps) | |
use a PropertySet as the data for a new Policy object More... | |
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".
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.
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.
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()
typedef std::vector<bool> lsst.pex::policy::Policy::BoolArray |
typedef std::shared_ptr<const Dictionary> lsst.pex::policy::Policy::ConstDictPtr |
typedef std::shared_ptr<const Policy> lsst.pex::policy::Policy::ConstPtr |
typedef std::shared_ptr<Dictionary> lsst.pex::policy::Policy::DictPtr |
typedef std::vector<double> lsst.pex::policy::Policy::DoubleArray |
typedef std::vector<int> lsst.pex::policy::Policy::IntArray |
|
inherited |
an enumeration for the supported policy types
Enumerator | |
---|---|
UNDETERMINED | |
UNDEF | |
BOOL | |
INT | |
DOUBLE | |
STRING | |
POLICY | |
FILE |
Definition at line 189 of file Policy.h.
lsst.pex::policy::Policy::Policy | ( | ) |
Create an empty policy.
|
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.
pathOrUrn | can be a local file name, file path, or URN. |
|
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.
pathOrUrn | can be a local file name, file path, or URN. |
|
explicit |
Create a Policy from a PolicySource (usually, a PolicyFile)
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).
validate | if true, a shallow copy of the Dictionary will be held onto by this Policy and used to validate future updates. |
dict | the Dictionary to load defaults from |
repository | the 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 |
||
) |
|
virtual |
destroy this policy
|
inlineprotected |
|
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
TypeError | if 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.
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
|
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
TypeError | if 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.
|
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
TypeError | if 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.
|
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
TypeError | if 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.
|
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
TypeError | if 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.
|
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
TypeError | if 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 1099 of file Policy.h.
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
TypeError | if 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 1214 of file Policy.h.
void lsst.pex::policy::Policy::addValue | ( | const std::string & | name, |
const bool & | value | ||
) |
void lsst.pex::policy::Policy::addValue | ( | const std::string & | name, |
const int & | value | ||
) |
void lsst.pex::policy::Policy::addValue | ( | const std::string & | name, |
const double & | value | ||
) |
|
inline |
bool lsst.pex::policy::Policy::canValidate | ( | ) | const |
|
staticinherited |
How many active Citizens are there?
startingMemId | Don't print Citizens with lower IDs |
Definition at line 238 of file Citizen.cc.
|
staticinherited |
Print a list of all active Citizens to stream, sorted by ID.
stream | stream to print to |
startingMemId | Don't print Citizens with lower IDs |
Definition at line 259 of file Citizen.cc.
|
staticinherited |
Return a (newly allocated) std::vector of active Citizens sorted by ID.
You are responsible for deleting it; or you can say std::unique_ptr<std::vector<Citizen const*> const> leaks(Citizen::census()); and not bother (that becomes std::unique_ptr in C++11)
Definition at line 287 of file Citizen.cc.
|
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.
input | the input file or stream to load data from. |
doIncludes | if 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. |
validate | if 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 1110 of file Policy.h.
|
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.
input | the input file or stream to load data from. |
doIncludes | if 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. |
validate | if 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 1116 of file Policy.h.
|
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.
input | the input file or stream to load data from. |
repos | a directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this. |
validate | if 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 1122 of file Policy.h.
|
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.
input | the input file or stream to load data from. |
repos | a directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this. |
validate | if 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 1129 of file Policy.h.
|
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.
input | the input file or stream to load data from. |
repos | a directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this. |
validate | if 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 1136 of file Policy.h.
|
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.
input | the input file or stream to load data from. |
repos | a directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this. |
validate | if 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 1143 of file Policy.h.
|
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.
input | the input file or stream to load data from. |
repos | a directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this. |
validate | if 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 1150 of file Policy.h.
|
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.
input | the input file or stream to load data from. |
repos | a directory to look in for the referenced files. Only when the name of the file to be included is an absolute path will this. |
validate | if 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 1157 of file Policy.h.
|
static |
Create a PolicyFile or UrnPolicyFile from pathOrUrn
.
pathOrUrn | if this looks like a Policy URN, create a UrnPolicyFile; otherwise, create a plain PolicyFile. |
strict | if false, "@" will be accepted as a substitute for "urn:eupspkg:"; if true, urn:eupspkg must be present in a URN. |
|
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.
urn | A URN of the form "urn:eupspkg:<package>[:<repository>]:<path> to load data from, as described in UrnPolicyFile. |
validate | if 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. |
|
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).
name | the (possibly) hierarchical name of the property of interest. |
|
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.
names | the list object to be loaded |
topLevelOnly | if true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included. |
append | if false, the contents of the given list will be erased before loading the names. |
Definition at line 913 of file Policy.h.
|
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.
topLevelOnly | if true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included. |
Definition at line 934 of file Policy.h.
|
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.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not a boolean type. |
Definition at line 589 of file Policy.h.
|
inline |
return an array of values associated with the given name
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not the expected type. |
Definition at line 1031 of file Policy.h.
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&).
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not a Policy type. |
const ConstDictPtr lsst.pex::policy::Policy::getDictionary | ( | ) | 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.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not a double type. |
Definition at line 617 of file Policy.h.
|
inline |
return an array of values associated with the given name
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not the expected type. |
Definition at line 1040 of file Policy.h.
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.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if 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&).
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not a Policy type. |
|
inherited |
|
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.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not an integer type. |
Definition at line 603 of file Policy.h.
|
inline |
return an array of values associated with the given name
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not the expected type. |
Definition at line 1035 of file Policy.h.
|
staticinherited |
Return the memId of the next object to be allocated.
Definition at line 209 of file Citizen.cc.
|
inline |
return a "sub-Policy" identified by a given name.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not a Policy type. |
Definition at line 1019 of file Policy.h.
|
inline |
return a "sub-Policy" identified by a given name.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not a Policy type. |
Definition at line 1022 of file Policy.h.
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&).
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not a Policy type. |
|
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.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not an integer type. |
Definition at line 631 of file Policy.h.
|
inline |
return an array of values associated with the given name
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
NameNotFound | if no value is associated with the given name. |
TypeError | if the value associated the given name is not the expected type. |
Definition at line 1027 of file Policy.h.
|
static |
Given the human-readable name of a type ("bool", "int", "policy", etc), what is its ValueType (BOOL, STRING, etc.)? Throws BadNameError if unknown.
|
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 1007 of file Policy.h.
|
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.
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 1167 of file Policy.h.
bool lsst.pex::policy::Policy::getValue | ( | const std::string & | name | ) | const |
int lsst.pex::policy::Policy::getValue | ( | const std::string & | name | ) | const |
double lsst.pex::policy::Policy::getValue | ( | const std::string & | name | ) | const |
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 1178 of file Policy.h.
std::vector<int> lsst.pex::policy::Policy::getValueArray | ( | const std::string & | name | ) | const |
std::vector<bool> lsst.pex::policy::Policy::getValueArray | ( | const std::string & | name | ) | const |
std::vector<double> lsst.pex::policy::Policy::getValueArray | ( | const std::string & | name | ) | const |
|
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 1190 of file Policy.h.
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.
Policy::ValueType lsst.pex::policy::Policy::getValueType | ( | ) |
Policy::ValueType lsst.pex::policy::Policy::getValueType | ( | ) |
Policy::ValueType lsst.pex::policy::Policy::getValueType | ( | ) |
Policy::ValueType lsst.pex::policy::Policy::getValueType | ( | ) |
|
staticinherited |
Check all allocated blocks for corruption.
Definition at line 316 of file Citizen.cc.
|
staticinherited |
Called once when the memory system is being initialised.
Definition at line 196 of file Citizen.cc.
|
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).
name | the (possibly) hierarchical name of the property of interest. |
|
inline |
|
inline |
return true if it appears that this Policy actually contains dictionary definition data.
Definition at line 419 of file Policy.h.
|
inline |
|
inline |
return true if the value pointed to by the given name is a PolicyFile
Definition at line 997 of file Policy.h.
|
inline |
|
inline |
|
inline |
|
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.
strict | If 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, "{}"). |
Definition at line 775 of file Policy.h.
|
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.
strict | If 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, "{}"). |
repository | a 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. |
|
inherited |
Mark a Citizen as persistent and not destroyed until process end.
Definition at line 225 of file Citizen.cc.
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.
defaultPol | the policy to pull default values from. This may be a Dictionary; if so, the default values will drawn from the appropriate default keyword. |
keepForValidation | if true, and if defaultPol is a Dictionary, keep a reference to it for validation future updates to this Policy. |
errs | an 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. |
|
inline |
|
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.
names | the list object to be loaded |
topLevelOnly | if true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included. |
append | if false, the contents of the given list will be erased before loading the names. |
Definition at line 897 of file Policy.h.
|
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.
topLevelOnly | if 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.
|
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.
names | the list object to be loaded |
topLevelOnly | if true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included. |
append | if false, the contents of the given list will be erased before loading the names. |
Definition at line 902 of file Policy.h.
|
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.
topLevelOnly | if true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included. |
Definition at line 924 of file Policy.h.
|
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.
names | the list object to be loaded |
topLevelOnly | if true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included. |
append | if false, the contents of the given list will be erased before loading the names. |
Definition at line 907 of file Policy.h.
|
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.
topLevelOnly | if true, only parameter names at the top of the hierarchy will be returned; no hierarchical names will be included. |
Definition at line 929 of file Policy.h.
|
virtual |
print the contents of this policy to an output stream.
This is mainly intended for debugging purposes.
out | the output stream to write contents to |
label | a labeling string to lead the listing with. |
indent | a string to prepend each line with. |
|
inline |
|
inherited |
Return a string representation of a Citizen.
Definition at line 219 of file Citizen.cc.
|
inlineinherited |
Template boost::serialization function for the base class.
Doesn't actually do anything, since there is no data associated with the base. Inline to allow expansion wherever needed.
Definition at line 87 of file Persistable.h.
|
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
|
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
|
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
|
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
|
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
|
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
TypeError | if this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name. |
Definition at line 1064 of file Policy.h.
|
staticinherited |
Set the CorruptionCallback function.
func | function be called when block is found to be corrupted |
Definition at line 391 of file Citizen.cc.
|
staticinherited |
Set the DeleteCallback function.
func | function be called when desired block is deleted |
Definition at line 381 of file Citizen.cc.
|
staticinherited |
Call the current DeleteCallback when block is deleted.
id | Desired ID |
Definition at line 347 of file Citizen.cc.
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.
|
staticinherited |
Set the NewCallback function.
func | The new function to be called when a designated block is allocated |
Definition at line 371 of file Citizen.cc.
|
staticinherited |
Call the NewCallback when block is allocated.
id | Desired ID |
Definition at line 337 of file Citizen.cc.
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
(see
), this operation will be checked before it is performed, and if it would create an invalid state, it will not succeed, and a
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
and
are equivalent.
name | the name of the parameter. This can be a hierarchical name with fields delimited with "." |
value | the value–int, double, string or Policy–to associate with the name. |
TypeError | if this Policy is controlled by a Dictionary but the value type does not match the definition associated with the name. |
Definition at line 1203 of file Policy.h.
void lsst.pex::policy::Policy::setValue | ( | const std::string & | name, |
const bool & | value | ||
) |
void lsst.pex::policy::Policy::setValue | ( | const std::string & | name, |
const int & | value | ||
) |
void lsst.pex::policy::Policy::setValue | ( | const std::string & | name, |
const double & | value | ||
) |
|
virtual |
return a string representation of the value given by a name.
The string "<null>" is printed if the name does not exist.
name | the name of the parameter to string-ify |
indent | a 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.
|
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 1015 of file Policy.h.
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
is null, a ValidationError will be thrown.
errs | if non-null, any validation errors will be stored here instead of being thrown. |
|
inline |
|
static |