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 | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
lsst::daf::base::PropertySet Class Reference

Class for storing generic metadata. More...

#include <PropertySet.h>

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

Public Types

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

 PropertySet (bool flat=false)
 
virtual ~PropertySet (void)
 
virtual Ptr deepCopy (void) const
 
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
 
virtual std::string toString (bool topLevelOnly=false, std::string const &indent="") 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)
 
virtual void copy (std::string const &dest, ConstPtr source, std::string const &name)
 
virtual void combine (ConstPtr source)
 
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::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...
 

Protected Member Functions

virtual void _set (std::string const &name, boost::shared_ptr< std::vector< boost::any > > vp)
 
virtual void _add (std::string const &name, boost::shared_ptr< std::vector< boost::any > > vp)
 
virtual std::string _format (std::string const &name) const
 

Private Types

typedef
std::tr1::unordered_map
< std::string,
boost::shared_ptr< std::vector
< boost::any > > > 
AnyMap
 

Private Member Functions

AnyMap::iterator _find (std::string const &name)
 
AnyMap::const_iterator _find (std::string const &name) const
 
virtual void _findOrInsert (std::string const &name, boost::shared_ptr< std::vector< boost::any > > vp)
 
void _cycleCheckPtrVec (std::vector< Ptr > const &v, std::string const &name)
 
void _cycleCheckAnyVec (std::vector< boost::any > const &v, std::string const &name)
 
void _cycleCheckPtr (Ptr const &v, std::string const &name)
 

Private Attributes

AnyMap _map
 
bool _flat
 

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

Detailed Description

Class for storing generic metadata.

This class stores key/value pairs, like a Python dictionary but in C++. Keys are always C++ strings. Values can be C++ primitive data types, strings, lsst::daf::base::DateTime objects, and lsst::daf::base::Persistable subclasses (although the latter is currently discouraged). Values can also be vectors of these items.

PropertySets are hierarchical; values within a PropertySet that is contained within another PropertySet can be addressed using dotted paths ("a.b.c"). If "flat=true" is specified to the constructor, the PropertySet still takes dotted paths but is not actually hierarchical in structure. This is used to support PropertyList.

Definition at line 82 of file PropertySet.h.

Member Typedef Documentation

typedef std::tr1::unordered_map<std::string, boost::shared_ptr< std::vector<boost::any> > > lsst::daf::base::PropertySet::AnyMap
private

Definition at line 167 of file PropertySet.h.

typedef boost::shared_ptr<PropertySet const> lsst::daf::base::PropertySet::ConstPtr

Definition at line 91 of file PropertySet.h.

typedef boost::shared_ptr<PropertySet> lsst::daf::base::PropertySet::Ptr

Definition at line 90 of file PropertySet.h.

Constructor & Destructor Documentation

lsst::daf::base::PropertySet::PropertySet ( bool  flat = false)
explicit

Constructor.

Parameters
[in]flatfalse (default) = flatten hierarchy by ignoring dots in names

Definition at line 55 of file PropertySet.cc.

55  : Citizen(typeid(*this)), _flat(flat) {
56 }
Citizen(const std::type_info &)
Definition: Citizen.cc:173
lsst::daf::base::PropertySet::~PropertySet ( void  )
virtual

Destructor.

Definition at line 60 of file PropertySet.cc.

60  {
61 }

Member Function Documentation

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

Finds the property name (possibly hierarchical) and appends or sets its value with the given vector of values.

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

Definition at line 848 of file PropertySet.cc.

