LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected 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 lsst::daf::base::Citizen

Public Types

typedef std::shared_ptr< PropertyListPtr
 
typedef std::shared_ptr< PropertyList const > ConstPtr
 
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 ()
 Construct an empty PropertyList. More...
 
virtual ~PropertyList () noexcept
 Destructor. More...
 
virtual PropertySet::Ptr deepCopy () const
 Make a deep copy of the PropertyList and all of its contents. More...
 
template<typename T >
get (std::string const &name) const
 Get the last value for a property name (possibly hierarchical). More...
 
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. More...
 
template<typename T >
std::vector< T > getArray (std::string const &name) const
 Get the vector of values for a property name (possibly hierarchical). More...
 
std::string const & getComment (std::string const &name) const
 Get the comment for a string property name (possibly hierarchical). More...
 
std::vector< std::stringgetOrderedNames () const
 Get the list of property names, in the order they were added. More...
 
std::list< std::string >::const_iterator begin () const
 Begin iterator over the list of property names, in the order they were added. More...
 
std::list< std::string >::const_iterator end () const
 End iterator over the list of property names, in the order they were added. More...
 
virtual std::string toString (bool topLevelOnly=false, std::string const &indent="") const
 Generate a string representation of the PropertySet. More...
 
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. More...
 
void set (std::string const &name, PropertySet::Ptr const &value)
 Replace all values for a property name (possibly hierarchical) with a new PropertySet. More...
 
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. More...
 
void set (std::string const &name, char const *value)
 Replace all values for a property name (possibly hierarchical) with a string value. More...
 
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). More...
 
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). More...
 
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). More...
 
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. More...
 
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. More...
 
void set (std::string const &name, char const *value, std::string const &comment)
 Version of set char* value that accepts a comment. More...
 
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. More...
 
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. More...
 
void add (std::string const &name, char const *value, std::string const &comment)
 Version of add char* value that accepts a comment. More...
 
template<typename T >
void set (std::string const &name, T const &value, char const *comment)
 Version of set scalar value that accepts a comment. More...
 
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. More...
 
void set (std::string const &name, char const *value, char const *comment)
 Version of set char* value that accepts a comment. More...
 
template<typename T >
void add (std::string const &name, T const &value, char const *comment)
 Version of add scalar value that accepts a comment. More...
 
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. More...
 
void add (std::string const &name, char const *value, char const *comment)
 Version of add char* value that accepts a comment. More...
 
virtual void copy (std::string const &dest, PropertySet::ConstPtr source, std::string const &name, bool asScalar=false)
 Replace a single value vector in the destination with one from the source. More...
 
virtual void combine (PropertySet::ConstPtr source)
 Append all value vectors from the source to their corresponding properties. More...
 
virtual void remove (std::string const &name)
 Remove all values for a property name (possibly hierarchical). More...
 
size_t nameCount (bool topLevelOnly=true) const
 Get the number of names in the PropertySet, optionally including those in subproperties. More...
 
std::vector< std::stringnames (bool topLevelOnly=true) const
 Get the names in the PropertySet, optionally including those in subproperties. More...
 
std::vector< std::stringparamNames (bool topLevelOnly=true) const
 A variant of names that excludes the names of subproperties. More...
 
std::vector< std::stringpropertySetNames (bool topLevelOnly=true) const
 A variant of names that only returns the names of subproperties. More...
 
bool exists (std::string const &name) const
 Determine if a name (possibly hierarchical) exists. More...
 
bool isArray (std::string const &name) const
 Determine if a name (possibly hierarchical) has multiple values. More...
 
bool isPropertySetPtr (std::string const &name) const
 Determine if a name (possibly hierarchical) is a subproperty. More...
 
bool isUndefined (std::string const &name) const
 Determine if a name (possibly hierarchical) has a defined value. More...
 
size_t valueCount (std::string const &name) const
 Get the number of values for a property name (possibly hierarchical). More...
 
