25 #ifndef LSST_DAF_BASE_PROPERTYSET
26 #define LSST_DAF_BASE_PROPERTYSET
58 #include <unordered_map>
61 #include "boost/any.hpp"
70 namespace persistence {
71 class PropertySetFormatter;
78 #pragma warning (push)
79 #pragma warning (disable: 444)
85 typedef std::shared_ptr<PropertySet>
Ptr;
86 typedef std::shared_ptr<PropertySet const>
ConstPtr;
105 size_t nameCount(
bool topLevelOnly =
true)
const;
106 std::vector<std::string>
names(
bool topLevelOnly =
true)
const;
107 std::vector<std::string>
paramNames(
bool topLevelOnly =
true)
const;
115 std::type_info
const&
typeOf(std::string
const&
name)
const;
120 template <
typename T> T
get(std::string
const&
name)
const;
123 template <
typename T>
124 T
get(std::string
const&
name, T
const& defaultValue)
const;
126 template <
typename T>
139 virtual std::string
toString(
bool topLevelOnly =
false,
140 std::string
const& indent =
"")
const;
143 template <
typename T>
void set(std::string
const&
name, T
const& value);
144 template <
typename T>
void set(std::string
const&
name,
145 std::vector<T>
const& value);
146 void set(std::string
const&
name,
char const* value);
147 template <
typename T>
void add(std::string
const&
name, T
const& value);
148 template <
typename T>
void add(std::string
const&
name,
149 std::vector<T>
const& value);
150 void add(std::string
const&
name,
char const* value);
152 virtual void copy(std::string
const& dest,
ConstPtr source,
153 std::string
const&
name);
158 virtual void remove(std::string
const&
name);
161 virtual void _set(std::string
const&
name,
162 std::shared_ptr< std::vector<boost::any> > vp);
163 virtual void _add(std::string
const&
name,
164 std::shared_ptr< std::vector<boost::any> > vp);
165 virtual std::string
_format(std::string
const&
name)
const;
170 typedef std::unordered_map<std::
string,
173 AnyMap::iterator
_find(std::
string const&
name);
174 AnyMap::const_iterator
_find(std::
string const& name) const;
176 std::shared_ptr< std::vector<boost::
any> > vp);
179 std::
string const& name);
187 #pragma warning (pop)
190 template<>
void PropertySet::add<PropertySet::Ptr>(
191 std::string
const&
name,
Ptr const& value);
192 template<>
void PropertySet::add<PropertySet::Ptr>(
193 std::string
const&
name, std::vector<Ptr>
const& value);
void add(std::string const &name, T const &value)
Appends a single value to the vector of values for a property name (possibly hierarchical).
#define LSST_PERSIST_FORMATTER(formatter...)
Macro used to connect the persistable class with the Formatter and boost::serialization.
virtual std::string _format(std::string const &name) const
table::Key< std::string > name
virtual void copy(std::string const &dest, ConstPtr source, std::string const &name)
Replaces a single value vector in the destination with one from the source.
void set(std::string const &name, T const &value)
Replace all values for a property name (possibly hierarchical) with a new value.
virtual Ptr deepCopy(void) const
Copy the PropertySet and all of its contents.
Include files required for standard LSST Exception handling.
std::shared_ptr< Persistable > Ptr
AnyMap::iterator _find(std::string const &name)
Finds the property name (possibly hierarchical).
void _cycleCheckPtrVec(std::vector< Ptr > const &v, std::string const &name)
std::unordered_map< std::string, std::shared_ptr< std::vector< boost::any > > > AnyMap
virtual void _findOrInsert(std::string const &name, std::shared_ptr< std::vector< boost::any > > vp)
Finds the property name (possibly hierarchical) and sets or replaces its value with the given vector ...
void _cycleCheckPtr(Ptr const &v, std::string const &name)
virtual std::string toString(bool topLevelOnly=false, std::string const &indent="") const
Generate a string representation of the PropertySet.
size_t valueCount(std::string const &name) const
Get number 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).
bool exists(std::string const &name) const
Determine if a name (possibly hierarchical) exists.
virtual ~PropertySet(void)
Destructor.
PropertySet::Ptr getAsPropertySetPtr(std::string const &name) const
Get the last value for a subproperty name (possibly hierarchical).
bool any(CoordinateExpr< N > const &expr)
Return true if any elements are true.
std::vector< std::string > propertySetNames(bool topLevelOnly=true) const
Get the names of subproperties in the PropertySet, optionally including those in subproperties.
Interface for Persistable base class.
PropertySet(bool flat=false)
Constructor.
virtual void _add(std::string const &name, std::shared_ptr< std::vector< boost::any > > vp)
Finds the property name (possibly hierarchical) and appends or sets its value with the given vector o...
Persistable::Ptr getAsPersistablePtr(std::string const &name) const
Get the last value for a Persistable name (possibly hierarchical).
std::vector< std::string > paramNames(bool topLevelOnly=true) const
Get the names of parameters (non-subproperties) in the PropertySet, optionally including those in sub...
int getAsInt(std::string const &name) const
Get the last value for a bool/char/short/int property name (possibly hierarchical).
virtual void combine(ConstPtr source)
Appends all value vectors from the source to their corresponding properties.
bool isArray(std::string const &name) const
Determine if a name (possibly hierarchical) has multiple values.
std::type_info const & typeOf(std::string const &name) const
Get the type of values for a property name (possibly hierarchical).
std::shared_ptr< PropertySet const > ConstPtr
Class for storing generic metadata.
std::vector< std::string > names(bool topLevelOnly=true) const
Get the names in the PropertySet, optionally including those in subproperties.
Base class for all persistable classes.
Citizen is a class that should be among all LSST classes base classes, and handles basic memory manag...
std::shared_ptr< PropertySet > Ptr
size_t nameCount(bool topLevelOnly=true) const
Get the number of names in the PropertySet, optionally including those in subproperties.
PropertySet & operator=(const PropertySet &)=delete
int64_t getAsInt64(std::string const &name) const
Get the last value for a bool/char/short/int/int64_t property name (possibly hierarchical).
bool isPropertySetPtr(std::string const &name) const
Determine if a name (possibly hierarchical) is a subproperty.
std::string getAsString(std::string const &name) const
Get the last value for a string property name (possibly hierarchical).
void _cycleCheckAnyVec(std::vector< boost::any > const &v, std::string const &name)
std::vector< T > getArray(std::string const &name) const
bool getAsBool(std::string const &name) const
Get the last value for a bool property name (possibly hierarchical).
virtual void _set(std::string const &name, std::shared_ptr< std::vector< boost::any > > vp)
Finds the property name (possibly hierarchical) and sets or replaces its value with the given vector ...