LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | 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
}
 an enumeration for the supported policy types More...
 
typedef std::shared_ptr< PolicyPtr
 
typedef std::shared_ptr< const PolicyConstPtr
 
typedef std::shared_ptr< Dictionary > DictPtr
 
typedef std::shared_ptr< const Dictionary > ConstDictPtr
 
typedef std::shared_ptr< PolicyFileFilePtr
 
typedef std::vector< bool > BoolArray
 
typedef std::vector< int > IntArray
 
typedef std::vector< double > DoubleArray
 
typedef std::vector< std::stringStringArray
 
typedef std::vector< PtrPolicyPtrArray
 
typedef std::vector< FilePtrFilePtrArray
 
typedef std::vector< ConstPtrConstPolicyPtrArray
 
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_infogetTypeInfo (const std::string &name) const
 return the type information for the underlying type associated with a given name. More...
 
const std::type_infotypeOf (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 >
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 PolicycreatePolicyFromUrn (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 PolicycreatePolicy (PolicySource &input, bool doIncludes=true, bool validate=true)
 create a Policy from a file. More...
 
static PolicycreatePolicy (const std::string &input, bool doIncludes=true, bool validate=true)
 create a Policy from a file. More...
 
static PolicycreatePolicy (PolicySource &input, const boost::filesystem::path &repos, bool validate=true)
 create a Policy from a file. More...
 
static PolicycreatePolicy (PolicySource &input, const std::string &repos, bool validate=true)
 create a Policy from a file. More...
 
static PolicycreatePolicy (PolicySource &input, const char *repos, bool validate=true)
 create a Policy from a file. More...
 
static PolicycreatePolicy (const std::string &input, const boost::filesystem::path &repos, bool validate=true)
 create a Policy from a file. More...
 
static PolicycreatePolicy (const std::string &input, const std::string &repos, bool validate=true)
 create a Policy from a file. More...
 
static PolicycreatePolicy (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...
 

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

◆ BoolArray

Definition at line 178 of file Policy.h.

◆ ConstDictPtr

Definition at line 175 of file Policy.h.

◆ ConstPolicyPtrArray

Definition at line 184 of file Policy.h.

◆ ConstPtr

Definition at line 173 of file Policy.h.

◆ DictPtr

Definition at line 174 of file Policy.h.

◆ DoubleArray

Definition at line 180 of file Policy.h.

◆ FilePtr

Definition at line 176 of file Policy.h.

◆ FilePtrArray

Definition at line 183 of file Policy.h.

◆ IntArray

Definition at line 179 of file Policy.h.

◆ memCallback

typedef memId(* lsst::daf::base::Citizen::memCallback) (const Citizen *ptr)
inherited

Definition at line 61 of file Citizen.h.

◆ memId

typedef unsigned long lsst::daf::base::Citizen::memId
inherited

Type of the block's ID.

Definition at line 58 of file Citizen.h.

◆ memNewCallback

typedef memId(* lsst::daf::base::Citizen::memNewCallback) (const memId cid)
inherited

A function used to register a callback.

Definition at line 60 of file Citizen.h.

◆ PolicyPtrArray

Definition at line 182 of file Policy.h.

◆ Ptr

Definition at line 172 of file Policy.h.

◆ StringArray

Definition at line 181 of file Policy.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited
Enumerator
magicSentinel 

Definition at line 88 of file Citizen.h.

◆ ValueType

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

◆ Policy() [1/8]

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

Create an empty policy.

◆ Policy() [2/8]

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.

◆ Policy() [3/8]

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.

◆ Policy() [4/8]

lsst.pex::policy::Policy::Policy ( const PolicySource source)
explicit

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

Parameters
source

◆ Policy() [5/8]

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.

◆ Policy() [6/8]

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.

◆ Policy() [7/8]

lsst.pex::policy::Policy::Policy ( const Policy pol)

deep-copy a Policy.

◆ ~Policy()

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

destroy this policy

◆ Policy() [8/8]

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  { }
Citizen(const std::type_info &)
Definition: Citizen.cc:163
Base class for all persistable classes.
Definition: Persistable.h:75

Member Function Documentation

◆ add() [1/7]

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 1079 of file Policy.h.

1079  {
1080  _validate(name, value, valueCount(name));
1081  POL_ADD(name, value->asPropertySet())
1082 }
#define POL_ADD(name, value)
Definition: Policy.h:1073
size_t valueCount(const std::string &name) const
return the number of values currently associated with a given name
Definition: Policy.h:940

◆ add() [2/7]

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.

◆ add() [3/7]

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 1083 of file Policy.h.

1083  {
1084  _validate(name, value, valueCount(name));
1085  POL_ADD(name, value);
1086 }
#define POL_ADD(name, value)
Definition: Policy.h:1073
size_t valueCount(const std::string &name) const
return the number of values currently associated with a given name
Definition: Policy.h:940

◆ add() [4/7]

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 1087 of file Policy.h.

1087  {
1088  _validate(name, value, valueCount(name));
1089  POL_ADD(name, value);
1090 }
#define POL_ADD(name, value)
Definition: Policy.h:1073
size_t valueCount(const std::string &name) const
return the number of values currently associated with a given name
Definition: Policy.h:940

◆ add() [5/7]

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 1091 of file Policy.h.

1091  {
1092  _validate(name, value, valueCount(name));
1093  POL_ADD(name, value);
1094 }
#define POL_ADD(name, value)
Definition: Policy.h:1073
size_t valueCount(const std::string &name) const
return the number of values currently associated with a given name
Definition: Policy.h:940

◆ add() [6/7]

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 1095 of file Policy.h.

1095  {
1096  _validate(name, value, valueCount(name));
1097  POL_ADD(name, value);
1098 }
#define POL_ADD(name, value)
Definition: Policy.h:1073
size_t valueCount(const std::string &name) const
return the number of values currently associated with a given name
Definition: Policy.h:940

◆ add() [7/7]

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 1099 of file Policy.h.

1099  {
1100  std::string v(value);
1101  _validate(name, v, valueCount(name));
1102  POL_ADD(name, v);
1103 }
STL class.
#define POL_ADD(name, value)
Definition: Policy.h:1073
size_t valueCount(const std::string &name) const
return the number of values currently associated with a given name
Definition: Policy.h:940

◆ addValue() [1/4]

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 1214 of file Policy.h.

1214  {
1215  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1216 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ addValue() [2/4]

template<>
void lsst.pex::policy::Policy::addValue ( const std::string name,
const bool &  value 
)

◆ addValue() [3/4]

template<>
void lsst.pex::policy::Policy::addValue ( const std::string name,
const int &  value 
)

◆ addValue() [4/4]

template<>
void lsst.pex::policy::Policy::addValue ( const std::string name,
const double &  value 
)

◆ asPropertySet()

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 1164 of file Policy.h.

1164 { return _data; }

◆ canValidate()

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.

◆ census() [1/3]

int lsst::daf::base::Citizen::census ( int  ,
memId  startingMemId = 0 
)
staticinherited

How many active Citizens are there?

Parameters
startingMemIdDon't print Citizens with lower IDs

Definition at line 238 of file Citizen.cc.

240  {
241  if (startingMemId == 0) { // easy
242  ReadGuard guard(citizenLock);
243  return _activeCitizens.size();
244  }
245 
246  int n = 0;
247  ReadGuard guard(citizenLock);
248  for (table::iterator cur = _activeCitizens.begin(); cur != _activeCitizens.end(); cur++) {
249  if (cur->first->_CitizenId >= startingMemId) {
250  n++;
251  }
252  }
253 
254  return n;
255 }
T end(T... args)
T size(T... args)
T begin(T... args)

◆ census() [2/3]

void lsst::daf::base::Citizen::census ( std::ostream stream,
memId  startingMemId = 0 
)
staticinherited

Print a list of all active Citizens to stream, sorted by ID.

Parameters
streamstream to print to
startingMemIdDon't print Citizens with lower IDs

Definition at line 259 of file Citizen.cc.

261  {
262  ReadGuard guard(citizenLock);
263 
265 
266  for (std::vector<Citizen const*>::const_iterator citizen = leaks->begin(), end = leaks->end();
267  citizen != end; ++citizen) {
268  if ((*citizen)->getId() >= startingMemId) {
269  stream << (*citizen)->repr() << "\n";
270  }
271  }
272 }
STL class.
STL class.
T begin(T... args)
int end
static const std::vector< const Citizen * > * census()
Return a (newly allocated) std::vector of active Citizens sorted by ID.
Definition: Citizen.cc:287

◆ census() [3/3]

std::vector< dafBase::Citizen const * > const * lsst::daf::base::Citizen::census ( )
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.

287  {
289  ReadGuard guard(citizenLock);
290  vec->reserve(_activeCitizens.size());
291 
292  for (table::iterator cur = _activeCitizens.begin(); cur != _activeCitizens.end(); cur++) {
293  vec->push_back(dynamic_cast<Citizen const*>(cur->first));
294  }
295 
296  std::sort(vec->begin(), vec->end(), cmpId);
297 
298  return vec;
299 }
T end(T... args)
T push_back(T... args)
T size(T... args)
STL class.
T begin(T... args)
T sort(T... args)
T reserve(T... args)

◆ createPolicy() [1/8]

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 1110 of file Policy.h.

1112 {
1113  return _createPolicy(input, doIncludes, boost::filesystem::path(), validate);
1114 }
void validate(ValidationError *errs=0) const
Validate this policy, using its stored dictionary.

◆ createPolicy() [2/8]

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 1116 of file Policy.h.

1118 {
1119  return _createPolicy(input, doIncludes, boost::filesystem::path(), validate);
1120 }
void validate(ValidationError *errs=0) const
Validate this policy, using its stored dictionary.

◆ createPolicy() [3/8]

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 1122 of file Policy.h.

1125 {
1126  return _createPolicy(input, true, repository, validate);
1127 }
void validate(ValidationError *errs=0) const
Validate this policy, using its stored dictionary.

◆ createPolicy() [4/8]

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 1129 of file Policy.h.

1132 {
1133  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1134 }
void validate(ValidationError *errs=0) const
Validate this policy, using its stored dictionary.

◆ createPolicy() [5/8]

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 1136 of file Policy.h.

1139 {
1140  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1141 }
void validate(ValidationError *errs=0) const
Validate this policy, using its stored dictionary.

◆ createPolicy() [6/8]

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 1143 of file Policy.h.

1146 {
1147  return _createPolicy(input, true, repository, validate);
1148 }
void validate(ValidationError *errs=0) const
Validate this policy, using its stored dictionary.

◆ createPolicy() [7/8]

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 1150 of file Policy.h.

1153 {
1154  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1155 }
void validate(ValidationError *errs=0) const
Validate this policy, using its stored dictionary.

◆ createPolicy() [8/8]

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 1157 of file Policy.h.

1160 {
1161  return _createPolicy(input, true, boost::filesystem::path(repository), validate);
1162 }
void validate(ValidationError *errs=0) const
Validate this policy, using its stored dictionary.

◆ createPolicyFile()

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.

◆ createPolicyFromUrn()

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.

◆ exists()

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 948 of file Policy.h.

948  {
949  return _data->exists(name);
950 }

◆ fileNames() [1/2]

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 }
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33

◆ fileNames() [2/2]

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 934 of file Policy.h.

934  {
935  StringArray out;
936  _names(out, topLevelOnly, true, 2);
937  return out;
938 }
std::vector< std::string > StringArray
Definition: Policy.h:181

◆ getBool()

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  }
#define POL_GETSCALAR(name, type, vtype)
Definition: Policy.h:52

◆ getBoolArray()

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 1031 of file Policy.h.

1031  {
1032  POL_GETLIST(name, bool, BOOL)
1033 }
#define POL_GETLIST(name, type, vtype)
Definition: Policy.h:63

◆ getConstPolicyArray()

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.

◆ getDictionary()

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.

◆ getDouble()

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  }
#define POL_GETSCALAR(name, type, vtype)
Definition: Policy.h:52

◆ getDoubleArray()

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 1040 of file Policy.h.

1040  {
1041  POL_GETLIST(name, double, DOUBLE)
1042 }
#define POL_GETLIST(name, type, vtype)
Definition: Policy.h:63

◆ getFile()

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.

◆ getFileArray()

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.

◆ getId()

dafBase::Citizen::memId lsst::daf::base::Citizen::getId ( ) const
inherited

Return the Citizen's ID.

Definition at line 206 of file Citizen.cc.

206 { return _CitizenId; }

◆ getInt()

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  }
#define POL_GETSCALAR(name, type, vtype)
Definition: Policy.h:52

