25#ifndef LSST_DAF_BASE_PROPERTYSET
26#define LSST_DAF_BASE_PROPERTYSET
49#include <unordered_map>
64#pragma warning(disable : 444)
191 template <typename T>
207 template <typename T>
222 template <typename T>
223 T
get(
std::
string const& name, T const& defaultValue) const;
236 template <typename T>
341 virtual
std::
string toString(
bool topLevelOnly = false,
std::
string const& indent =
"") const;
359 template <typename T>
360 void set(
std::
string const& name, T const& value);
370 template <typename T>
371 void set(
std::
string const& name,
std::vector<T> const& value);
380 void set(
std::
string const& name,
char const* value);
397 template <typename T>
398 void add(
std::
string const& name, T const& value);
411 template <typename T>
412 void add(
std::
string const& name,
std::vector<T> const& value);
424 void add(
std::
string const& name,
char const* value);
441 bool asScalar = false);
496 typedef
std::unordered_map<
std::
string,
std::shared_ptr<
std::vector<
std::any> > > AnyMap;
504 AnyMap::iterator _find(
std::
string const& name);
512 AnyMap::const_iterator _find(
std::
string const& name) const;
523 void _cycleCheckPtrVec(
std::vector<
std::shared_ptr<
PropertySet>> const& v,
std::
string const& name);
524 void _cycleCheckAnyVec(
std::vector<
std::any> const& v,
std::
string const& name);
525 void _cycleCheckPtr(
std::shared_ptr<
PropertySet> const & v,
std::
string const& name);
#define LSST_EXPORT
Make a symbol visible even if visiblity is hidden (e.g.
Base class for all persistable classes.
Class for storing generic metadata.
std::string getAsString(std::string const &name) const
Get the last value for a string property name (possibly hierarchical).
virtual void _set(std::string const &name, std::shared_ptr< std::vector< std::any > > vp)
size_t nameCount(bool topLevelOnly=true) const
Get the number of names in the PropertySet, optionally including those in subproperties.
int getAsInt(std::string const &name) const
Get the last value for a bool/char/short/int property name (possibly hierarchical).
virtual void remove(std::string const &name)
Remove all values for a property name (possibly hierarchical).
std::shared_ptr< PropertySet > Ptr
bool isArray(std::string const &name) const
Determine if a name (possibly hierarchical) has multiple values.
int64_t getAsInt64(std::string const &name) const
Get the last value for a bool/char/short/int/int64_t property name (possibly hierarchical).
virtual std::string _format(std::string const &name) const
bool isUndefined(std::string const &name) const
Determine if a name (possibly hierarchical) has a defined value.
virtual void _findOrInsert(std::string const &name, std::shared_ptr< std::vector< std::any > > vp)
bool exists(std::string const &name) const
Determine if a name (possibly hierarchical) exists.
std::vector< std::string > names(bool topLevelOnly=true) const
Get the names in the PropertySet, optionally including those in subproperties.
void set(std::string const &name, T const &value)
Replace all values for a property name (possibly hierarchical) with a new scalar value.
std::vector< T > getArray(std::string const &name) const
Get the vector of values for a property name (possibly hierarchical).
std::shared_ptr< PropertySet const > ConstPtr
size_t valueCount() const
Get the number of values in the entire PropertySet, counting each element of a vector.
bool isPropertySetPtr(std::string const &name) const
Determine if a name (possibly hierarchical) is a subproperty.
PropertySet(bool flat=false)
Construct an empty PropertySet.
virtual void copy(std::string const &dest, PropertySet const &source, std::string const &name, bool asScalar=false)
Replace a single value vector in the destination with one from the source.
virtual void combine(PropertySet const &source)
Append all value vectors from the source to their corresponding properties.
std::shared_ptr< PropertySet > getAsPropertySetPtr(std::string const &name) const
Get the last value for a subproperty name (possibly hierarchical).
std::type_info const & typeOf(std::string const &name) const
Get the type of values for a property name (possibly hierarchical).
double getAsDouble(std::string const &name) const
Get the last value for any arithmetic property name (possibly hierarchical).
static std::type_info const & typeOfT()
Get type info for the specified class.
virtual ~PropertySet() noexcept
Destructor.
Persistable::Ptr getAsPersistablePtr(std::string const &name) const
Get the last value for a Persistable name (possibly hierarchical).
T get(std::string const &name) const
Get the last value for a property name (possibly hierarchical).
virtual void _add(std::string const &name, std::shared_ptr< std::vector< std::any > > vp)
uint64_t getAsUInt64(std::string const &name) const
Get the last value for an bool/char/short/int/int64_t property name (possibly hierarchical).
void add(std::string const &name, T const &value)
Append a single value to the vector of values for a property name (possibly hierarchical).
virtual std::shared_ptr< PropertySet > deepCopy() const
Make a deep copy of the PropertySet and all of its contents.
std::vector< std::string > propertySetNames(bool topLevelOnly=true) const
A variant of names that only returns the names of subproperties.
virtual std::string toString(bool topLevelOnly=false, std::string const &indent="") const
Generate a string representation of the PropertySet.
std::vector< std::string > paramNames(bool topLevelOnly=true) const
A variant of names that excludes the names of subproperties.
bool getAsBool(std::string const &name) const
Get the last value for a bool property name (possibly hierarchical).
Interface for Persistable base class.