849  {
850 
851  AnyMap::const_iterator dp = _find(name);
852  if (dp == _map.end()) {
853  _set(name, vp);
854  }
855  else {
856  if (vp->back().type() != dp->second->back().type()) {
857  throw LSST_EXCEPT(pexExcept::TypeError,
858  name + " has mismatched type");
859  }
860  // Check for cycles
861  if (vp->back().type() == typeid(Ptr)) {
862  _cycleCheckAnyVec(*vp, name);
863  }
864  dp->second->insert(dp->second->end(), vp->begin(), vp->end());
865  }
866 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
virtual void _set(std::string const &name, boost::shared_ptr< std::vector< boost::any > > vp)
Definition: PropertySet.cc:837
void _cycleCheckAnyVec(std::vector< boost::any > const &v, std::string const &name)
Definition: PropertySet.cc:929
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
void lsst::daf::base::PropertySet::_cycleCheckAnyVec ( std::vector< boost::any > const &  v,
std::string const &  name 
)
private

Definition at line 929 of file PropertySet.cc.

930  {
931  for (vector<boost::any>::const_iterator i = v.begin(); i != v.end(); ++i) {
932  _cycleCheckPtr(boost::any_cast<Ptr>(*i), name);
933  }
934 }
void _cycleCheckPtr(Ptr const &v, std::string const &name)
Definition: PropertySet.cc:936
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void lsst::daf::base::PropertySet::_cycleCheckPtr ( Ptr const &  v,
std::string const &  name 
)
private

Definition at line 936 of file PropertySet.cc.

937  {
938  if (v.get() == this) {
939  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
940  name + " would cause a cycle");
941  }
942  vector<string> sets = v->propertySetNames(false);
943  for (vector<string>::const_iterator i = sets.begin();
944  i != sets.end(); ++i) {
945  if (v->getAsPropertySetPtr(*i).get() == this) {
946  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
947  name + " would cause a cycle");
948  }
949  }
950 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
void lsst::daf::base::PropertySet::_cycleCheckPtrVec ( std::vector< Ptr > const &  v,
std::string const &  name 
)
private

Definition at line 922 of file PropertySet.cc.

923  {
924  for (vector<Ptr>::const_iterator i = v.begin(); i != v.end(); ++i) {
925  _cycleCheckPtr(*i, name);
926  }
927 }
void _cycleCheckPtr(Ptr const &v, std::string const &name)
Definition: PropertySet.cc:936
table::Key< std::string > name
Definition: ApCorrMap.cc:71
dafBase::PropertySet::AnyMap::iterator lsst::daf::base::PropertySet::_find ( std::string const &  name)
private

Finds the property name (possibly hierarchical).

Parameters
[in]nameProperty name to find, possibly hierarchical.
Returns
unordered_map::iterator to the property or end() if nonexistent.

Definition at line 781 of file PropertySet.cc.

781  {
782  string::size_type i = name.find('.');
783  if (_flat || i == name.npos) {
784  return _map.find(name);
785  }
786  string prefix(name, 0, i);
787  AnyMap::iterator j = _map.find(prefix);
788  if (j == _map.end() || j->second->back().type() != typeid(Ptr)) {
789  return _map.end();
790  }
791  Ptr p = boost::any_cast<Ptr>(j->second->back());
792  if (p.get() == 0) {
793  return _map.end();
794  }
795  string suffix(name, i + 1);
796  AnyMap::iterator x = p->_find(suffix);
797  if (x == p->_map.end()) {
798  return _map.end();
799  }
800  return x;
801 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
double x
dafBase::PropertySet::AnyMap::const_iterator lsst::daf::base::PropertySet::_find ( std::string const &  name) const
private

Finds the property name (possibly hierarchical). Const version.

Parameters
[in]nameProperty name to find, possibly hierarchical.
Returns
unordered_map::const_iterator to the property or end().

Definition at line 808 of file PropertySet.cc.

808  {
809  string::size_type i = name.find('.');
810  if (_flat || i == name.npos) {
811  return _map.find(name);
812  }
813  string prefix(name, 0, i);
814  AnyMap::const_iterator j = _map.find(prefix);
815  if (j == _map.end() || j->second->back().type() != typeid(Ptr)) {
816  return _map.end();
817  }
818  Ptr p = boost::any_cast<Ptr>(j->second->back());
819  if (p.get() == 0) {
820  return _map.end();
821  }
822  string suffix(name, i + 1);
823  AnyMap::const_iterator x = p->_find(suffix);
824  if (x == p->_map.end()) {
825  return _map.end();
826  }
827  return x;
828 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
double x
void lsst::daf::base::PropertySet::_findOrInsert ( 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.

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

Definition at line 874 of file PropertySet.cc.

875  {
876  if (vp->back().type() == typeid(Ptr)) {
877  if (_flat) {
878  Ptr source = boost::any_cast<Ptr>(vp->back());
879  vector<string> names = source->paramNames(false);
880  for (vector<string>::const_iterator i = names.begin();
881  i != names.end(); ++i) {
882  AnyMap::const_iterator sp = source->_find(*i);
883  _add(name + "." + *i, sp->second);
884  }
885  return;
886  }
887 
888  // Check for cycles
889  _cycleCheckAnyVec(*vp, name);
890  }
891 
892  string::size_type i = name.find('.');
893  if (_flat || i == name.npos) {
894  _map[name] = vp;
895  return;
896  }
897  string prefix(name, 0, i);
898  string suffix(name, i + 1);
899  AnyMap::iterator j = _map.find(prefix);
900  if (j == _map.end()) {
902  pp->_findOrInsert(suffix, vp);
903  boost::shared_ptr< vector<boost::any> > temp(new vector<boost::any>);
904  temp->push_back(pp);
905  _map[prefix] = temp;
906  return;
907  }
908  else if (j->second->back().type() != typeid(Ptr)) {
909  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
910  prefix +
911  " exists but does not contain PropertySet::Ptrs");
912  }
913  Ptr p = boost::any_cast<Ptr>(j->second->back());
914  if (p.get() == 0) {
915  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
916  prefix +
917  " exists but contains null PropertySet::Ptr");
918  }
919  p->_findOrInsert(suffix, vp);
920 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void _add(std::string const &name, boost::shared_ptr< std::vector< boost::any > > vp)
Definition: PropertySet.cc:848
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
std::vector< std::string > names(bool topLevelOnly=true) const
Definition: PropertySet.cc:117
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
Class for storing generic metadata.
Definition: PropertySet.h:82
void _cycleCheckAnyVec(std::vector< boost::any > const &v, std::string const &name)
Definition: PropertySet.cc:929
std::string lsst::daf::base::PropertySet::_format ( std::string const &  name) const
protectedvirtual

Definition at line 507 of file PropertySet.cc.

507  {
508  ostringstream s;
509  s << std::showpoint; // Always show a decimal point for floats
510  AnyMap::const_iterator j = _map.find(name);
511  s << j->first << " = ";
512  boost::shared_ptr< vector<boost::any> > vp = j->second;
513  if (vp->size() > 1) {
514  s << "[ ";
515  }
516  type_info const& t = vp->back().type();
517  for (vector<boost::any>::const_iterator k = vp->begin();
518  k != vp->end(); ++k) {
519  if (k != vp->begin()) {
520  s << ", ";
521  }
522  boost::any const& v(*k);
523  if (t == typeid(bool)) {
524  s << boost::any_cast<bool>(v);
525  } else if (t == typeid(char)) {
526  s << '\'' << boost::any_cast<char>(v) << '\'';
527  } else if (t == typeid(signed char)) {
528  s << '\'' << boost::any_cast<signed char>(v) << '\'';
529  } else if (t == typeid(unsigned char)) {
530  s << '\'' << boost::any_cast<unsigned char>(v) << '\'';
531  } else if (t == typeid(short)) {
532  s << boost::any_cast<short>(v);
533  } else if (t == typeid(unsigned short)) {
534  s << boost::any_cast<unsigned short>(v);
535  } else if (t == typeid(int)) {
536  s << boost::any_cast<int>(v);
537  } else if (t == typeid(unsigned int)) {
538  s << boost::any_cast<unsigned int>(v);
539  } else if (t == typeid(long)) {
540  s << boost::any_cast<long>(v);
541  } else if (t == typeid(unsigned long)) {
542  s << boost::any_cast<unsigned long>(v);
543  } else if (t == typeid(long long)) {
544  s << boost::any_cast<long long>(v);
545  } else if (t == typeid(unsigned long long)) {
546  s << boost::any_cast<unsigned long long>(v);
547  } else if (t == typeid(float)) {
548  s << std::setprecision(7) << boost::any_cast<float>(v);
549  } else if (t == typeid(double)) {
550  s << std::setprecision(14) << boost::any_cast<double>(v);
551  } else if (t == typeid(string)) {
552  s << '"' << boost::any_cast<string>(v) << '"';
553  } else if (t == typeid(dafBase::DateTime)) {
554  s << boost::any_cast<dafBase::DateTime>(v).toString();
555  } else if (t == typeid(Ptr)) {
556  s << "{ ... }";
557  } else if (t == typeid(Persistable::Ptr)) {
558  s << "<Persistable>";
559  } else {
560  s << "<Unknown>";
561  }
562  }
563  if (j->second->size() > 1) {
564  s << " ]";
565  }
566  s << endl;
567  return s.str();
568 }
Class for handling dates/times, including MJD, UTC, and TAI.
Definition: DateTime.h:58
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
bool any(CoordinateExpr< N > const &expr)
Return true if any elements are true.
boost::shared_ptr< Persistable > Ptr
Definition: Persistable.h:76
virtual std::string toString(bool topLevelOnly=false, std::string const &indent="") const
Definition: PropertySet.cc:476
void lsst::daf::base::PropertySet::_set ( std::string const &  name,
boost::shared_ptr< std::vector< boost::any > >  vp 
)
protectedvirtual

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

Definition at line 837 of file PropertySet.cc.

838  {
839  _findOrInsert(name, vp);
840 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void _findOrInsert(std::string const &name, boost::shared_ptr< std::vector< boost::any > > vp)
Definition: PropertySet.cc:874
template<typename T >
void lsst::daf::base::PropertySet::add ( std::string const &  name,
T const &  value 
)

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.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 619 of file PropertySet.cc.

619  {
620  AnyMap::iterator i = _find(name);
621  if (i == _map.end()) {
622  set(name, value);
623  }
624  else {
625  if (i->second->back().type() != typeid(T)) {
626  throw LSST_EXCEPT(pexExcept::TypeError,
627  name + " has mismatched type");
628  }
629  i->second->push_back(value);
630  }
631 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void set(std::string const &name, T const &value)
Definition: PropertySet.cc:581
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
template<typename T >
void lsst::daf::base::PropertySet::add ( std::string const &  name,
std::vector< T > const &  value 
)

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.
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 660 of file PropertySet.cc.

661  {
662  AnyMap::iterator i = _find(name);
663  if (i == _map.end()) {
664  set(name, value);
665  }
666  else {
667  if (i->second->back().type() != typeid(T)) {
668  throw LSST_EXCEPT(pexExcept::TypeError,
669  name + " has mismatched type");
670  }
671  i->second->insert(i->second->end(), value.begin(), value.end());
672  }
673 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void set(std::string const &name, T const &value)
Definition: PropertySet.cc:581
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
void lsst::daf::base::PropertySet::add ( std::string const &  name,
char const *  value 
)

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]valueCharacter string value to append.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorHierarchical name uses non-PropertySet.

Definition at line 700 of file PropertySet.cc.

700  {
701  add(name, string(value));
702 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void add(std::string const &name, T const &value)
Definition: PropertySet.cc:619
void lsst::daf::base::PropertySet::combine ( ConstPtr  source)
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.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorHierarchical name uses non-PropertySet.
Note
May only partially combine the PropertySets if an exception occurs.

Reimplemented in lsst::daf::base::PropertyList.

Definition at line 738 of file PropertySet.cc.

738  {
739  if (source.get() == 0) {
740  return;
741  }
742  vector<string> names = source->paramNames(false);
743  for (vector<string>::const_iterator i = names.begin();
744  i != names.end(); ++i) {
745  AnyMap::const_iterator sp = source->_find(*i);
746  _add(*i, sp->second);
747  }
748 }
virtual void _add(std::string const &name, boost::shared_ptr< std::vector< boost::any > > vp)
Definition: PropertySet.cc:848
std::vector< std::string > names(bool topLevelOnly=true) const
Definition: PropertySet.cc:117
void lsst::daf::base::PropertySet::copy ( std::string const &  dest,
ConstPtr  source,
std::string const &  name 
)
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.
Exceptions
TypeErrorType does not match existing values.
InvalidParameterErrorName does not exist in source.
InvalidParameterErrorHierarchical name uses non-PropertySet.

Reimplemented in lsst::daf::base::PropertyList.

Definition at line 713 of file PropertySet.cc.

714  {
715  if (source.get() == 0) {
716  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
717  "Missing source");
718  }
719  AnyMap::const_iterator sj = source->_find(name);
720  if (sj == source->_map.end()) {
721  throw LSST_EXCEPT(pexExcept::InvalidParameterError,
722  name + " not in source");
723  }
724  remove(dest);
725  boost::shared_ptr< vector<boost::any> > vp(
726  new vector<boost::any>(*(sj->second)));
727  _set(dest, vp);
728 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
virtual void _set(std::string const &name, boost::shared_ptr< std::vector< boost::any > > vp)
Definition: PropertySet.cc:837
dafBase::PropertySet::Ptr lsst::daf::base::PropertySet::deepCopy ( void  ) const
virtual

Copy the PropertySet and all of its contents.

Returns
PropertySet::Ptr pointing to the new copy.

Reimplemented in lsst::daf::base::PropertyList.

Definition at line 70 of file PropertySet.cc.

70  {
71  Ptr n(new PropertySet(_flat));
72  for (AnyMap::const_iterator i = _map.begin(); i != _map.end(); ++i) {
73  if (i->second->back().type() == typeid(Ptr)) {
74  for (vector<boost::any>::const_iterator j =
75  i->second->begin(); j != i->second->end(); ++j) {
76  Ptr p = boost::any_cast<Ptr>(*j);
77  if (p.get() == 0) {
78  n->add(i->first, Ptr());
79  } else {
80  n->add(i->first, p->deepCopy());
81  }
82  }
83  } else {
84  boost::shared_ptr< vector<boost::any> > vp(
85  new vector<boost::any>(*(i->second)));
86  n->_map[i->first] = vp;
87  }
88  }
89  return n;
90 }
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
PropertySet(bool flat=false)
Definition: PropertySet.cc:55
bool lsst::daf::base::PropertySet::exists ( std::string const &  name) const

Determine if a name (possibly hierarchical) exists.

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

Definition at line 190 of file PropertySet.cc.

190  {
191  return _find(name) != _map.end();
192 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
template<typename T >
T lsst::daf::base::PropertySet::get ( std::string const &  name) const

Get the last value for a property name (possibly hierarchical). Note that the type must be explicitly specified for this template:

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 246 of file PropertySet.cc.

246  { /* parasoft-suppress LsstDm-3-4a LsstDm-4-6 "allow template over bool" */
247  AnyMap::const_iterator i = _find(name);
248  if (i == _map.end()) {
249  throw LSST_EXCEPT(pexExcept::NotFoundError, name + " not found");
250  }
251  try {
252  return boost::any_cast<T>(i->second->back());
253  }
254  catch (boost::bad_any_cast) {
255  throw LSST_EXCEPT(pexExcept::TypeError, name);
256  }
257  // not reached
258  return boost::any_cast<T>(i->second->back());
259 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
template<typename T >
T lsst::daf::base::PropertySet::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 = 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 271 of file PropertySet.cc.

271  { /* parasoft-suppress LsstDm-3-4a LsstDm-4-6 "allow template over bool" */
272  AnyMap::const_iterator i = _find(name);
273  if (i == _map.end()) {
274  return defaultValue;
275  }
276  try {
277  return boost::any_cast<T>(i->second->back());
278  }
279  catch (boost::bad_any_cast) {
280  throw LSST_EXCEPT(pexExcept::TypeError, name);
281  }
282  // not reached
283  return boost::any_cast<T>(i->second->back());
284 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
template<typename T >
std::vector<T> lsst::daf::base::PropertySet::getArray ( std::string const &  name) const
template<typename T >
vector<T> lsst::daf::base::PropertySet::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 = 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 295 of file PropertySet.cc.

295  {
296  AnyMap::const_iterator i = _find(name);
297  if (i == _map.end()) {
298  throw LSST_EXCEPT(pexExcept::NotFoundError, name + " not found");
299  }
300  vector<T> v;
301  for (vector<boost::any>::const_iterator j = i->second->begin();
302  j != i->second->end(); ++j) {
303  try {
304  v.push_back(boost::any_cast<T>(*j));
305  }
306  catch (boost::bad_any_cast) {
307  throw LSST_EXCEPT(pexExcept::TypeError, name);
308  }
309  }
310  return v;
311 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
bool lsst::daf::base::PropertySet::getAsBool ( std::string const &  name) const

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

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

Definition at line 321 of file PropertySet.cc.

321  { /* parasoft-suppress LsstDm-3-4a LsstDm-4-6 "for symmetry with other types" */
322  return get<bool>(name);
323 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
double lsst::daf::base::PropertySet::getAsDouble ( std::string const &  name) const

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.

Definition at line 406 of file PropertySet.cc.

406  {
407  AnyMap::const_iterator i = _find(name);
408  if (i == _map.end()) {
409  throw LSST_EXCEPT(pexExcept::NotFoundError, name + " not found");
410  }
411  boost::any v = i->second->back();
412  type_info const& t = v.type();
413  if (t == typeid(bool)) return boost::any_cast<bool>(v);
414  if (t == typeid(char)) return boost::any_cast<char>(v);
415  if (t == typeid(signed char)) return boost::any_cast<signed char>(v);
416  if (t == typeid(unsigned char)) return boost::any_cast<unsigned char>(v);
417  if (t == typeid(short)) return boost::any_cast<short>(v);
418  if (t == typeid(unsigned short)) return boost::any_cast<unsigned short>(v);
419  if (t == typeid(int)) return boost::any_cast<int>(v);
420  if (t == typeid(unsigned int)) return boost::any_cast<unsigned int>(v);
421  if (t == typeid(long)) return boost::any_cast<long>(v);
422  if (t == typeid(unsigned long)) return boost::any_cast<unsigned long>(v);
423  if (t == typeid(long long)) return boost::any_cast<long long>(v);
424  if (t == typeid(unsigned long long)) return boost::any_cast<unsigned long long>(v);
425  if (t == typeid(float)) return boost::any_cast<float>(v);
426  try {
427  return boost::any_cast<double>(v);
428  }
429  catch (boost::bad_any_cast) {
430  throw LSST_EXCEPT(pexExcept::TypeError, name);
431  }
432  // not reached
433  return boost::any_cast<double>(v);
434 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
bool any(CoordinateExpr< N > const &expr)
Return true if any elements are true.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
int lsst::daf::base::PropertySet::getAsInt ( std::string const &  name) const

Get the last value for a bool/char/short/int property name (possibly hierarchical). Unsigned int properties are not acceptable, but unsigned versions of smaller types are.

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

Definition at line 333 of file PropertySet.cc.

333  {
334  AnyMap::const_iterator i = _find(name);
335  if (i == _map.end()) {
336  throw LSST_EXCEPT(pexExcept::NotFoundError, name + " not found");
337  }
338  boost::any v = i->second->back();
339  type_info const& t = v.type();
340  if (t == typeid(bool)) {
341  return boost::any_cast<bool>(v);
342  } else if (t == typeid(char)) {
343  return boost::any_cast<char>(v);
344  } else if (t == typeid(signed char)) {
345  return boost::any_cast<signed char>(v);
346  } else if (t == typeid(unsigned char)) {
347  return boost::any_cast<unsigned char>(v);
348  } else if (t == typeid(short)) {
349  return boost::any_cast<short>(v);
350  } else if (t == typeid(unsigned short)) {
351  return boost::any_cast<unsigned short>(v);
352  }
353  try {
354  return boost::any_cast<int>(v);
355  }
356  catch (boost::bad_any_cast) {
357  throw LSST_EXCEPT(pexExcept::TypeError, name);
358  }
359  // not reached
360  return boost::any_cast<int>(v);
361 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
bool any(CoordinateExpr< N > const &expr)
Return true if any elements are true.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
int64_t lsst::daf::base::PropertySet::getAsInt64 ( std::string const &  name) const

Get the last value for a bool/char/short/int/int64_t property name (possibly hierarchical). Unsigned int64_t properties are not acceptable, but unsigned versions of smaller types are, except possibly unsigned long, depending on compiler.

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.

Definition at line 372 of file PropertySet.cc.

372  {
373  AnyMap::const_iterator i = _find(name);
374  if (i == _map.end()) {
375  throw LSST_EXCEPT(pexExcept::NotFoundError, name + " not found");
376  }
377  boost::any v = i->second->back();
378  type_info const& t = v.type();
379  if (t == typeid(bool)) return boost::any_cast<bool>(v);
380  if (t == typeid(char)) return boost::any_cast<char>(v);
381  if (t == typeid(signed char)) return boost::any_cast<signed char>(v);
382  if (t == typeid(unsigned char)) return boost::any_cast<unsigned char>(v);
383  if (t == typeid(short)) return boost::any_cast<short>(v);
384  if (t == typeid(unsigned short)) return boost::any_cast<unsigned short>(v);
385  if (t == typeid(int)) return boost::any_cast<int>(v);
386  if (t == typeid(unsigned int)) return boost::any_cast<unsigned int>(v);
387  if (t == typeid(long)) return boost::any_cast<long>(v);
388  if (t == typeid(long long)) return boost::any_cast<long long>(v);
389  try {
390  return boost::any_cast<int64_t>(v);
391  }
392  catch (boost::bad_any_cast) {
393  throw LSST_EXCEPT(pexExcept::TypeError, name);
394  }
395  // not reached
396  return boost::any_cast<int64_t>(v);
397 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
bool any(CoordinateExpr< N > const &expr)
Return true if any elements are true.
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
dafBase::Persistable::Ptr lsst::daf::base::PropertySet::getAsPersistablePtr ( std::string const &  name) const

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.

Definition at line 466 of file PropertySet.cc.

466  {
467  return get<Persistable::Ptr>(name);
468 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
dafBase::PropertySet::Ptr lsst::daf::base::PropertySet::getAsPropertySetPtr ( std::string const &  name) const

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.

Definition at line 455 of file PropertySet.cc.

455  {
456  return get<Ptr>(name);
457 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
std::string lsst::daf::base::PropertySet::getAsString ( std::string const &  name) const

Get the last value for a string property name (possibly hierarchical). Note that properties set with char const* can be retrieved as strings using this method.

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

Definition at line 444 of file PropertySet.cc.

444  {
445  return get<string>(name);
446 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
bool lsst::daf::base::PropertySet::isArray ( std::string const &  name) const

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.

Definition at line 198 of file PropertySet.cc.

198  {
199  AnyMap::const_iterator i = _find(name);
200  return i != _map.end() && i->second->size() > 1U;
201 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
bool lsst::daf::base::PropertySet::isPropertySetPtr ( std::string const &  name) const

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.

Definition at line 207 of file PropertySet.cc.

207  {
208  AnyMap::const_iterator i = _find(name);
209  return i != _map.end() && i->second->back().type() == typeid(Ptr);
210 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
size_t lsst::daf::base::PropertySet::nameCount ( bool  topLevelOnly = true) const

Get the number of names in the PropertySet, optionally including those in subproperties. The name of the subproperty is counted in that case.

Parameters
[in]topLevelOnlytrue (default) = don't include subproperties.
Returns
Number of names.

Definition at line 97 of file PropertySet.cc.

97  {
98  int n = 0;
99  for (AnyMap::const_iterator i = _map.begin(); i != _map.end(); ++i) {
100  ++n;
101  if (!topLevelOnly && i->second->back().type() == typeid(Ptr)) {
102  Ptr p = boost::any_cast<Ptr>(i->second->back());
103  if (p.get() != 0) {
104  n += p->nameCount(false);
105  }
106  }
107  }
108  return n;
109 }
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
vector< string > lsst::daf::base::PropertySet::names ( bool  topLevelOnly = true) const

Get the names in the PropertySet, optionally including those in subproperties. The name of the subproperty is included in that case. Hierarchical subproperty names are separated by a period.

Parameters
[in]topLevelOnlytrue (default) = don't include subproperties.
Returns
Vector of names.

Definition at line 117 of file PropertySet.cc.

117  {
118  vector<string> v;
119  for (AnyMap::const_iterator i = _map.begin(); i != _map.end(); ++i) {
120  v.push_back(i->first);
121  if (!topLevelOnly && i->second->back().type() == typeid(Ptr)) {
122  Ptr p = boost::any_cast<Ptr>(i->second->back());
123  if (p.get() != 0) {
124  vector<string> w = p->names(false);
125  for (vector<string>::const_iterator k = w.begin();
126  k != w.end(); ++k) {
127  v.push_back(i->first + "." + *k);
128  }
129  }
130  }
131  }
132  return v;
133 }
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
double w
Definition: CoaddPsf.cc:57
vector< string > lsst::daf::base::PropertySet::paramNames ( bool  topLevelOnly = true) const

Get the names of parameters (non-subproperties) in the PropertySet, optionally including those in subproperties. Hierarchical subproperty names are separated by a period.

Parameters
[in]topLevelOnlytrue (default) = don't include subproperties.
Returns
Vector of parameter names.

Definition at line 142 of file PropertySet.cc.

142  {
143  vector<string> v;
144  for (AnyMap::const_iterator i = _map.begin(); i != _map.end(); ++i) {
145  if (i->second->back().type() == typeid(Ptr)) {
146  Ptr p = boost::any_cast<Ptr>(i->second->back());
147  if (p.get() != 0 && !topLevelOnly) {
148  vector<string> w = p->paramNames(false);
149  for (vector<string>::const_iterator k = w.begin();
150  k != w.end(); ++k) {
151  v.push_back(i->first + "." + *k);
152  }
153  }
154  } else {
155  v.push_back(i->first);
156  }
157  }
158  return v;
159 }
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
double w
Definition: CoaddPsf.cc:57
vector< string > lsst::daf::base::PropertySet::propertySetNames ( bool  topLevelOnly = true) const

Get the names of subproperties in the PropertySet, optionally including those in subproperties. Hierarchical subproperty names are separated by a period.

Parameters
[in]topLevelOnlytrue (default) = don't include subproperties.
Returns
Vector of subproperty names.

Definition at line 168 of file PropertySet.cc.

168  {
169  vector<string> v;
170  for (AnyMap::const_iterator i = _map.begin(); i != _map.end(); ++i) {
171  if (i->second->back().type() == typeid(Ptr)) {
172  v.push_back(i->first);
173  Ptr p = boost::any_cast<Ptr>(i->second->back());
174  if (p.get() != 0 && !topLevelOnly) {
175  vector<string> w = p->propertySetNames(false);
176  for (vector<string>::const_iterator k = w.begin();
177  k != w.end(); ++k) {
178  v.push_back(i->first + "." + *k);
179  }
180  }
181  }
182  }
183  return v;
184 }
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
double w
Definition: CoaddPsf.cc:57
void lsst::daf::base::PropertySet::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 in lsst::daf::base::PropertyList.

Definition at line 754 of file PropertySet.cc.

754  {
755  string::size_type i = name.find('.');
756  if (_flat || i == name.npos) {
757  _map.erase(name);
758  return;
759  }
760  string prefix(name, 0, i);
761  AnyMap::iterator j = _map.find(prefix);
762  if (j == _map.end() || j->second->back().type() != typeid(Ptr)) {
763  return;
764  }
765  Ptr p = boost::any_cast<Ptr>(j->second->back());
766  if (p.get() != 0) {
767  string suffix(name, i + 1);
768  p->remove(suffix);
769  }
770 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
template<typename T >
void lsst::daf::base::PropertySet::set ( std::string const &  name,
T const &  value 
)

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

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

Definition at line 581 of file PropertySet.cc.

581  {
582  boost::shared_ptr< vector<boost::any> > vp(new vector<boost::any>);
583  vp->push_back(value);
584  _set(name, vp);
585 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
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::PropertySet::set ( std::string const &  name,
std::vector< T > const &  value 
)

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

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

Definition at line 594 of file PropertySet.cc.

595  {
596  if (value.empty()) return;
597  boost::shared_ptr< vector<boost::any> > vp(new vector<boost::any>);
598  vp->insert(vp->end(), value.begin(), value.end());
599  _set(name, vp);
600 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
virtual void _set(std::string const &name, boost::shared_ptr< std::vector< boost::any > > vp)
Definition: PropertySet.cc:837
void lsst::daf::base::PropertySet::set ( std::string const &  name,
char const *  value 
)

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

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

Definition at line 607 of file PropertySet.cc.

607  {
608  set(name, string(value));
609 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
void set(std::string const &name, T const &value)
Definition: PropertySet.cc:581
std::string lsst::daf::base::PropertySet::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 in lsst::daf::base::PropertyList.

Definition at line 476 of file PropertySet.cc.

477  {
478  ostringstream s;
479  vector<string> nv = names();
480  sort(nv.begin(), nv.end());
481  for (vector<string>::const_iterator i = nv.begin(); i != nv.end(); ++i) {
482  boost::shared_ptr< vector<boost::any> > vp = _map.find(*i)->second;
483  type_info const& t = vp->back().type();
484  if (t == typeid(Ptr)) {
485  s << indent << *i << " = ";
486  if (topLevelOnly) {
487  s << "{ ... }";
488  } else {
489  Ptr p = boost::any_cast<Ptr>(vp->back());
490  if (p.get() == 0) {
491  s << "{ NULL }";
492  } else {
493  s << '{' << endl;
494  s << p->toString(false, indent + "..");
495  s << indent << '}';
496  }
497  }
498  s << endl;
499  }
500  else {
501  s << indent << _format(*i);
502  }
503  }
504  return s.str();
505 }
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
std::vector< std::string > names(bool topLevelOnly=true) const
Definition: PropertySet.cc:117
virtual std::string _format(std::string const &name) const
Definition: PropertySet.cc:507
type_info const & lsst::daf::base::PropertySet::typeOf ( std::string const &  name) const

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

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

Definition at line 227 of file PropertySet.cc.

227  {
228  AnyMap::const_iterator i = _find(name);
229  if (i == _map.end()) {
230  throw LSST_EXCEPT(pexExcept::NotFoundError, name + " not found");
231  }
232  return i->second->back().type();
233 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781
size_t lsst::daf::base::PropertySet::valueCount ( std::string const &  name) const

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

Definition at line 216 of file PropertySet.cc.

216  {
217  AnyMap::const_iterator i = _find(name);
218  if (i == _map.end()) return 0;
219  return i->second->size();
220 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
AnyMap::iterator _find(std::string const &name)
Definition: PropertySet.cc:781

Member Data Documentation

bool lsst::daf::base::PropertySet::_flat
private

Definition at line 179 of file PropertySet.h.

AnyMap lsst::daf::base::PropertySet::_map
private

Definition at line 178 of file PropertySet.h.


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