|
LSST Applications g00d0e8bbd7+8c5ae1fdc5,g013ef56533+603670b062,g083dd6704c+2e189452a7,g199a45376c+0ba108daf9,g1c5cce2383+bc9f6103a4,g1fd858c14a+cd69ed4fc1,g210f2d0738+c4742f2e9e,g262e1987ae+612fa42d85,g29ae962dfc+83d129e820,g2cef7863aa+aef1011c0b,g35bb328faa+8c5ae1fdc5,g3fd5ace14f+5eaa884f2a,g47891489e3+e32160a944,g53246c7159+8c5ae1fdc5,g5b326b94bb+dcc56af22d,g64539dfbff+c4742f2e9e,g67b6fd64d1+e32160a944,g74acd417e5+c122e1277d,g786e29fd12+668abc6043,g87389fa792+8856018cbb,g88cb488625+47d24e4084,g89139ef638+e32160a944,g8d7436a09f+d14b4ff40a,g8ea07a8fe4+b212507b11,g90f42f885a+e1755607f3,g97be763408+34be90ab8c,g98df359435+ec1fa61bf1,ga2180abaac+8c5ae1fdc5,ga9e74d7ce9+43ac651df0,gbf99507273+8c5ae1fdc5,gc2a301910b+c4742f2e9e,gca7fc764a6+e32160a944,gd7ef33dd92+e32160a944,gdab6d2f7ff+c122e1277d,gdb1e2cdc75+1b18322db8,ge410e46f29+e32160a944,ge41e95a9f2+c4742f2e9e,geaed405ab2+0d91c11c6d,w.2025.44
LSST Data Management Base Package
|
Class for storing generic metadata. More...
#include <PropertySet.h>
Public Types | |
| typedef std::shared_ptr< PropertySet > | Ptr |
| typedef std::shared_ptr< PropertySet const > | ConstPtr |
Public Member Functions | |
| PropertySet (bool flat=false) | |
| Construct an empty PropertySet. | |
| virtual | ~PropertySet () noexcept |
| Destructor. | |
| PropertySet (const PropertySet &)=delete | |
| PropertySet & | operator= (const PropertySet &)=delete |
| PropertySet (PropertySet &&)=delete | |
| PropertySet & | operator= (PropertySet &&)=delete |
| virtual std::shared_ptr< PropertySet > | deepCopy () const |
| Make a deep copy of the PropertySet and all of its contents. | |
| size_t | nameCount (bool topLevelOnly=true) const |
| Get the number of names in the PropertySet, optionally including those in subproperties. | |
| std::vector< std::string > | names (bool topLevelOnly=true) const |
| Get the names in the PropertySet, optionally including those in subproperties. | |
| std::vector< std::string > | paramNames (bool topLevelOnly=true) const |
| A variant of names that excludes the names of subproperties. | |
| std::vector< std::string > | propertySetNames (bool topLevelOnly=true) const |
| A variant of names that only returns the names of subproperties. | |
| bool | exists (std::string const &name) const |
| Determine if a name (possibly hierarchical) exists. | |
| bool | isArray (std::string const &name) const |
| Determine if a name (possibly hierarchical) has multiple values. | |
| bool | isPropertySetPtr (std::string const &name) const |
| Determine if a name (possibly hierarchical) is a subproperty. | |
| bool | isUndefined (std::string const &name) const |
| Determine if a name (possibly hierarchical) has a defined value. | |
| size_t | valueCount () const |
| Get the number of values in the entire PropertySet, counting each element of a vector. | |
| size_t | valueCount (std::string const &name) const |
| Get the number of values for a property name (possibly hierarchical). | |
| std::type_info const & | typeOf (std::string const &name) const |
| Get the type of values for a property name (possibly hierarchical). | |
| template<typename T> | |
| T | get (std::string const &name) const |
| Get the last value for a property name (possibly hierarchical). | |
| template<typename T> | |
| T | get (std::string const &name, T const &defaultValue) const |
| Get the last value for a property name (possibly hierarchical); return the provided defaultValue if the property does not exist. | |
| template<typename T> | |
| std::vector< T > | getArray (std::string const &name) const |
| Get the vector of values for a property name (possibly hierarchical). | |
| bool | getAsBool (std::string const &name) const |
| Get the last value for a bool property name (possibly hierarchical). | |
| int | getAsInt (std::string const &name) const |
| Get the last value for a bool/char/short/int property name (possibly hierarchical). | |
| int64_t | getAsInt64 (std::string const &name) const |
| Get the last value for a bool/char/short/int/int64_t property name (possibly hierarchical). | |
| uint64_t | getAsUInt64 (std::string const &name) const |
| Get the last value for an bool/char/short/int/int64_t property name (possibly hierarchical). | |
| double | getAsDouble (std::string const &name) const |
| Get the last value for any arithmetic property name (possibly hierarchical). | |
| std::string | getAsString (std::string const &name) const |
| Get the last value for a string property name (possibly hierarchical). | |
| std::shared_ptr< PropertySet > | getAsPropertySetPtr (std::string const &name) const |
| Get the last value for a subproperty name (possibly hierarchical). | |
| Persistable::Ptr | getAsPersistablePtr (std::string const &name) const |
| Get the last value for a Persistable name (possibly hierarchical). | |
| virtual std::string | toString (bool topLevelOnly=false, std::string const &indent="") const |
| Generate a string representation of the PropertySet. | |
| template<typename T> | |
| void | set (std::string const &name, T const &value) |
| Replace all values for a property name (possibly hierarchical) with a new scalar value. | |
| template<typename T> | |
| void | set (std::string const &name, std::vector< T > const &value) |
| Replace all values for a property name (possibly hierarchical) with a vector of new values. | |
| void | set (std::string const &name, char const *value) |
| Replace all values for a property name (possibly hierarchical) with a string value. | |
| template<typename T> | |
| void | add (std::string const &name, T const &value) |
| Append a single value to the vector of values for a property name (possibly hierarchical). | |
| template<typename T> | |
| void | add (std::string const &name, std::vector< T > const &value) |
| Append a vector of values to the vector of values for a property name (possibly hierarchical). | |
| void | add (std::string const &name, char const *value) |
Append a char const* value to the vector of values for a property name (possibly hierarchical). | |
| virtual void | copy (std::string const &dest, PropertySet const &source, std::string const &name, bool asScalar=false) |
| Replace a single value vector in the destination with one from the source. | |
| virtual void | combine (PropertySet const &source) |
| Append all value vectors from the source to their corresponding properties. | |
| virtual void | remove (std::string const &name) |
| Remove all values for a property name (possibly hierarchical). | |
Static Public Member Functions | |
| template<typename T> | |
| static std::type_info const & | typeOfT () |
| Get type info for the specified class. | |
Protected Member Functions | |
| virtual void | _set (std::string const &name, std::shared_ptr< std::vector< std::any > > vp) |
| virtual void | _add (std::string const &name, std::shared_ptr< std::vector< std::any > > vp) |
| virtual std::string | _format (std::string const &name) const |
Private Member Functions | |
| virtual void | _findOrInsert (std::string const &name, std::shared_ptr< std::vector< std::any > > vp) |
Class for storing generic metadata.
This class stores key/value pairs, like a Python dictionary but in C++. Keys are always C++ strings. Values can be C++ primitive data types, strings, lsst::daf::base::DateTime objects, and lsst::daf::base::Persistable subclasses (although the latter is currently discouraged). Values can also be vectors of these items.
PropertySets are hierarchical; values within a PropertySet that is contained within another PropertySet can be addressed using dotted paths ("a.b.c"). If "flat=true" is specified to the constructor, the PropertySet still takes dotted paths but is not actually hierarchical in structure. This is used to support PropertyList.
Definition at line 67 of file PropertySet.h.
| typedef std::shared_ptr<PropertySet const> lsst::daf::base::PropertySet::ConstPtr |
Definition at line 71 of file PropertySet.h.
Definition at line 70 of file PropertySet.h.
|
explicit |
Construct an empty PropertySet.
| [in] | flat | false (default) = flatten hierarchy by ignoring dots in names |
|
virtualnoexcept |
Destructor.
|
delete |
|
delete |
|
protectedvirtual |
|
privatevirtual |
|
protectedvirtual |
|
protectedvirtual |
Reimplemented in lsst::daf::base::PropertyList.
| void lsst::daf::base::PropertySet::add | ( | std::string const & | name, |
| char const * | value ) |
Append 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 | Character string value to append. |
| TypeError | Type does not match existing values. |
| InvalidParameterError | Hierarchical name uses non-PropertySet. |
| void lsst::daf::base::PropertySet::add | ( | std::string const & | name, |
| std::vector< T > const & | value ) |
Append 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. |
| TypeError | Type does not match existing values. |
| InvalidParameterError | Hierarchical name uses non-PropertySet. |
| void lsst::daf::base::PropertySet::add | ( | std::string const & | name, |
| T const & | value ) |
Append 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. |
| TypeError | Type does not match existing values. |
| InvalidParameterError | Hierarchical name uses non-PropertySet. |
If value is a PropertySet, the default implementation will allow it to be retreived later via get (or other methods) using the given name, and the result will be the same shared_ptr passed in, but this is not guaranteed to be the behavior for all derived classes, which may flatten out PropertySet values instead.
|
virtual |
Append all value vectors from the source to their corresponding properties.
Sets values if a property does not exist.
If a property already exists then the types of the existing value(s) must match the type of the value(s) in source.
| [in] | source | PropertySet to extract values from. |
| TypeError | Type does not match existing values for an item. |
| InvalidParameterError | Hierarchical name uses non-PropertySet. |
Reimplemented in lsst::daf::base::PropertyList.
|
virtual |
Replace a single value vector in the destination with one from the source.
| [in] | dest | Destination property name. |
| [in] | source | PropertySet to extract values from. |
| [in] | name | Property name to extract. |
| [in] | asScalar | If true copy the item as a scalar by ignoring all but the last value (which is the value returned by get<T>(name)) |
| TypeError | Type does not match existing values. |
| InvalidParameterError | Name does not exist in source. |
| InvalidParameterError | Hierarchical name uses non-PropertySet. |
Reimplemented in lsst::daf::base::PropertyList.
|
virtual |
Make a deep copy of the PropertySet and all of its contents.
Reimplemented in lsst::daf::base::PropertyList.
| bool lsst::daf::base::PropertySet::exists | ( | std::string const & | name | ) | const |
Determine if a name (possibly hierarchical) exists.
| [in] | name | Property name to examine, possibly hierarchical. |
| T lsst::daf::base::PropertySet::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. |
| T lsst::daf::base::PropertySet::get | ( | std::string const & | name, |
| T const & | defaultValue ) const |
Get the last value for a property name (possibly hierarchical); return 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. |
| std::vector< T > lsst::daf::base::PropertySet::getArray | ( | std::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. |
| bool lsst::daf::base::PropertySet::getAsBool | ( | std::string const & | name | ) | const |
Get the last value for a bool property name (possibly hierarchical).
Only bool properties are supported.
| [in] | name | Property name to examine, possibly hierarchical. |
| NotFoundError | Property does not exist. |
| TypeError | Value is not a bool. |
| double lsst::daf::base::PropertySet::getAsDouble | ( | std::string const & | name | ) | const |
Get the last value for any arithmetic property name (possibly hierarchical).
| [in] | name | Property name to examine, possibly hierarchical. |
| NotFoundError | Property does not exist. |
| TypeError | Value cannot be converted to double. |
| int lsst::daf::base::PropertySet::getAsInt | ( | std::string const & | name | ) | const |
Get the last value for a bool/char/short/int property name (possibly hierarchical).
Unsigned int properties are not acceptable.
| [in] | name | Property name to examine, possibly hierarchical. |
| NotFoundError | Property does not exist. |
| TypeError | Value cannot be converted to int. |
| int64_t lsst::daf::base::PropertySet::getAsInt64 | ( | std::string const & | name | ) | const |
Get the last value for a bool/char/short/int/int64_t property name (possibly hierarchical).
Unsigned int64_t properties are not acceptable, but unsigned versions of smaller types are, except possibly unsigned long, depending on compiler.
| [in] | name | Property name to examine, possibly hierarchical. |
| NotFoundError | Property does not exist. |
| TypeError | Value cannot be converted to int64_t. |
| Persistable::Ptr lsst::daf::base::PropertySet::getAsPersistablePtr | ( | std::string const & | name | ) | const |
Get the last value for a Persistable name (possibly hierarchical).
| [in] | name | Property name to examine, possibly hierarchical. |
| NotFoundError | Property does not exist. |
| TypeError | Value is not a Persistable::Ptr. |
| std::shared_ptr< PropertySet > lsst::daf::base::PropertySet::getAsPropertySetPtr | ( | std::string const & | name | ) | const |
Get the last value for a subproperty name (possibly hierarchical).
| [in] | name | Property name to examine, possibly hierarchical. |
| NotFoundError | Property does not exist. |
| TypeError | Value is not a PropertySet. |
| std::string lsst::daf::base::PropertySet::getAsString | ( | std::string const & | name | ) | const |
Get the last value for a string property name (possibly hierarchical).
Only strings values are supported, though this does include properties set with char const*.
| [in] | name | Property name to examine, possibly hierarchical. |
| NotFoundError | Property does not exist. |
| TypeError | Value is not a string. |
| uint64_t lsst::daf::base::PropertySet::getAsUInt64 | ( | std::string const & | name | ) | const |
Get the last value for an bool/char/short/int/int64_t property name (possibly hierarchical).
| [in] | name | Property name to examine, possibly hierarchical. |
| NotFoundError | Property does not exist. |
| TypeError | Value cannot be converted to uint64_t. |
| bool lsst::daf::base::PropertySet::isArray | ( | std::string const & | name | ) | const |
Determine if a name (possibly hierarchical) has multiple values.
| [in] | name | Property name to examine, possibly hierarchical. |
| bool lsst::daf::base::PropertySet::isPropertySetPtr | ( | std::string const & | name | ) | const |
Determine if a name (possibly hierarchical) is a subproperty.
| [in] | name | Property name to examine, possibly hierarchical. |
| bool lsst::daf::base::PropertySet::isUndefined | ( | std::string const & | name | ) | const |
Determine if a name (possibly hierarchical) has a defined value.
| [in] | name | Property name to examine, possibly hierarchical. |
| size_t lsst::daf::base::PropertySet::nameCount | ( | bool | topLevelOnly = true | ) | const |
Get the number of names in the PropertySet, optionally including those in subproperties.
| [in] | topLevelOnly | If true (default) omit names from subproperties and names of subproperties. |
| std::vector< std::string > lsst::daf::base::PropertySet::names | ( | bool | topLevelOnly = true | ) | const |
Get the names in the PropertySet, optionally including those in subproperties.
| [in] | topLevelOnly | If true (default) omit names from subproperties and names of subproperties. If false subproperty names are separated by a dot, e.g. "subname.subitem1" |
|
delete |
|
delete |
| std::vector< std::string > lsst::daf::base::PropertySet::paramNames | ( | bool | topLevelOnly = true | ) | const |
A variant of names that excludes the names of subproperties.
| std::vector< std::string > lsst::daf::base::PropertySet::propertySetNames | ( | bool | topLevelOnly = true | ) | const |
A variant of names that only returns the names of subproperties.
|
virtual |
Remove 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 in lsst::daf::base::PropertyList.
| void lsst::daf::base::PropertySet::set | ( | std::string const & | name, |
| char const * | value ) |
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 ). |
| void lsst::daf::base::PropertySet::set | ( | std::string const & | name, |
| std::vector< T > const & | value ) |
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. |
| InvalidParameterError | Hierarchical name uses non-PropertySet. |
| void lsst::daf::base::PropertySet::set | ( | std::string const & | name, |
| T const & | value ) |
Replace all values for a property name (possibly hierarchical) with a new scalar value.
| [in] | name | Property name to set, possibly hierarchical. |
| [in] | value | Value to set. |
| InvalidParameterError | Hierarchical name uses non-PropertySet. |
If value is a PropertySet, the default implementation will allow it to be retreived later via get (or other methods) using the given name, and the result will be the same shared_ptr passed in, but this is not guaranteed to be the behavior for all derived classes, which may flatten out PropertySet values instead.
|
virtual |
Generate a string representation of the PropertySet.
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 in lsst::daf::base::PropertyList.
| std::type_info const & lsst::daf::base::PropertySet::typeOf | ( | std::string const & | name | ) | const |
Get the type of values for a property name (possibly hierarchical).
If the value is an array this returns the type of the elements.
| [in] | name | Property name to examine, possibly hierarchical. |
| NotFoundError | Property does not exist. |
|
static |
Get type info for the specified class.
| size_t lsst::daf::base::PropertySet::valueCount | ( | ) | const |
Get the number of values in the entire PropertySet, counting each element of a vector.
| size_t lsst::daf::base::PropertySet::valueCount | ( | std::string const & | name | ) | const |
Get the number of values for a property name (possibly hierarchical).
| [in] | name | Property name to examine, possibly hierarchical. |