std::type_info const & typeOf (std::string const &name) const
 Get the type of values for a property name (possibly hierarchical). More...
 
bool getAsBool (std::string const &name) const
 Get the last value for a bool property name (possibly hierarchical). More...
 
int getAsInt (std::string const &name) const
 Get the last value for a bool/char/short/int property name (possibly hierarchical). More...
 
int64_t getAsInt64 (std::string const &name) const
 Get the last value for a bool/char/short/int/int64_t property name (possibly hierarchical). More...
 
uint64_t getAsUInt64 (std::string const &name) const
 Get the last value for an bool/char/short/int/int64_t property name (possibly hierarchical). More...
 
double getAsDouble (std::string const &name) const
 Get the last value for any arithmetic property name (possibly hierarchical). More...
 
std::string getAsString (std::string const &name) const
 Get the last value for a string property name (possibly hierarchical). More...
 
PropertySet::Ptr getAsPropertySetPtr (std::string const &name) const
 Get the last value for a subproperty name (possibly hierarchical). More...
 
Persistable::Ptr getAsPersistablePtr (std::string const &name) const
 Get the last value for a Persistable name (possibly hierarchical). More...
 
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...
 

Static Public Member Functions

template<typename T >
static std::type_info const & typeOfT ()
 Get type info for the specified class. More...
 
static bool hasBeenCorrupted ()
 Check all allocated blocks for corruption. More...
 
static memId getNextMemId ()
 Return the memId of the next object to be allocated. More...
 
static int init ()
 Called once when the memory system is being initialised. More...
 
Census

Provide a list of current Citizens

static int census (int, memId startingMemId=0)
 How many active Citizens are there? More...
 
static void census (std::ostream &stream, memId startingMemId=0)
 Print a list of all active Citizens to stream, sorted by ID. More...
 
static const std::vector< const Citizen * > * census ()
 Return a (newly allocated) std::vector of active Citizens sorted by ID. More...
 
callbackIDs

Set callback Ids.

The old Id is returned

static memId setNewCallbackId (memId id)
 Call the NewCallback when block is allocated. More...
 
static memId setDeleteCallbackId (memId id)
 Call the current DeleteCallback when block is deleted. More...
 
callbacks

Set the New/Delete callback functions; in each case the previously installed callback is returned.

These callback functions return a value which is Added to the previously registered id.

The default callback functions are called default{New,Delete}Callback; you may want to set a break point in these callbacks from your favourite debugger

static memNewCallback setNewCallback (memNewCallback func)
 Set the NewCallback function. More...
 
static memCallback setDeleteCallback (memCallback func)
 Set the DeleteCallback function. More...
 
static memCallback setCorruptionCallback (memCallback func)
 Set the CorruptionCallback function. More...
 

Protected Member Functions

virtual void _add (std::string const &name, std::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 68 of file PropertyList.h.

Member Typedef Documentation

◆ ConstPtr

Definition at line 72 of file PropertyList.h.

◆ memCallback

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

Definition at line 61 of file Citizen.h.

◆ memId

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

Type of the block's ID.

Definition at line 58 of file Citizen.h.

◆ memNewCallback

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

A function used to register a callback.

Definition at line 60 of file Citizen.h.

◆ Ptr

Definition at line 71 of file PropertyList.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited
Enumerator
magicSentinel 

Definition at line 88 of file Citizen.h.

Constructor & Destructor Documentation

◆ PropertyList()

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

Construct an empty PropertyList.

Constructor.

Definition at line 40 of file PropertyList.cc.

40 : 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< boost::any > >  vp 
)
protectedvirtualinherited

◆ _format()

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

◆ add() [1/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.

Definition at line 138 of file PropertyList.cc.

138  {
139  PropertySet::add(name, value);
140 }
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]

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

145  {
146  PropertySet::add(name, value);
147 }
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() [3/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 142 of file PropertyList.cc.

142 { add(name, std::string(value)); }
STL class.
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() [4/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 168 of file PropertyList.cc.

168  {
169  PropertySet::add(name, value);
170  _commentOrderFix(name, comment);
171 }
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,
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 178 of file PropertyList.cc.

178  {
179  PropertySet::add(name, value);
180  _commentOrderFix(name, comment);
181 }
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() [6/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 173 of file PropertyList.cc.

173  {
174  add(name, std::string(value), comment);
175 }
STL class.
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() [7/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 262 of file PropertyList.h.

262  {
263  add(name, value, std::string(comment));
264  }
STL class.
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() [8/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 267 of file PropertyList.h.

267  {
268  add(name, value, std::string(comment));
269  }
STL class.
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() [9/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 272 of file PropertyList.h.

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

◆ 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 89 of file PropertyList.cc.

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

◆ census() [1/3]

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

How many active Citizens are there?

Parameters
startingMemIdDon't print Citizens with lower IDs

Definition at line 238 of file Citizen.cc.

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

◆ census() [2/3]

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

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

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

Definition at line 259 of file Citizen.cc.

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

◆ census() [3/3]

std::vector< dafBase::Citizen const * > const * lsst::daf::base::Citizen::census ( )
staticinherited

Return a (newly allocated) std::vector of active Citizens sorted by ID.

You are responsible for deleting it; or you can say std::unique_ptr<std::vector<Citizen const*> const> leaks(Citizen::census()); and not bother (that becomes std::unique_ptr in C++11)

Definition at line 287 of file Citizen.cc.

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

◆ combine()

void lsst::daf::base::PropertyList::combine ( PropertySet::ConstPtr  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::Ptr for the source PropertySet.
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 195 of file PropertyList.cc.

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

◆ copy()

void lsst::daf::base::PropertyList::copy ( std::string const &  dest,
PropertySet::ConstPtr  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::Ptr for the source PropertySet.
[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 186 of file PropertyList.cc.

187  {
188  PropertySet::copy(dest, source, name, asScalar);
190  if (pl) {
191  _comments[name] = pl->_comments.find(name)->second;
192  }
193 }
virtual void copy(std::string const &dest, ConstPtr source, std::string const &name, bool asScalar=false)
Replace a single value vector in the destination with one from the source.
PropertySet(bool flat=false)
Construct an empty PropertySet.
std::shared_ptr< PropertyList const > ConstPtr
Definition: PropertyList.h:72
const char * source()
Source function that allows astChannel to source from a Stream.
Definition: Stream.h:224
T dynamic_pointer_cast(T... args)
T find(T... args)
PropertyList()
Construct an empty PropertyList.
Definition: PropertyList.cc:40

◆ deepCopy()

PropertySet::Ptr lsst::daf::base::PropertyList::deepCopy ( ) const
virtual

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

Returns
PropertyList::Ptr pointing to the new copy.

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

Definition at line 50 of file PropertyList.cc.

50  {
51  Ptr n(new PropertyList);
52  n->PropertySet::combine(this->PropertySet::deepCopy());
53  n->_order = _order;
54  n->_comments = _comments;
55  return n;
56 }
std::shared_ptr< PropertyList > Ptr
Definition: PropertyList.h:71
virtual Ptr deepCopy() const
Make a deep copy of the PropertySet and all of its contents.
PropertyList()
Construct an empty PropertyList.
Definition: PropertyList.cc:40

◆ 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 91 of file PropertyList.cc.

91 { return _order.end(); }
T end(T... args)

◆ 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 61 of file PropertyList.cc.

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

◆ 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 67 of file PropertyList.cc.

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

◆ 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 73 of file PropertyList.cc.

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

◆ 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()

PropertySet::Ptr 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::Ptr value.
Exceptions
NotFoundErrorProperty does not exist.
TypeErrorValue is not a PropertySet::Ptr.

◆ 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 77 of file PropertyList.cc.

77  {
78  return _comments.find(name)->second;
79 }
T find(T... args)

◆ getId()

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

Return the Citizen's ID.

Definition at line 206 of file Citizen.cc.

206 { return _CitizenId; }

◆ getNextMemId()

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

Return the memId of the next object to be allocated.

Definition at line 209 of file Citizen.cc.

209 { return _nextMemId(); }

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

81  {
83  for (auto const& name : _order) {
84  v.push_back(name);
85  }
86  return v;
87 }
T push_back(T... args)

◆ hasBeenCorrupted()

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

Check all allocated blocks for corruption.

Definition at line 316 of file Citizen.cc.

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

◆ init()

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

Called once when the memory system is being initialised.

Definition at line 196 of file Citizen.cc.

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

◆ isArray()

bool lsst::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::Ptrs.

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

◆ markPersistent()

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

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

Definition at line 225 of file Citizen.cc.

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

◆ 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 216 of file PropertyList.cc.

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

◆ repr()

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

Return a string representation of a Citizen.

Definition at line 219 of file Citizen.cc.

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

◆ set() [1/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.

Definition at line 113 of file PropertyList.cc.

113  {
114  PropertySet::set(name, value);
115 }
void set(std::string const &name, T const &value)
Replace all values for a property name (possibly hierarchical) with a new scalar value.

◆ set() [2/10]

void lsst::daf::base::PropertyList::set ( std::string const &  name,
PropertySet::Ptr 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.

Definition at line 117 of file PropertyList.cc.

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

◆ set() [3/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 133 of file PropertyList.cc.

133  {
134  PropertySet::set(name, value);
135 }
void set(std::string const &name, T const &value)
Replace all values for a property name (possibly hierarchical) with a new scalar value.

◆ set() [4/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 130 of file PropertyList.cc.

◆ set() [5/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 153 of file PropertyList.cc.

153  {
154  PropertySet::set(name, value);
155  _commentOrderFix(name, comment);
156 }
void set(std::string const &name, T const &value)
Replace all values for a property name (possibly hierarchical) with a new scalar value.

◆ set() [6/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 163 of file PropertyList.cc.

163  {
164  PropertySet::set(name, value);
165  _commentOrderFix(name, comment);
166 }
void set(std::string const &name, T const &value)
Replace all values for a property name (possibly hierarchical) with a new scalar value.

◆ set() [7/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 158 of file PropertyList.cc.

158  {
159  set(name, std::string(value), comment);
160 }
STL class.

◆ set() [8/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 245 of file PropertyList.h.

245  {
246  set(name, value, std::string(comment));
247  }
STL class.

◆ set() [9/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 251 of file PropertyList.h.

251  {
252  set(name, value, std::string(comment));
253  }
STL class.

◆ set() [10/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 256 of file PropertyList.h.

256  {
257  set(name, value, std::string(comment));
258  }
STL class.

◆ setCorruptionCallback()

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

Set the CorruptionCallback function.

Parameters
funcfunction be called when block is found to be corrupted

Definition at line 391 of file Citizen.cc.

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

◆ setDeleteCallback()

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

Set the DeleteCallback function.

Parameters
funcfunction be called when desired block is deleted

Definition at line 381 of file Citizen.cc.

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

◆ setDeleteCallbackId()

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

Call the current DeleteCallback when block is deleted.

Parameters
idDesired ID

Definition at line 347 of file Citizen.cc.

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

◆ setNewCallback()

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

Set the NewCallback function.

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

Definition at line 371 of file Citizen.cc.

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

◆ setNewCallbackId()

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

Call the NewCallback when block is allocated.

Parameters
idDesired ID

Definition at line 337 of file Citizen.cc.

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

◆ 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 93 of file PropertyList.cc.

93  {
95  for (auto const& name : _order) {
96  s << _format(name);
97  std::string const& comment = _comments.find(name)->second;
98  if (comment.size()) {
99  s << "// " << comment << std::endl;
100  }
101  }
102  return s.str();
103 }
T endl(T... args)
virtual std::string _format(std::string const &name) const
STL class.
T str(T... args)
solver_t * s
T find(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()

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: