LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+bd2ed33bd6,g1470d8bcf6+de7501a2e0,g14a832a312+ff425fae3c,g2079a07aa2+86d27d4dc4,g2305ad1205+91a32aca49,g295015adf3+762506a1ad,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+c34e8be1fa,g487adcacf7+5fae3daba8,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ea1711114f,g5a732f18d5+53520f316c,g64a986408d+bd2ed33bd6,g858d7b2824+bd2ed33bd6,g8a8a8dda67+585e252eca,g99cad8db69+016a06b37a,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+ef4e3a5875,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+09e12c87ab,gc120e1dc64+bc2e06c061,gc28159a63d+0e5473021a,gcf0d15dbbd+c34e8be1fa,gdaeeff99f8+f9a426f77a,ge6526c86ff+508d0e0a30,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+8d59551888,gf1cff7945b+bd2ed33bd6,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
lsst::daf::base::PropertyList Class Reference

Class for storing ordered metadata with comments. More...

#include <PropertyList.h>

Inheritance diagram for lsst::daf::base::PropertyList:
lsst::daf::base::PropertySet

Public Types

typedef std::shared_ptr< PropertyListPtr
 
typedef std::shared_ptr< PropertyList const > ConstPtr
 

Public Member Functions

 PropertyList ()
 Construct an empty PropertyList.
 
virtual ~PropertyList () noexcept
 Destructor.
 
virtual std::shared_ptr< PropertySetdeepCopy () const
 Make a deep copy of the PropertyList and all of its contents.
 
template<typename T >
get (std::string const &name) const
 Get the last value for a property name (possibly hierarchical).
 
template<typename 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).
 
std::string const & getComment (std::string const &name) const
 Get the comment for a string property name (possibly hierarchical).
 
std::vector< std::stringgetOrderedNames () const
 Get the list of property names, in the order they were added.
 
std::list< std::string >::const_iterator begin () const
 Begin iterator over the list of property names, in the order they were added.
 
std::list< std::string >::const_iterator end () const
 End iterator over the list of property names, in the order they were added.
 
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.
 
void set (std::string const &name, std::shared_ptr< PropertySet > const &value)
 Replace all values for a property name (possibly hierarchical) with a new PropertySet.
 
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).
 
template<typename T >
void set (std::string const &name, T const &value, std::string const &comment)
 Version of set scalar value that accepts a comment.
 
template<typename T >
void set (std::string const &name, std::vector< T > const &value, std::string const &comment)
 Version of set vector value that accepts a comment.
 
void set (std::string const &name, char const *value, std::string const &comment)
 Version of set char* value that accepts a comment.
 
template<typename T >
void add (std::string const &name, T const &value, std::string const &comment)
 Version of add scalar value that accepts a comment.
 
template<typename T >
void add (std::string const &name, std::vector< T > const &value, std::string const &comment)
 Version of add vector value that accepts a comment.
 
void add (std::string const &name, char const *value, std::string const &comment)
 Version of add char* value that accepts a comment.
 
template<typename T >
void set (std::string const &name, T const &value, char const *comment)
 Version of set scalar value that accepts a comment.
 
template<typename T >
void set (std::string const &name, std::vector< T > const &value, char const *comment)
 Version of set vector value that accepts a comment.
 
void set (std::string const &name, char const *value, char const *comment)
 Version of set char* value that accepts a comment.
 
template<typename T >
void add (std::string const &name, T const &value, char const *comment)
 Version of add scalar value that accepts a comment.
 
template<typename T >
void add (std::string const &name, std::vector< T > const &value, char const *comment)
 Version of add vector value that accepts a comment.
 
void add (std::string const &name, char const *value, char const *comment)
 Version of add char* value that accepts a comment.
 
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).
 
size_t nameCount (bool topLevelOnly=true) const
 Get the number of names in the PropertySet, optionally including those in subproperties.
 
std::vector< std::stringnames (bool topLevelOnly=true) const
 Get the names in the PropertySet, optionally including those in subproperties.
 
std::vector< std::stringparamNames (bool topLevelOnly=true) const
 A variant of names that excludes the names of subproperties.
 
std::vector< std::stringpropertySetNames (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).
 
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< PropertySetgetAsPropertySetPtr (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).
 

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 _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 _set (std::string const &name, std::shared_ptr< std::vector< std::any > > vp)
 
virtual void _moveToEnd (std::string const &name)
 
virtual void _commentOrderFix (std::string const &name, std::string const &comment)
 

Detailed Description

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 68 of file PropertyList.h.

Member Typedef Documentation

◆ ConstPtr

Definition at line 72 of file PropertyList.h.

◆ Ptr

Definition at line 71 of file PropertyList.h.

Constructor & Destructor Documentation

◆ PropertyList()

lsst::daf::base::PropertyList::PropertyList ( )

Construct an empty PropertyList.

Constructor.

Definition at line 41 of file PropertyList.cc.

41: PropertySet(true) {}
PropertySet(bool flat=false)
Construct an empty PropertySet.

◆ ~PropertyList()

lsst::daf::base::PropertyList::~PropertyList ( )
virtualdefaultnoexcept

Destructor.

Member Function Documentation

◆ _add()

virtual void lsst::daf::base::PropertySet::_add ( std::string const & name,
std::shared_ptr< std::vector< std::any > > vp )
protectedvirtualinherited

◆ _commentOrderFix()

void lsst::daf::base::PropertyList::_commentOrderFix ( std::string const & name,
std::string const & comment )
privatevirtual

Definition at line 242 of file PropertyList.cc.

242 {
243 _comments[name] = comment;
244}
table::Key< std::string > name
Definition Amplifier.cc:116

◆ _format()

virtual std::string lsst::daf::base::PropertySet::_format ( std::string const & name) const
protectedvirtualinherited

◆ _moveToEnd()

void lsst::daf::base::PropertyList::_moveToEnd ( std::string const & name)
privatevirtual

Definition at line 237 of file PropertyList.cc.

237 {
238 _order.remove(name);
239 _order.push_back(name);
240}
T push_back(T... args)
T remove(T... args)

◆ _set()

void lsst::daf::base::PropertyList::_set ( std::string const & name,
std::shared_ptr< std::vector< std::any > > vp )
privatevirtual

Reimplemented from lsst::daf::base::PropertySet.

Definition at line 229 of file PropertyList.cc.

229 {
230 PropertySet::_set(name, vp);
231 if (_comments.find(name) == _comments.end()) {
232 _comments.insert(std::make_pair(name, std::string()));
233 _order.push_back(name);
234 }
235}
virtual void _set(std::string const &name, std::shared_ptr< std::vector< std::any > > vp)
T end(T... args)
T find(T... args)
T insert(T... args)
T make_pair(T... args)

◆ add() [1/9]

void lsst::daf::base::PropertyList::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.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueCharacter string value to append.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 143 of file PropertyList.cc.

143{ add(name, std::string(value)); }
void add(std::string const &name, T const &value)
Append a single value to the vector of values for a property name (possibly hierarchical).

◆ add() [2/9]

void lsst::daf::base::PropertyList::add ( std::string const & name,
char const * value,
char const * comment )
inline

Version of add char* value that accepts a comment.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueCharacter string value to add.
[in]commentComment to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 276 of file PropertyList.h.

276 {
277 add(name, value, std::string(comment));
278 }

◆ add() [3/9]

void lsst::daf::base::PropertyList::add ( std::string const & name,
char const * value,
std::string const & comment )

Version of add char* value that accepts a comment.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueCharacter string value to add.
[in]commentComment to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 174 of file PropertyList.cc.

174 {
175 add(name, std::string(value), comment);
176}

◆ add() [4/9]

template<typename T >
void lsst::daf::base::PropertyList::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.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueVector of values to append.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorHierarchical name uses non-PropertySet.
Note
May only partially add the vector if an exception occurs.

Definition at line 146 of file PropertyList.cc.

146 {
147 PropertySet::add(name, value);
148}
void add(std::string const &name, T const &value)
Append a single value to the vector of values for a property name (possibly hierarchical).

◆ add() [5/9]

template<typename T >
void lsst::daf::base::PropertyList::add ( std::string const & name,
std::vector< T > const & value,
char const * comment )
inline

Version of add vector value that accepts a comment.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueCharacter string value to add.
[in]commentComment to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 271 of file PropertyList.h.

271 {
272 add(name, value, std::string(comment));
273 }

◆ add() [6/9]

template<typename T >
void lsst::daf::base::PropertyList::add ( std::string const & name,
std::vector< T > const & value,
std::string const & comment )

Version of add vector value that accepts a comment.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueCharacter string value to add.
[in]commentComment to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 179 of file PropertyList.cc.

179 {
180 PropertySet::add(name, value);
181 _commentOrderFix(name, comment);
182}
virtual void _commentOrderFix(std::string const &name, std::string const &comment)

◆ add() [7/9]

template<typename T >
void lsst::daf::base::PropertyList::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.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueValue to append.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorHierarchical 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.

Definition at line 139 of file PropertyList.cc.

139 {
140 PropertySet::add(name, value);
141}

◆ add() [8/9]

template<typename T >
void lsst::daf::base::PropertyList::add ( std::string const & name,
T const & value,
char const * comment )
inline

Version of add scalar value that accepts a comment.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueValue to add.
[in]commentComment to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 266 of file PropertyList.h.

266 {
267 add(name, value, std::string(comment));
268 }

◆ add() [9/9]

template<typename T >
void lsst::daf::base::PropertyList::add ( std::string const & name,
T const & value,
std::string const & comment )

Version of add scalar value that accepts a comment.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueValue to add.
[in]commentComment to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 169 of file PropertyList.cc.

169 {
170 PropertySet::add(name, value);
171 _commentOrderFix(name, comment);
172}

◆ begin()

std::list< std::string >::const_iterator lsst::daf::base::PropertyList::begin ( ) const

Begin iterator over the list of property names, in the order they were added.

Definition at line 90 of file PropertyList.cc.

90{ return _order.begin(); }
T begin(T... args)

◆ combine()

void lsst::daf::base::PropertyList::combine ( PropertySet const & source)
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.

Parameters
[in]sourcePropertySet to extract values from.
Exceptions
TypeErrorType does not match existing values for an item.
InvalidParameterErrorHierarchical name uses non-PropertySet.
Warning
May only partially combine the PropertySets if an exception occurs.

Reimplemented from lsst::daf::base::PropertySet.

Definition at line 197 of file PropertyList.cc.

197 {
198 auto const * pl = dynamic_cast<PropertyList const *>(&source);
199 std::list<std::string> newOrder;
200 if (pl) {
201 newOrder = _order;
202 for (auto const& name : *pl) {
203 bool present = _comments.find(name) != _comments.end();
204 if (!present) {
205 newOrder.push_back(name);
206 }
207 }
208 }
209 PropertySet::combine(source);
210 if (pl) {
211 _order = newOrder;
212 for (auto const& name : *pl) {
213 _comments[name] = pl->_comments.find(name)->second;
214 }
215 }
216}
virtual void combine(PropertySet const &source)
Append all value vectors from the source to their corresponding properties.
const char * source()
Source function that allows astChannel to source from a Stream.
Definition Stream.h:224

◆ copy()

void lsst::daf::base::PropertyList::copy ( std::string const & dest,
PropertySet const & source,
std::string const & name,
bool asScalar = false )
virtual

Replace a single value vector in the destination with one from the source.

Parameters
[in]destDestination property name.
[in]sourcePropertySet to extract values from.
[in]nameProperty name to extract.
[in]asScalarIf true copy the item as a scalar by ignoring all but the last value (which is the value returned by get<T>(name))
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorName does not exist in source.
InvalidParameterErrorHierarchical name uses non-PropertySet.

Reimplemented from lsst::daf::base::PropertySet.

Definition at line 187 of file PropertyList.cc.

188 {
189 PropertySet::copy(dest, source, name, asScalar);
190 auto const * pl = dynamic_cast<PropertyList const *>(&source);
191 if (pl) {
192 _comments[name] = pl->_comments.find(name)->second;
193 }
194}
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.

◆ deepCopy()

std::shared_ptr< PropertySet > lsst::daf::base::PropertyList::deepCopy ( ) const
virtual

Make a deep copy of the PropertyList and all of its contents.

Returns
PropertyList pointing to the new copy.

Reimplemented from lsst::daf::base::PropertySet.

Definition at line 51 of file PropertyList.cc.

51 {
52 std::shared_ptr<PropertyList> n(new PropertyList);
53 n->PropertySet::combine(*this->PropertySet::deepCopy());
54 n->_order = _order;
55 n->_comments = _comments;
56 return n;
57}
virtual std::shared_ptr< PropertySet > deepCopy() const
Make a deep copy of the PropertySet and all of its contents.

◆ end()

std::list< std::string >::const_iterator lsst::daf::base::PropertyList::end ( ) const

End iterator over the list of property names, in the order they were added.

Definition at line 92 of file PropertyList.cc.

92{ return _order.end(); }

◆ exists()

bool lsst::daf::base::PropertySet::exists ( std::string const & name) const
inherited

Determine if a name (possibly hierarchical) exists.

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
true if property exists.

◆ get() [1/2]

template<typename T >
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:

int i = propertySet.get<int>("foo")
Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
Last value set or added.
Exceptions
NotFoundErrorProperty does not exist.
TypeErrorValue does not match desired type.

Definition at line 62 of file PropertyList.cc.

63 { /* parasoft-suppress LsstDm-3-4a LsstDm-4-6 "allow template over bool" */
64 return PropertySet::get<T>(name);
65}

◆ get() [2/2]

template<typename T >
T lsst::daf::base::PropertyList::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:

int i = propertySet.get<int>("foo", 42)
Parameters
[in]nameProperty name to examine, possibly hierarchical.
[in]defaultValueDefault value to return if property does not exist.
Returns
Last value set or added.
Exceptions
TypeErrorValue does not match desired type.

Definition at line 68 of file PropertyList.cc.

69 { /* parasoft-suppress LsstDm-3-4a LsstDm-4-6 "allow template over bool" */
70 return PropertySet::get<T>(name, defaultValue);
71}

◆ getArray()

template<typename T >
std::vector< T > lsst::daf::base::PropertyList::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:

vector<int> v = propertySet.getArray<int>("foo")
Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
Vector of values.
Exceptions
NotFoundErrorProperty does not exist.
TypeErrorValue does not match desired type.

Definition at line 74 of file PropertyList.cc.

74 {
75 return PropertySet::getArray<T>(name);
76}

◆ getAsBool()

bool lsst::daf::base::PropertySet::getAsBool ( std::string const & name) const
inherited

Get the last value for a bool property name (possibly hierarchical).

Only bool properties are supported.

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
Value as a bool.
Exceptions
NotFoundErrorProperty does not exist.
TypeErrorValue is not a bool.

◆ getAsDouble()

double lsst::daf::base::PropertySet::getAsDouble ( std::string const & name) const
inherited

Get the last value for any arithmetic property name (possibly hierarchical).

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
Value as a double.
Exceptions
NotFoundErrorProperty does not exist.
TypeErrorValue cannot be converted to double.

◆ getAsInt()

int lsst::daf::base::PropertySet::getAsInt ( std::string const & name) const
inherited

Get the last value for a bool/char/short/int property name (possibly hierarchical).

Unsigned int properties are not acceptable.

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
Value as an int.
Exceptions
NotFoundErrorProperty does not exist.
TypeErrorValue cannot be converted to int.

◆ getAsInt64()

int64_t lsst::daf::base::PropertySet::getAsInt64 ( std::string const & name) const
inherited

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.

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
Value as an int64_t.
Exceptions
NotFoundErrorProperty does not exist.
TypeErrorValue cannot be converted to int64_t.

◆ getAsPersistablePtr()

Persistable::Ptr lsst::daf::base::PropertySet::getAsPersistablePtr ( std::string const & name) const
inherited

Get the last value for a Persistable name (possibly hierarchical).

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
Persistable::Ptr value.
Exceptions
NotFoundErrorProperty does not exist.
TypeErrorValue is not a Persistable::Ptr.

◆ getAsPropertySetPtr()

std::shared_ptr< PropertySet > lsst::daf::base::PropertySet::getAsPropertySetPtr ( std::string const & name) const
inherited

Get the last value for a subproperty name (possibly hierarchical).

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
PropertySet value.
Exceptions
NotFoundErrorProperty does not exist.
TypeErrorValue is not a PropertySet.

◆ getAsString()

std::string lsst::daf::base::PropertySet::getAsString ( std::string const & name) const
inherited

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*.

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
String value.
Exceptions
NotFoundErrorProperty does not exist.
TypeErrorValue is not a string.

◆ getAsUInt64()

uint64_t lsst::daf::base::PropertySet::getAsUInt64 ( std::string const & name) const
inherited

Get the last value for an bool/char/short/int/int64_t property name (possibly hierarchical).

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
Value as an uint64_t.
Exceptions
NotFoundErrorProperty does not exist.
TypeErrorValue cannot be converted to uint64_t.

◆ getComment()

std::string const & lsst::daf::base::PropertyList::getComment ( std::string const & name) const

Get the comment for a string property name (possibly hierarchical).

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
Comment string.
Exceptions
NotFoundErrorProperty does not exist.

Definition at line 78 of file PropertyList.cc.

78 {
79 return _comments.find(name)->second;
80}

◆ getOrderedNames()

std::vector< std::string > lsst::daf::base::PropertyList::getOrderedNames ( ) const

Get the list of property names, in the order they were added.

Definition at line 82 of file PropertyList.cc.

82 {
84 for (auto const& name : _order) {
85 v.push_back(name);
86 }
87 return v;
88}

◆ isArray()

bool lsst::daf::base::PropertySet::isArray ( std::string const & name) const
inherited

Determine if a name (possibly hierarchical) has multiple values.

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
true if property exists and has more than one value.

◆ isPropertySetPtr()

bool lsst::daf::base::PropertySet::isPropertySetPtr ( std::string const & name) const
inherited

Determine if a name (possibly hierarchical) is a subproperty.

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
true if property exists and its values are PropertySet:.

◆ isUndefined()

bool lsst::daf::base::PropertySet::isUndefined ( std::string const & name) const
inherited

Determine if a name (possibly hierarchical) has a defined value.

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
true if property exists and its values are undefined.

◆ nameCount()

size_t lsst::daf::base::PropertySet::nameCount ( bool topLevelOnly = true) const
inherited

Get the number of names in the PropertySet, optionally including those in subproperties.

Parameters
[in]topLevelOnlyIf true (default) omit names from subproperties and names of subproperties.
Returns
Number of names.

◆ names()

std::vector< std::string > lsst::daf::base::PropertySet::names ( bool topLevelOnly = true) const
inherited

Get the names in the PropertySet, optionally including those in subproperties.

Parameters
[in]topLevelOnlyIf true (default) omit names from subproperties and names of subproperties. If false subproperty names are separated by a dot, e.g. "subname.subitem1"
Returns
Vector of names.

◆ paramNames()

std::vector< std::string > lsst::daf::base::PropertySet::paramNames ( bool topLevelOnly = true) const
inherited

A variant of names that excludes the names of subproperties.

◆ propertySetNames()

std::vector< std::string > lsst::daf::base::PropertySet::propertySetNames ( bool topLevelOnly = true) const
inherited

A variant of names that only returns the names of subproperties.

◆ remove()

void lsst::daf::base::PropertyList::remove ( std::string const & name)
virtual

Remove all values for a property name (possibly hierarchical).

Does nothing if the property does not exist.

Parameters
[in]nameProperty name to remove, possibly hierarchical.

Reimplemented from lsst::daf::base::PropertySet.

Definition at line 219 of file PropertyList.cc.

219 {
221 _comments.erase(name);
222 _order.remove(name);
223}
virtual void remove(std::string const &name)
Remove all values for a property name (possibly hierarchical).
T erase(T... args)

◆ set() [1/10]

void lsst::daf::base::PropertyList::set ( std::string const & name,
char const * value )

Replace all values for a property name (possibly hierarchical) with a string value.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueCharacter string (converted to std::string ).

Definition at line 131 of file PropertyList.cc.

131{ set(name, std::string(value)); }
daf::base::PropertySet * set
Definition fits.cc:931

◆ set() [2/10]

void lsst::daf::base::PropertyList::set ( std::string const & name,
char const * value,
char const * comment )
inline

Version of set char* value that accepts a comment.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueCharacter string value to set.
[in]commentComment to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 260 of file PropertyList.h.

260 {
261 set(name, value, std::string(comment));
262 }

◆ set() [3/10]

void lsst::daf::base::PropertyList::set ( std::string const & name,
char const * value,
std::string const & comment )

Version of set char* value that accepts a comment.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueCharacter string value to set.
[in]commentComment to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 159 of file PropertyList.cc.

159 {
160 set(name, std::string(value), comment);
161}

◆ set() [4/10]

void lsst::daf::base::PropertyList::set ( std::string const & name,
std::shared_ptr< PropertySet > const & value )

Replace all values for a property name (possibly hierarchical) with a new PropertySet.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueValue to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Unlike the base PropertySet implementation, PropertyList flattens out nested PropertySet objects, storing their keys with nested names but not the PropertySet instance itself.

Definition at line 118 of file PropertyList.cc.

118 {
119 auto pl = std::dynamic_pointer_cast<PropertyList, PropertySet>(value);
120 PropertySet::set(name, value);
121 _comments.erase(name);
122 _order.remove(name);
123 std::vector<std::string> paramNames = value->paramNames(false);
124 if (pl) {
125 for (auto const& paramName : paramNames) {
126 _commentOrderFix(name + "." + paramName, pl->getComment(paramName));
127 }
128 }
129}
void set(std::string const &name, T const &value)
Replace all values for a property name (possibly hierarchical) with a new scalar value.
std::vector< std::string > paramNames(bool topLevelOnly=true) const
A variant of names that excludes the names of subproperties.

◆ set() [5/10]

template<typename T >
void lsst::daf::base::PropertyList::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.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueVector of values to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 134 of file PropertyList.cc.

134 {
135 PropertySet::set(name, value);
136}

◆ set() [6/10]

template<typename T >
void lsst::daf::base::PropertyList::set ( std::string const & name,
std::vector< T > const & value,
char const * comment )
inline

Version of set vector value that accepts a comment.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueVector value to set.
[in]commentComment to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 255 of file PropertyList.h.

255 {
256 set(name, value, std::string(comment));
257 }

◆ set() [7/10]

template<typename T >
void lsst::daf::base::PropertyList::set ( std::string const & name,
std::vector< T > const & value,
std::string const & comment )

Version of set vector value that accepts a comment.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueVector value to set.
[in]commentComment to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 164 of file PropertyList.cc.

164 {
165 PropertySet::set(name, value);
166 _commentOrderFix(name, comment);
167}

◆ set() [8/10]

template<typename T >
void lsst::daf::base::PropertyList::set ( std::string const & name,
T const & value )

Replace all values for a property name (possibly hierarchical) with a new scalar value.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueValue to set.
Exceptions
InvalidParameterErrorHierarchical 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.

Definition at line 114 of file PropertyList.cc.

114 {
115 PropertySet::set(name, value);
116}

◆ set() [9/10]

template<typename T >
void lsst::daf::base::PropertyList::set ( std::string const & name,
T const & value,
char const * comment )
inline

Version of set scalar value that accepts a comment.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueValue to set.
[in]commentComment to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 249 of file PropertyList.h.

249 {
250 set(name, value, std::string(comment));
251 }

◆ set() [10/10]

template<typename T >
void lsst::daf::base::PropertyList::set ( std::string const & name,
T const & value,
std::string const & comment )

Version of set scalar value that accepts a comment.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueValue to set.
[in]commentComment to set.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 154 of file PropertyList.cc.

154 {
155 PropertySet::set(name, value);
156 _commentOrderFix(name, comment);
157}

◆ toString()

std::string lsst::daf::base::PropertyList::toString ( bool topLevelOnly = false,
std::string const & indent = "" ) const
virtual

Generate a string representation of the PropertySet.

Use this for debugging, not for serialization/persistence.

Parameters
[in]topLevelOnlyfalse (default) = do include subproperties.
[in]indentString to indent lines by (default none).
Returns
String representation of the PropertySet.

Reimplemented from lsst::daf::base::PropertySet.

Definition at line 94 of file PropertyList.cc.

94 {
96 for (auto const& name : _order) {
97 s << _format(name);
98 std::string const& comment = _comments.find(name)->second;
99 if (comment.size()) {
100 s << "// " << comment << std::endl;
101 }
102 }
103 return s.str();
104}
virtual std::string _format(std::string const &name) const
T endl(T... args)
T size(T... args)

◆ typeOf()

std::type_info const & lsst::daf::base::PropertySet::typeOf ( std::string const & name) const
inherited

Get the type of values for a property name (possibly hierarchical).

If the value is an array this returns the type of the elements.

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
Type of values for that property.
Exceptions
NotFoundErrorProperty does not exist.

◆ typeOfT()

template<typename T >
static std::type_info const & lsst::daf::base::PropertySet::typeOfT ( )
staticinherited

Get type info for the specified class.

◆ valueCount() [1/2]

size_t lsst::daf::base::PropertySet::valueCount ( ) const
inherited

Get the number of values in the entire PropertySet, counting each element of a vector.

Returns
Number of values.

◆ valueCount() [2/2]

size_t lsst::daf::base::PropertySet::valueCount ( std::string const & name) const
inherited

Get the number of values for a property name (possibly hierarchical).

Parameters
[in]nameProperty name to examine, possibly hierarchical.
Returns
Number of values for that property. 0 if it doesn't exist.

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