LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
|
Class for storing ordered metadata with comments. More...
#include <PropertyList.h>
Public Types | |
typedef boost::shared_ptr < PropertyList > | Ptr |
typedef boost::shared_ptr < PropertyList const > | ConstPtr |
Public Types inherited from lsst::daf::base::PropertySet | |
typedef boost::shared_ptr < PropertySet > | Ptr |
typedef boost::shared_ptr < PropertySet const > | ConstPtr |
Public Types inherited from lsst::daf::base::Persistable | |
typedef boost::shared_ptr < Persistable > | Ptr |
Public Types inherited from lsst::daf::base::Citizen | |
enum | { magicSentinel = 0xdeadbeef } |
typedef unsigned long | memId |
Type of the block's ID. More... | |
typedef memId(* | memNewCallback )(const memId cid) |
A function used to register a callback. More... | |
typedef memId(* | memCallback )(const Citizen *ptr) |
Public Member Functions | |
PropertyList (void) | |
virtual | ~PropertyList (void) |
virtual PropertySet::Ptr | deepCopy (void) const |
template<typename T > | |
T | get (std::string const &name) const |
template<typename T > | |
T | get (std::string const &name, T const &defaultValue) const |
template<typename T > | |
std::vector< T > | getArray (std::string const &name) const |
std::string const & | getComment (std::string const &name) const |
std::vector< std::string > | getOrderedNames (void) const |
std::list< std::string > ::const_iterator | begin (void) const |
std::list< std::string > ::const_iterator | end (void) const |
virtual std::string | toString (bool topLevelOnly=false, std::string const &indent="") const |
template<typename T > | |
void | set (std::string const &name, T const &value, bool inPlace=true) |
void | set (std::string const &name, PropertySet::Ptr const &value, bool inPlace=true) |
template<typename T > | |
void | set (std::string const &name, std::vector< T > const &value, bool inPlace=true) |
void | set (std::string const &name, char const *value, bool inPlace=true) |
template<typename T > | |
void | add (std::string const &name, T const &value, bool inPlace=true) |
template<typename T > | |
void | add (std::string const &name, std::vector< T > const &value, bool inPlace=true) |
void | add (std::string const &name, char const *value, bool inPlace=true) |
template<typename T > | |
void | set (std::string const &name, T const &value, std::string const &comment, bool inPlace=true) |
template<typename T > | |
void | set (std::string const &name, std::vector< T > const &value, std::string const &comment, bool inPlace=true) |
void | set (std::string const &name, char const *value, std::string const &comment, bool inPlace=true) |
template<typename T > | |
void | add (std::string const &name, T const &value, std::string const &comment, bool inPlace=true) |
template<typename T > | |
void | add (std::string const &name, std::vector< T > const &value, std::string const &comment, bool inPlace=true) |
void | add (std::string const &name, char const *value, std::string const &comment, bool inPlace=true) |
template<typename T > | |
void | set (std::string const &name, T const &value, char const *comment, bool inPlace=true) |
template<typename T > | |
void | set (std::string const &name, std::vector< T > const &value, char const *comment, bool inPlace=true) |
void | set (std::string const &name, char const *value, char const *comment, bool inPlace=true) |
template<typename T > | |
void | add (std::string const &name, T const &value, char const *comment, bool inPlace=true) |
template<typename T > | |
void | add (std::string const &name, std::vector< T > const &value, char const *comment, bool inPlace=true) |
void | add (std::string const &name, char const *value, char const *comment, bool inPlace=true) |
virtual void | copy (std::string const &dest, PropertySet::ConstPtr source, std::string const &name) |
virtual void | combine (PropertySet::ConstPtr source) |
virtual void | copy (std::string const &dest, PropertySet::ConstPtr source, std::string const &name, bool inPlace) |
virtual void | combine (PropertySet::ConstPtr source, bool inPlace) |
virtual void | remove (std::string const &name) |
template<typename T > | |
vector< T > | getArray (string const &name) const |
Public Member Functions inherited from lsst::daf::base::PropertySet | |
PropertySet (bool flat=false) | |
virtual | ~PropertySet (void) |
size_t | nameCount (bool topLevelOnly=true) const |
std::vector< std::string > | names (bool topLevelOnly=true) const |
std::vector< std::string > | paramNames (bool topLevelOnly=true) const |
std::vector< std::string > | propertySetNames (bool topLevelOnly=true) const |
bool | exists (std::string const &name) const |
bool | isArray (std::string const &name) const |
bool | isPropertySetPtr (std::string const &name) const |
size_t | valueCount (std::string const &name) const |
std::type_info const & | typeOf (std::string const &name) const |
template<typename T > | |
T | get (std::string const &name) const |
template<typename T > | |
T | get (std::string const &name, T const &defaultValue) const |
template<typename T > | |
std::vector< T > | getArray (std::string const &name) const |
bool | getAsBool (std::string const &name) const |
int | getAsInt (std::string const &name) const |
int64_t | getAsInt64 (std::string const &name) const |
double | getAsDouble (std::string const &name) const |
std::string | getAsString (std::string const &name) const |
PropertySet::Ptr | getAsPropertySetPtr (std::string const &name) const |
Persistable::Ptr | getAsPersistablePtr (std::string const &name) const |
template<typename T > | |
void | set (std::string const &name, T const &value) |
template<typename T > | |
void | set (std::string const &name, std::vector< T > const &value) |
void | set (std::string const &name, char const *value) |
template<typename T > | |
void | add (std::string const &name, T const &value) |
template<typename T > | |
void | add (std::string const &name, std::vector< T > const &value) |
void | add (std::string const &name, char const *value) |
template<typename T > | |
vector< T > | getArray (string const &name) const |
Public Member Functions inherited from lsst::daf::base::Persistable | |
Persistable (void) | |
virtual | ~Persistable (void) |
template<class Archive > | |
void | serialize (Archive &, unsigned int const) |
Public Member Functions inherited from lsst::daf::base::Citizen | |
Citizen (const std::type_info &) | |
Citizen (Citizen const &) | |
~Citizen () | |
Citizen & | operator= (Citizen const &) |
std::string | repr () const |
Return a string representation of a Citizen. More... | |
void | markPersistent (void) |
Mark a Citizen as persistent and not destroyed until process end. More... | |
memId | getId () const |
Return the Citizen's ID. More... | |
Private Types | |
typedef std::tr1::unordered_map < std::string, std::string > | CommentMap |
Private Member Functions | |
virtual void | _set (std::string const &name, boost::shared_ptr< std::vector< boost::any > > vp) |
virtual void | _moveToEnd (std::string const &name) |
virtual void | _commentOrderFix (std::string const &name, std::string const &comment, bool inPlace) |
Private Attributes | |
CommentMap | _comments |
std::list< std::string > | _order |
Additional Inherited Members | |
Static Public Member Functions inherited from lsst::daf::base::Citizen | |
static bool | hasBeenCorrupted () |
Check all allocated blocks for corruption. More... | |
static memId | getNextMemId () |
Return the memId of the next object to be allocated. More... | |
static int | init () |
Called once when the memory system is being initialised. More... | |
static int | census (int, memId startingMemId=0) |
How many active Citizens are there? More... | |
static void | census (std::ostream &stream, memId startingMemId=0) |
Print a list of all active Citizens to stream, sorted by ID. More... | |
static const std::vector < const Citizen * > * | census () |
Return a (newly allocated) std::vector of active Citizens sorted by ID. More... | |
static memId | setNewCallbackId (memId id) |
Call the NewCallback when block is allocated. More... | |
static memId | setDeleteCallbackId (memId id) |
Call the current DeleteCallback when block is deleted. More... | |
static memNewCallback | setNewCallback (memNewCallback func) |
Set the NewCallback function. More... | |
static memCallback | setDeleteCallback (memCallback func) |
Set the DeleteCallback function. More... | |
static memCallback | setCorruptionCallback (memCallback func) |
Set the CorruptionCallback function. More... | |
Protected Member Functions inherited from lsst::daf::base::PropertySet | |
virtual void | _add (std::string const &name, boost::shared_ptr< std::vector< boost::any > > vp) |
virtual std::string | _format (std::string const &name) const |
Class for storing ordered metadata with comments.
This class stores key/value pairs like PropertySet, of which it is a subclass. The difference is that the PropertyList maintains the order of the key/value pairs according to how they were inserted. By default, replacing the value of an existing key does not change its ordering. In addition, a comment string may be associated with each key/value pair.
The main motivating use case for PropertyList is FITS headers.
PropertyLists are not truly hierarchical, although they accept dotted paths as keys. If a PropertySet or PropertyList is added as a value to a PropertyList, the hierarchical pathnames are flattened into the resulting PropertyList.
Definition at line 81 of file PropertyList.h.
|
private |
Definition at line 201 of file PropertyList.h.
typedef boost::shared_ptr<PropertyList const> lsst::daf::base::PropertyList::ConstPtr |
Definition at line 85 of file PropertyList.h.
typedef boost::shared_ptr<PropertyList> lsst::daf::base::PropertyList::Ptr |
Definition at line 84 of file PropertyList.h.
lsst::daf::base::PropertyList::PropertyList | ( | void | ) |
|
virtual |
|
privatevirtual |
Definition at line 495 of file PropertyList.cc.
|
privatevirtual |
Definition at line 490 of file PropertyList.cc.
|
privatevirtual |
Finds the property name (possibly hierarchical) and sets or replaces its value with the given vector of values. Hook for subclass overrides of top-level setting.
[in] | name | Property name to find, possibly hierarchical. |
[in] | vp | shared_ptr to vector of values. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Reimplemented from lsst::daf::base::PropertySet.
Definition at line 481 of file PropertyList.cc.
void lsst::daf::base::PropertyList::add | ( | std::string const & | name, |
T const & | value, | ||
bool | inPlace = true |
||
) |
Appends a single value to the vector of values for a property name (possibly hierarchical). Sets the value if the property does not exist.
[in] | name | Property name to append to, possibly hierarchical. |
[in] | value | Value to append. |
[in] | inPlace | If false, property is moved to end of list. |
TypeError | Type does not match existing values. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 255 of file PropertyList.cc.
void lsst::daf::base::PropertyList::add | ( | std::string const & | name, |
std::vector< T > const & | value, | ||
bool | inPlace = true |
||
) |
Appends a vector of values to the vector of values for a property name (possibly hierarchical). Sets the values if the property does not exist.
[in] | name | Property name to append to, possibly hierarchical. |
[in] | value | Vector of values to append. |
[in] | inPlace | If false, property is moved to end of list. |
TypeError | Type does not match existing values. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 288 of file PropertyList.cc.
void lsst::daf::base::PropertyList::add | ( | std::string const & | name, |
char const * | value, | ||
bool | inPlace = true |
||
) |
Appends a char const*
value to the vector of values for a property name (possibly hierarchical). Sets the value if the property does not exist.
[in] | name | Property name to append to, possibly hierarchical. |
[in] | value | Value to append. |
[in] | inPlace | If false, property is moved to end of list. |
TypeError | Type does not match existing values. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 272 of file PropertyList.cc.
void lsst::daf::base::PropertyList::add | ( | std::string const & | name, |
T const & | value, | ||
std::string const & | comment, | ||
bool | inPlace = true |
||
) |
Appends a single value to the vector of values for a property name (possibly hierarchical). Sets the value if the property does not exist.
[in] | name | Property name to append to, possibly hierarchical. |
[in] | value | Value to append. |
[in] | comment | Comment to set. |
[in] | inPlace | If false, property is moved to end of list. |
TypeError | Type does not match existing values. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 356 of file PropertyList.cc.
void lsst::daf::base::PropertyList::add | ( | std::string const & | name, |
std::vector< T > const & | value, | ||
std::string const & | comment, | ||
bool | inPlace = true |
||
) |
Appends a vector of values to the vector of values for a property name (possibly hierarchical). Sets the values if the property does not exist.
[in] | name | Property name to append to, possibly hierarchical. |
[in] | value | Vector of values to append. |
[in] | comment | Comment to set. |
[in] | inPlace | If false, property is moved to end of list. |
TypeError | Type does not match existing values. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 392 of file PropertyList.cc.
void lsst::daf::base::PropertyList::add | ( | std::string const & | name, |
char const * | value, | ||
std::string const & | comment, | ||
bool | inPlace = true |
||
) |
Appends a char const*
value to the vector of values for a property name (possibly hierarchical). Sets the value if the property does not exist.
[in] | name | Property name to append to, possibly hierarchical. |
[in] | value | String value to append. |
[in] | comment | Comment to set. |
[in] | inPlace | If false, property is moved to end of list. |
TypeError | Type does not match existing values. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 374 of file PropertyList.cc.
|
inline |
Definition at line 168 of file PropertyList.h.
|
inline |
Definition at line 173 of file PropertyList.h.
|
inline |
Definition at line 178 of file PropertyList.h.
std::list< std::string >::const_iterator lsst::daf::base::PropertyList::begin | ( | void | ) | const |
Definition at line 143 of file PropertyList.cc.
|
inlinevirtual |
Appends all value vectors from the source to their corresponding properties. Sets values if a property does not exist.
[in] | source | PropertySet::Ptr for the source PropertySet. |
TypeError | Type does not match existing values. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Reimplemented from lsst::daf::base::PropertySet.
Definition at line 188 of file PropertyList.h.
|
virtual |
Appends all value vectors from the source to their corresponding properties. Sets values if a property does not exist.
[in] | source | PropertySet::Ptr for the source PropertySet. |
[in] | inPlace | If false, existing properties are moved to end of list. |
TypeError | Type does not match existing values. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 437 of file PropertyList.cc.
|
inlinevirtual |
Replaces a single value vector in the destination with one from the source.
[in] | dest | Destination property name. |
[in] | source | PropertySet::Ptr for the source PropertySet. |
[in] | name | Property name to extract. |
TypeError | Type does not match existing values. |
InvalidParameterError | Name does not exist in source. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Reimplemented from lsst::daf::base::PropertySet.
Definition at line 184 of file PropertyList.h.
|
virtual |
Replaces a single value vector in the destination with one from the source.
[in] | dest | Destination property name. |
[in] | source | PropertySet::Ptr for the source PropertySet. |
[in] | name | Property name to extract. |
[in] | inPlace | If false, property is moved to end of list. |
TypeError | Type does not match existing values. |
InvalidParameterError | Name does not exist in source. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 413 of file PropertyList.cc.
|
virtual |
Copy the PropertyList and all of its contents.
Reimplemented from lsst::daf::base::PropertySet.
Definition at line 72 of file PropertyList.cc.
std::list< std::string >::const_iterator lsst::daf::base::PropertyList::end | ( | void | ) | const |
Definition at line 148 of file PropertyList.cc.
T lsst::daf::base::PropertyList::get | ( | std::string const & | name | ) | const |
Get the last value for a property name (possibly hierarchical). Note that the type must be explicitly specified for this template:
[in] | name | Property name to examine, possibly hierarchical. |
NotFoundError | Property does not exist. |
TypeError | Value does not match desired type. |
Definition at line 91 of file PropertyList.cc.
T lsst::daf::base::PropertyList::get | ( | std::string const & | name, |
T const & | defaultValue | ||
) | const |
Get the last value for a property name (possibly hierarchical). Returns the provided defaultValue if the property does not exist. Note that the type must be explicitly specified for this template:
[in] | name | Property name to examine, possibly hierarchical. |
[in] | defaultValue | Default value to return if property does not exist. |
TypeError | Value does not match desired type. |
Definition at line 105 of file PropertyList.cc.
std::vector<T> lsst::daf::base::PropertyList::getArray | ( | std::string const & | name | ) | const |
vector<T> lsst::daf::base::PropertyList::getArray | ( | string const & | name | ) | const |
Get the vector of values for a property name (possibly hierarchical). Note that the type must be explicitly specified for this template:
[in] | name | Property name to examine, possibly hierarchical. |
NotFoundError | Property does not exist. |
TypeError | Value does not match desired type. |
Definition at line 118 of file PropertyList.cc.
std::string const & lsst::daf::base::PropertyList::getComment | ( | std::string const & | name | ) | const |
Get the comment for a string property name (possibly hierarchical).
[in] | name | Property name to examine, possibly hierarchical. |
NotFoundError | Property does not exist. |
Definition at line 128 of file PropertyList.cc.
std::vector< std::string > lsst::daf::base::PropertyList::getOrderedNames | ( | void | ) | const |
Definition at line 133 of file PropertyList.cc.
|
virtual |
Removes all values for a property name (possibly hierarchical). Does nothing if the property does not exist.
[in] | name | Property name to remove, possibly hierarchical. |
Reimplemented from lsst::daf::base::PropertySet.
Definition at line 471 of file PropertyList.cc.
void lsst::daf::base::PropertyList::set | ( | std::string const & | name, |
T const & | value, | ||
bool | inPlace = true |
||
) |
Replace all values for a property name (possibly hierarchical) with a new value.
[in] | name | Property name to set, possibly hierarchical. |
[in] | value | Value to set. |
[in] | inPlace | If false, property is moved to end of list. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 188 of file PropertyList.cc.
void lsst::daf::base::PropertyList::set | ( | std::string const & | name, |
PropertySet::Ptr const & | value, | ||
bool | inPlace = true |
||
) |
Definition at line 196 of file PropertyList.cc.
void lsst::daf::base::PropertyList::set | ( | std::string const & | name, |
std::vector< T > const & | value, | ||
bool | inPlace = true |
||
) |
Replace all values for a property name (possibly hierarchical) with a vector of new values.
[in] | name | Property name to set, possibly hierarchical. |
[in] | value | Vector of values to set. |
[in] | inPlace | If false, property is moved to end of list. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 238 of file PropertyList.cc.
void lsst::daf::base::PropertyList::set | ( | std::string const & | name, |
char const * | value, | ||
bool | inPlace = true |
||
) |
Replace all values for a property name (possibly hierarchical) with a string value.
[in] | name | Property name to set, possibly hierarchical. |
[in] | value | Character string (converted to std::string ). |
[in] | inPlace | If false, property is moved to end of list. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 222 of file PropertyList.cc.
void lsst::daf::base::PropertyList::set | ( | std::string const & | name, |
T const & | value, | ||
std::string const & | comment, | ||
bool | inPlace = true |
||
) |
Replace all values for a property name (possibly hierarchical) with a new value.
[in] | name | Property name to set, possibly hierarchical. |
[in] | value | Value to set. |
[in] | comment | Comment to set. |
[in] | inPlace | If false, property is moved to end of list. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 309 of file PropertyList.cc.
void lsst::daf::base::PropertyList::set | ( | std::string const & | name, |
std::vector< T > const & | value, | ||
std::string const & | comment, | ||
bool | inPlace = true |
||
) |
Replace all values for a property name (possibly hierarchical) with a vector of new values.
[in] | name | Property name to set, possibly hierarchical. |
[in] | value | Vector of values to set. |
[in] | comment | Comment to set. |
[in] | inPlace | If false, property is moved to end of list. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 339 of file PropertyList.cc.
void lsst::daf::base::PropertyList::set | ( | std::string const & | name, |
char const * | value, | ||
std::string const & | comment, | ||
bool | inPlace = true |
||
) |
Replace all values for a property name (possibly hierarchical) with a string value.
[in] | name | Property name to set, possibly hierarchical. |
[in] | value | Character string value to set. |
[in] | comment | Comment to set. |
[in] | inPlace | If false, property is moved to end of list. |
InvalidParameterError | Hierarchical name uses non-PropertySet. |
Definition at line 324 of file PropertyList.cc.
|
inline |
Definition at line 153 of file PropertyList.h.
|
inline |
Definition at line 158 of file PropertyList.h.
|
inline |
Definition at line 163 of file PropertyList.h.
|
virtual |
Generate a string representation of the PropertyList. Use this for debugging, not for serialization/persistence.
[in] | topLevelOnly | false (default) = do include subproperties. |
[in] | indent | String to indent lines by (default none). |
Reimplemented from lsst::daf::base::PropertySet.
Definition at line 158 of file PropertyList.cc.
|
private |
Definition at line 209 of file PropertyList.h.
|
private |
Definition at line 210 of file PropertyList.h.