◆ getIntArray()

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 1035 of file Policy.h.

1035  {
1036  POL_GETLIST(name, int, INT)
1037 }
#define POL_GETLIST(name, type, vtype)
Definition: Policy.h:63

◆ getNextMemId()

dafBase::Citizen::memId lsst::daf::base::Citizen::getNextMemId ( )
staticinherited

Return the memId of the next object to be allocated.

Definition at line 209 of file Citizen.cc.

209 { return _nextMemId(); }

◆ getPolicy() [1/2]

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 1019 of file Policy.h.

1019  {
1020  return ConstPtr(new Policy(_data->get<lsst::daf::base::PropertySet::Ptr>(name)));
1021 }
std::shared_ptr< const Policy > ConstPtr
Definition: Policy.h:173
Policy()
Create an empty policy.
T get(T... args)

◆ getPolicy() [2/2]

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 1022 of file Policy.h.

1022  {
1023  return Ptr(new Policy(_data->get<lsst::daf::base::PropertySet::Ptr>(name)));
1024 }
Policy()
Create an empty policy.
std::shared_ptr< Policy > Ptr
Definition: Policy.h:172
T get(T... args)

◆ getPolicyArray()

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.

◆ getString()

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  {
633  }
STL class.
#define POL_GETSCALAR(name, type, vtype)
Definition: Policy.h:52

◆ getStringArray()

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 1027 of file Policy.h.

1027  {
1028  return _data->getArray<std::string>(name);
1029 }
STL class.

◆ getTypeByName()

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.

◆ getTypeInfo()

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 1007 of file Policy.h.

1008 {
1009  try { return _data->typeOf(name); }
1011  throw LSST_EXCEPT(NameNotFound, name);
1012  }
1013 }
Reports attempts to access elements using an invalid key.
Definition: Runtime.h:151
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ getTypeName()

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  }
static ValueType getValueType()
A template-ized way to get the ValueType.
Definition: Policy.h:1190
static const char *const typeName[]
c-string forms for the supported value types.
Definition: Policy.h:205

◆ getValue() [1/4]

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 1167 of file Policy.h.

1167  {
1168  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1169 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ getValue() [2/4]

template<>
bool lsst.pex::policy::Policy::getValue ( const std::string name) const

◆ getValue() [3/4]

template<>
int lsst.pex::policy::Policy::getValue ( const std::string name) const

◆ getValue() [4/4]

template<>
double lsst.pex::policy::Policy::getValue ( const std::string name) const

◆ getValueArray() [1/4]

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 1178 of file Policy.h.

1178  {
1179  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1180 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ getValueArray() [2/4]

template<>
std::vector<int> lsst.pex::policy::Policy::getValueArray ( const std::string name) const

◆ getValueArray() [3/4]

template<>
std::vector<bool> lsst.pex::policy::Policy::getValueArray ( const std::string name) const

◆ getValueArray() [4/4]

template<>
std::vector<double> lsst.pex::policy::Policy::getValueArray ( const std::string name) const

◆ getValueType() [1/6]

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 1190 of file Policy.h.

1190  {
1191  throw LSST_EXCEPT(TypeError, "unknown", "not implemented for this type");
1192 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ getValueType() [2/6]

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.

◆ getValueType() [3/6]

template<>
Policy::ValueType lsst.pex::policy::Policy::getValueType ( )

◆ getValueType() [4/6]

template<>
Policy::ValueType lsst.pex::policy::Policy::getValueType ( )

◆ getValueType() [5/6]

template<>
Policy::ValueType lsst.pex::policy::Policy::getValueType ( )

◆ getValueType() [6/6]

template<>
Policy::ValueType lsst.pex::policy::Policy::getValueType ( )

◆ hasBeenCorrupted()

bool lsst::daf::base::Citizen::hasBeenCorrupted ( )
staticinherited

Check all allocated blocks for corruption.

Definition at line 316 of file Citizen.cc.

316  {
317  ReadGuard guard(citizenLock);
318  for (table::iterator cur = _activeCitizens.begin(); cur != _activeCitizens.end(); cur++) {
319  if (cur->first->_hasBeenCorrupted()) {
320  return true;
321  }
322  }
323  for (table::iterator cur = _persistentCitizens.begin(); cur != _persistentCitizens.end(); cur++) {
324  if (cur->first->_hasBeenCorrupted()) {
325  return true;
326  }
327  }
328 
329  return false;
330 }
T end(T... args)
T begin(T... args)

◆ init()

int lsst::daf::base::Citizen::init ( )
staticinherited

Called once when the memory system is being initialised.

Definition at line 196 of file Citizen.cc.

196  {
197  volatile int dummy = 1;
198  return dummy;
199 }

◆ isArray()

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 944 of file Policy.h.

944  {
945  return _data->isArray(name);
946 }

◆ isBool()

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 952 of file Policy.h.

952  {
953  try {
954  return (_data->typeOf(name) == typeid(bool));
955  }
956  catch (...) {
957  return false;
958  }
959 }

◆ isDictionary()

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
return true if a value exists in this policy for the given name.
Definition: Policy.h:948

◆ isDouble()

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 970 of file Policy.h.

970  {
971  try {
972  return (_data->typeOf(name) == typeid(double));
973  }
974  catch (...) {
975  return false;
976  }
977 }

◆ isFile()

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 997 of file Policy.h.

997  {
998 
999  try {
1000  return (getValueType(name) == FILE);
1001  }
1002  catch (...) {
1003  return false;
1004  }
1005 }
static ValueType getValueType()
A template-ized way to get the ValueType.
Definition: Policy.h:1190

◆ isInt()

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 961 of file Policy.h.

961  {
962  try {
963  return (_data->typeOf(name) == typeid(int));
964  }
965  catch (...) {
966  return false;
967  }
968 }

◆ isPolicy()

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 988 of file Policy.h.

988  {
989  try {
990  return _data->isPropertySetPtr(name);
991  }
992  catch (...) {
993  return false;
994  }
995 }

◆ isString()

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 979 of file Policy.h.

979  {
980  try {
981  return (_data->typeOf(name) == typeid(std::string));
982  }
983  catch (...) {
984  return false;
985  }
986 }
STL class.

◆ loadPolicyFiles() [1/2]

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)
Recursively replace all PolicyFile values with the contents of the files they refer to...
Definition: Policy.h:775

◆ loadPolicyFiles() [2/2]

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.

◆ markPersistent()

void lsst::daf::base::Citizen::markPersistent ( void  )
inherited

Mark a Citizen as persistent and not destroyed until process end.

Definition at line 225 of file Citizen.cc.

225  {
226  WriteGuard guard(citizenLock);
227  _persistentCitizens[this] = _activeCitizens[this];
228  _activeCitizens.erase(this);
229 }
T erase(T... args)

◆ mergeDefaults()

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

◆ nameCount()

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  }

◆ names() [1/2]

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 }
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33

◆ names() [2/2]

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  StringArray out;
921  _names(out, topLevelOnly, true, 7);
922  return out;
923 }
std::vector< std::string > StringArray
Definition: Policy.h:181

◆ paramNames() [1/2]

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 }
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33

◆ paramNames() [2/2]

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 924 of file Policy.h.

924  {
925  StringArray out;
926  _names(out, topLevelOnly, true, 4);
927  return out;
928 }
std::vector< std::string > StringArray
Definition: Policy.h:181

◆ policyNames() [1/2]

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 }
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33

◆ policyNames() [2/2]

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 929 of file Policy.h.

929  {
930  StringArray out;
931  _names(out, topLevelOnly, true, 1);
932  return out;
933 }
std::vector< std::string > StringArray
Definition: Policy.h:181

◆ print()

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.

◆ remove()

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 1106 of file Policy.h.

1106  {
1107  _data->remove(name);
1108 }

◆ repr()

std::string lsst::daf::base::Citizen::repr ( ) const
inherited

Return a string representation of a Citizen.

Definition at line 219 of file Citizen.cc.

219  {
220  return boost::str(boost::format("%d: %08x %s") % _CitizenId % this %
221  lsst::utils::demangleType(_typeName));
222 }
std::string demangleType(std::string const _typeName)
Definition: Demangle.cc:113
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:168

◆ serialize()

template<class Archive >
void lsst::daf::base::Persistable::serialize ( Archive &  ,
unsigned int  const 
)
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.

87 {}

◆ set() [1/7]

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 1044 of file Policy.h.

1044  {
1045  _validate(name, value);
1046  _data->set(name, value->asPropertySet());
1047 }

◆ set() [2/7]

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.

◆ set() [3/7]

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 1048 of file Policy.h.

1048  {
1049  _validate(name, value);
1050  _data->set(name, value);
1051 }

◆ set() [4/7]

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 1052 of file Policy.h.

1052  {
1053  _validate(name, value);
1054  _data->set(name, value);
1055 }

◆ set() [5/7]

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 1056 of file Policy.h.

1056  {
1057  _validate(name, value);
1058  _data->set(name, value);
1059 }

◆ set() [6/7]

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 1060 of file Policy.h.

1060  {
1061  _validate(name, value);
1062  _data->set(name, value);
1063 }

◆ set() [7/7]

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 1064 of file Policy.h.

1064  {
1065  if (value == NULL)
1067  std::string("Attempted to assign NULL value to ")
1068  + name + ".");
1069  _validate(name, std::string(value));
1070  _data->set(name, std::string(value));
1071 }
STL class.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Reports invalid arguments.
Definition: Runtime.h:66

◆ setCorruptionCallback()

dafBase::Citizen::memCallback lsst::daf::base::Citizen::setCorruptionCallback ( Citizen::memCallback  func)
staticinherited

Set the CorruptionCallback function.

Parameters
funcfunction be called when block is found to be corrupted

Definition at line 391 of file Citizen.cc.

393  {
394  Citizen::memCallback old = _corruptionCallback;
395  _corruptionCallback = func;
396 
397  return old;
398 }
memId(* memCallback)(const Citizen *ptr)
Definition: Citizen.h:61

◆ setDeleteCallback()

dafBase::Citizen::memCallback lsst::daf::base::Citizen::setDeleteCallback ( Citizen::memCallback  func)
staticinherited

Set the DeleteCallback function.

Parameters
funcfunction be called when desired block is deleted

Definition at line 381 of file Citizen.cc.

383  {
384  Citizen::memCallback old = _deleteCallback;
385  _deleteCallback = func;
386 
387  return old;
388 }
memId(* memCallback)(const Citizen *ptr)
Definition: Citizen.h:61

◆ setDeleteCallbackId()

dafBase::Citizen::memId lsst::daf::base::Citizen::setDeleteCallbackId ( Citizen::memId  id)
staticinherited

Call the current DeleteCallback when block is deleted.

Parameters
idDesired ID

Definition at line 347 of file Citizen.cc.

348  {
349  WriteGuard guard(citizenLock);
350  Citizen::memId oldId = _deleteId;
351  _deleteId = id;
352 
353  return oldId;
354 }
unsigned long memId
Type of the block&#39;s ID.
Definition: Citizen.h:58
table::Key< int > id
Definition: Detector.cc:166

◆ setDictionary()

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.

◆ setNewCallback()

dafBase::Citizen::memNewCallback lsst::daf::base::Citizen::setNewCallback ( Citizen::memNewCallback  func)
staticinherited

Set the NewCallback function.

Parameters
funcThe new function to be called when a designated block is allocated

Definition at line 371 of file Citizen.cc.

373  {
374  Citizen::memNewCallback old = _newCallback;
375  _newCallback = func;
376 
377  return old;
378 }
memId(* memNewCallback)(const memId cid)
A function used to register a callback.
Definition: Citizen.h:60

◆ setNewCallbackId()

dafBase::Citizen::memId lsst::daf::base::Citizen::setNewCallbackId ( Citizen::memId  id)
staticinherited

Call the NewCallback when block is allocated.

Parameters
idDesired ID

Definition at line 337 of file Citizen.cc.

338  {
339  WriteGuard guard(citizenLock);
340  Citizen::memId oldId = _newId;
341  _newId = id;
342 
343  return oldId;
344 }
unsigned long memId
Type of the block&#39;s ID.
Definition: Citizen.h:58
table::Key< int > id
Definition: Detector.cc:166

◆ setValue() [1/4]

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 1203 of file Policy.h.

1203  {
1204  throw LSST_EXCEPT(TypeError, name, "not implemented for this type");
1205 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ setValue() [2/4]

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

◆ setValue() [3/4]

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

◆ setValue() [4/4]

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

◆ str()

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.

◆ toString()

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.

◆ typeOf()

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 1015 of file Policy.h.

1015  {
1016  return getTypeInfo(name);
1017 }
const std::type_info & getTypeInfo(const std::string &name) const
return the type information for the underlying type associated with a given name. ...
Definition: Policy.h:1007

◆ validate()

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.

◆ valueCount()

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 940 of file Policy.h.

940  {
941  return _data->valueCount(name);
942 }

Member Data Documentation

◆ typeName

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: