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
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | 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 lsst::daf::base::Persistable lsst::daf::base::Citizen

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 >
get (std::string const &name) const
 
template<typename 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 >
get (std::string const &name) const
 
template<typename 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 ()
 
Citizenoperator= (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
 

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

Member Typedef Documentation

typedef std::tr1::unordered_map<std::string, std::string> lsst::daf::base::PropertyList::CommentMap
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.

Definition at line 84 of file PropertyList.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 57 of file PropertyList.cc.

57  : PropertySet(true) {
58 }
PropertySet(bool flat=false)
Definition: PropertySet.cc:55
lsst::daf::base::PropertyList::~PropertyList ( void  )
virtual

Destructor.

Definition at line 62 of file PropertyList.cc.

62  {
63 }

Member Function Documentation

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

Definition at line 495 of file PropertyList.cc.

496  {
497  _comments[name] = comment;
498  if (!inPlace) {
499  _moveToEnd(name);
500  }
501 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void _moveToEnd(std::string const &name)
void lsst::daf::base::PropertyList::_moveToEnd ( std::string const &  name)
privatevirtual

Definition at line 490 of file PropertyList.cc.

490  {
491  _order.remove(name);
492  _order.push_back(name);
493 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
std::list< std::string > _order
Definition: PropertyList.h:210
void lsst::daf::base::PropertyList::_set ( std::string const &  name,
boost::shared_ptr< std::vector< boost::any > >  vp 
)
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.

Parameters
[in]nameProperty name to find, possibly hierarchical.
[in]vpshared_ptr to vector of values.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

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

Definition at line 481 of file PropertyList.cc.

482  {
483  PropertySet::_set(name, vp);
484  if (_comments.find(name) == _comments.end()) {
485  _comments.insert(std::make_pair(name, std::string()));
486  _order.push_back(name);
487  }
488 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
std::list< std::string > _order
Definition: PropertyList.h:210
virtual void _set(std::string const &name, boost::shared_ptr< std::vector< boost::any > > vp)
Definition: PropertySet.cc:837
template<typename T >
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.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueValue to append.
[in]inPlaceIf false, property is moved to end of list.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 255 of file PropertyList.cc.

256  {
257  PropertySet::add(name, value);
258  if (!inPlace) {
259  _moveToEnd(name);
260  }
261 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void _moveToEnd(std::string const &name)
void add(std::string const &name, T const &value)
Definition: PropertySet.cc:619
template<typename T >
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.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueVector of values to append.
[in]inPlaceIf false, property is moved to end of list.
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 288 of file PropertyList.cc.

289  {
290  PropertySet::add(name, value);
291  if (!inPlace) {
292  _moveToEnd(name);
293  }
294 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void _moveToEnd(std::string const &name)
void add(std::string const &name, T const &value)
Definition: PropertySet.cc:619
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.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueValue to append.
[in]inPlaceIf false, property is moved to end of list.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 272 of file PropertyList.cc.

273  {
274  add(name, string(value), inPlace);
275 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void add(std::string const &name, T const &value, bool inPlace=true)
template<typename T >
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.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueValue to append.
[in]commentComment to set.
[in]inPlaceIf false, property is moved to end of list.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 356 of file PropertyList.cc.

358  {
359  PropertySet::add(name, value);
360  _commentOrderFix(name, comment, inPlace);
361 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void _commentOrderFix(std::string const &name, std::string const &comment, bool inPlace)
void add(std::string const &name, T const &value)
Definition: PropertySet.cc:619
template<typename T >
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.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueVector of values to append.
[in]commentComment to set.
[in]inPlaceIf false, property is moved to end of list.
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 392 of file PropertyList.cc.

394  {
395  PropertySet::add(name, value);
396  _commentOrderFix(name, comment, inPlace);
397 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void _commentOrderFix(std::string const &name, std::string const &comment, bool inPlace)
void add(std::string const &name, T const &value)
Definition: PropertySet.cc:619
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.

Parameters
[in]nameProperty name to append to, possibly hierarchical.
[in]valueString value to append.
[in]commentComment to set.
[in]inPlaceIf false, property is moved to end of list.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 374 of file PropertyList.cc.

376  {
377  add(name, string(value), comment, inPlace);
378 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void add(std::string const &name, T const &value, bool inPlace=true)
template<typename T >
void lsst::daf::base::PropertyList::add ( std::string const &  name,
T const &  value,
char const *  comment,
bool  inPlace = true 
)
inline

Definition at line 168 of file PropertyList.h.

170  {
171  add(name, value, std::string(comment), inPlace);
172  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void add(std::string const &name, T const &value, bool inPlace=true)
template<typename T >
void lsst::daf::base::PropertyList::add ( std::string const &  name,
std::vector< T > const &  value,
char const *  comment,
bool  inPlace = true 
)
inline

Definition at line 173 of file PropertyList.h.

175  {
176  add(name, value, std::string(comment), inPlace);
177  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void add(std::string const &name, T const &value, bool inPlace=true)
void lsst::daf::base::PropertyList::add ( std::string const &  name,
char const *  value,
char const *  comment,
bool  inPlace = true 
)
inline

Definition at line 178 of file PropertyList.h.

180  {
181  add(name, value, std::string(comment), inPlace);
182  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void add(std::string const &name, T const &value, bool inPlace=true)
std::list< std::string >::const_iterator lsst::daf::base::PropertyList::begin ( void  ) const

Definition at line 143 of file PropertyList.cc.

143  {
144  return _order.begin();
145 }
std::list< std::string > _order
Definition: PropertyList.h:210
virtual void lsst::daf::base::PropertyList::combine ( PropertySet::ConstPtr  source)
inlinevirtual

Appends all value vectors from the source to their corresponding properties. Sets values if a property does not exist.

Parameters
[in]sourcePropertySet::Ptr for the source PropertySet.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorHierarchical name uses non-PropertySet.
Note
May only partially combine the PropertySets if an exception occurs.

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

Definition at line 188 of file PropertyList.h.

188  {
189  combine(source, true);
190  }
virtual void combine(PropertySet::ConstPtr source)
Definition: PropertyList.h:188
void lsst::daf::base::PropertyList::combine ( PropertySet::ConstPtr  source,
bool  inPlace 
)
virtual

Appends all value vectors from the source to their corresponding properties. Sets values if a property does not exist.

Parameters
[in]sourcePropertySet::Ptr for the source PropertySet.
[in]inPlaceIf false, existing properties are moved to end of list.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorHierarchical name uses non-PropertySet.
Note
May only partially combine the PropertySets if an exception occurs.

Definition at line 437 of file PropertyList.cc.

438  {
439  ConstPtr pl =
440  boost::dynamic_pointer_cast<PropertyList const, PropertySet const>(
441  source);
442  std::list<std::string> newOrder;
443  if (pl) {
444  newOrder = _order;
445  for (std::list<std::string>::const_iterator i = pl->begin();
446  i != pl->end(); ++i) {
447  bool present = _comments.find(*i) != _comments.end();
448  if (!present) {
449  newOrder.push_back(*i);
450  }
451  else if (!inPlace) {
452  newOrder.remove(*i);
453  newOrder.push_back(*i);
454  }
455  }
456  }
457  PropertySet::combine(source);
458  if (pl) {
459  _order = newOrder;
460  for (std::list<std::string>::const_iterator i = pl->begin();
461  i != pl->end(); ++i) {
462  _comments[*i] = pl->_comments.find(*i)->second;
463  }
464  }
465 }
boost::shared_ptr< PropertyList const > ConstPtr
Definition: PropertyList.h:85
Class for storing ordered metadata with comments.
Definition: PropertyList.h:81
std::list< std::string > _order
Definition: PropertyList.h:210
virtual void combine(ConstPtr source)
Definition: PropertySet.cc:738
Class for storing generic metadata.
Definition: PropertySet.h:82
virtual void lsst::daf::base::PropertyList::copy ( std::string const &  dest,
PropertySet::ConstPtr  source,
std::string const &  name 
)
inlinevirtual

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

Parameters
[in]destDestination property name.
[in]sourcePropertySet::Ptr for the source PropertySet.
[in]nameProperty name to extract.
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 184 of file PropertyList.h.

185  {
186  copy(dest, source, name, true);
187  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void copy(std::string const &dest, PropertySet::ConstPtr source, std::string const &name)
Definition: PropertyList.h:184
void lsst::daf::base::PropertyList::copy ( std::string const &  dest,
PropertySet::ConstPtr  source,
std::string const &  name,
bool  inPlace 
)
virtual

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

Parameters
[in]destDestination property name.
[in]sourcePropertySet::Ptr for the source PropertySet.
[in]nameProperty name to extract.
[in]inPlaceIf false, property is moved to end of list.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorName does not exist in source.
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 413 of file PropertyList.cc.

415  {
416  PropertySet::copy(dest, source, name);
417  ConstPtr pl =
418  boost::dynamic_pointer_cast<PropertyList const, PropertySet const>(
419  source);
420  if (pl) {
421  _comments[name] = pl->_comments.find(name)->second;
422  if (!inPlace) {
423  _moveToEnd(name);
424  }
425  }
426 }
boost::shared_ptr< PropertyList const > ConstPtr
Definition: PropertyList.h:85
table::Key< std::string > name
Definition: ApCorrMap.cc:71
Class for storing ordered metadata with comments.
Definition: PropertyList.h:81
virtual void copy(std::string const &dest, ConstPtr source, std::string const &name)
Definition: PropertySet.cc:713
virtual void _moveToEnd(std::string const &name)
Class for storing generic metadata.
Definition: PropertySet.h:82
PropertySet::Ptr lsst::daf::base::PropertyList::deepCopy ( void  ) const
virtual

Copy the PropertyList and all of its contents.

Returns
PropertySet::Ptr pointing to the new copy.

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

Definition at line 72 of file PropertyList.cc.

72  {
73  Ptr n(new PropertyList);
74  n->PropertySet::combine(this->PropertySet::deepCopy());
75  n->_order = _order;
76  n->_comments = _comments;
77  return n;
78 }
Class for storing ordered metadata with comments.
Definition: PropertyList.h:81
std::list< std::string > _order
Definition: PropertyList.h:210
boost::shared_ptr< PropertyList > Ptr
Definition: PropertyList.h:84
virtual Ptr deepCopy(void) const
Definition: PropertySet.cc:70
std::list< std::string >::const_iterator lsst::daf::base::PropertyList::end ( void  ) const

Definition at line 148 of file PropertyList.cc.

148  {
149  return _order.end();
150 }
std::list< std::string > _order
Definition: PropertyList.h:210
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 = propertyList.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 91 of file PropertyList.cc.

91  { /* parasoft-suppress LsstDm-3-4a LsstDm-4-6 "allow template over bool" */
92  return PropertySet::get<T>(name);
93 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
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). Returns the provided defaultValue if the property does not exist. Note that the type must be explicitly specified for this template:

int i = propertyList.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 105 of file PropertyList.cc.

105  { /* parasoft-suppress LsstDm-3-4a LsstDm-4-6 "allow template over bool" */
106  return PropertySet::get<T>(name, defaultValue);
107 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
template<typename T >
std::vector<T> lsst::daf::base::PropertyList::getArray ( std::string const &  name) const
template<typename T >
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:

vector<int> v = propertyList.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 118 of file PropertyList.cc.

118  {
119  return PropertySet::getArray<T>(name);
120 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
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 128 of file PropertyList.cc.

129  {
130  return _comments.find(name)->second;
131 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
std::vector< std::string > lsst::daf::base::PropertyList::getOrderedNames ( void  ) const

Definition at line 133 of file PropertyList.cc.

133  {
134  std::vector<std::string> v;
135  for (std::list<std::string>::const_iterator i = _order.begin();
136  i != _order.end(); ++i) {
137  v.push_back(*i);
138  }
139  return v;
140 }
std::list< std::string > _order
Definition: PropertyList.h:210
void lsst::daf::base::PropertyList::remove ( std::string const &  name)
virtual

Removes 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 471 of file PropertyList.cc.

471  {
473  _comments.erase(name);
474  _order.remove(name);
475 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void remove(std::string const &name)
Definition: PropertySet.cc:754
std::list< std::string > _order
Definition: PropertyList.h:210
template<typename T >
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.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueValue to set.
[in]inPlaceIf false, property is moved to end of list.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 188 of file PropertyList.cc.

189  {
190  PropertySet::set(name, value);
191  if (!inPlace) {
192  _moveToEnd(name);
193  }
194 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void set(std::string const &name, T const &value)
Definition: PropertySet.cc:581
virtual void _moveToEnd(std::string const &name)
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.

198  {
199  Ptr pl = boost::dynamic_pointer_cast<PropertyList, PropertySet>(value);
200  PropertySet::set(name, value);
201  _comments.erase(name);
202  _order.remove(name);
203  vector<string> names = value->paramNames(false);
204  for (vector<string>::const_iterator i = names.begin();
205  i != names.end(); ++i) {
206  if (pl) {
207  _commentOrderFix(name + "." + *i, pl->getComment(*i), inPlace);
208  }
209  else if (inPlace) {
210  _moveToEnd(name + "." + *i);
211  }
212  }
213 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void set(std::string const &name, T const &value)
Definition: PropertySet.cc:581
virtual void _moveToEnd(std::string const &name)
std::vector< std::string > names(bool topLevelOnly=true) const
Definition: PropertySet.cc:117
std::list< std::string > _order
Definition: PropertyList.h:210
boost::shared_ptr< PropertyList > Ptr
Definition: PropertyList.h:84
Class for storing generic metadata.
Definition: PropertySet.h:82
virtual void _commentOrderFix(std::string const &name, std::string const &comment, bool inPlace)
template<typename T >
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.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueVector of values to set.
[in]inPlaceIf false, property is moved to end of list.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 238 of file PropertyList.cc.

239  {
240  PropertySet::set(name, value);
241  if (!inPlace) {
242  _moveToEnd(name);
243  }
244 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void set(std::string const &name, T const &value)
Definition: PropertySet.cc:581
virtual void _moveToEnd(std::string const &name)
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.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueCharacter string (converted to std::string ).
[in]inPlaceIf false, property is moved to end of list.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 222 of file PropertyList.cc.

223  {
224  set(name, string(value), inPlace);
225  if (!inPlace) {
226  _moveToEnd(name);
227  }
228 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void _moveToEnd(std::string const &name)
void set(std::string const &name, T const &value, bool inPlace=true)
template<typename T >
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.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueValue to set.
[in]commentComment to set.
[in]inPlaceIf false, property is moved to end of list.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 309 of file PropertyList.cc.

311  {
312  PropertySet::set(name, value);
313  _commentOrderFix(name, comment, inPlace);
314 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void set(std::string const &name, T const &value)
Definition: PropertySet.cc:581
virtual void _commentOrderFix(std::string const &name, std::string const &comment, bool inPlace)
template<typename T >
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.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueVector of values to set.
[in]commentComment to set.
[in]inPlaceIf false, property is moved to end of list.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 339 of file PropertyList.cc.

341  {
342  PropertySet::set(name, value);
343  _commentOrderFix(name, comment, inPlace);
344 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void set(std::string const &name, T const &value)
Definition: PropertySet.cc:581
virtual void _commentOrderFix(std::string const &name, std::string const &comment, bool inPlace)
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.

Parameters
[in]nameProperty name to set, possibly hierarchical.
[in]valueCharacter string value to set.
[in]commentComment to set.
[in]inPlaceIf false, property is moved to end of list.
Exceptions
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 324 of file PropertyList.cc.

326  {
327  set(name, string(value), comment, inPlace);
328 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void set(std::string const &name, T const &value, bool inPlace=true)
template<typename T >
void lsst::daf::base::PropertyList::set ( std::string const &  name,
T const &  value,
char const *  comment,
bool  inPlace = true 
)
inline

Definition at line 153 of file PropertyList.h.

155  {
156  set(name, value, std::string(comment), inPlace);
157  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void set(std::string const &name, T const &value, bool inPlace=true)
template<typename T >
void lsst::daf::base::PropertyList::set ( std::string const &  name,
std::vector< T > const &  value,
char const *  comment,
bool  inPlace = true 
)
inline

Definition at line 158 of file PropertyList.h.

160  {
161  set(name, value, std::string(comment), inPlace);
162  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void set(std::string const &name, T const &value, bool inPlace=true)
void lsst::daf::base::PropertyList::set ( std::string const &  name,
char const *  value,
char const *  comment,
bool  inPlace = true 
)
inline

Definition at line 163 of file PropertyList.h.

165  {
166  set(name, value, std::string(comment), inPlace);
167  }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void set(std::string const &name, T const &value, bool inPlace=true)
std::string lsst::daf::base::PropertyList::toString ( bool  topLevelOnly = false,
std::string const &  indent = "" 
) const
virtual

Generate a string representation of the PropertyList. 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 PropertyList.

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

Definition at line 158 of file PropertyList.cc.

159  {
160  ostringstream s;
161  for (std::list<std::string>::const_iterator i = _order.begin();
162  i != _order.end(); ++i) {
163  s << _format(*i);
164  std::string const& comment = _comments.find(*i)->second;
165  if (comment.size()) {
166  s << "// " << comment << std::endl;
167  }
168  }
169  return s.str();
170 }
std::list< std::string > _order
Definition: PropertyList.h:210
virtual std::string _format(std::string const &name) const
Definition: PropertySet.cc:507
if(width!=gim.getWidth()||height!=gim.getHeight()||x0!=gim.getX0()||y0!=gim.getY0())
Definition: saturated.cc:47

Member Data Documentation

CommentMap lsst::daf::base::PropertyList::_comments
private

Definition at line 209 of file PropertyList.h.

std::list<std::string> lsst::daf::base::PropertyList::_order
private

Definition at line 210 of file PropertyList.h.


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