25 #ifndef LSST_DAF_BASE_PROPERTYLIST
26 #define LSST_DAF_BASE_PROPERTYLIST
60 #include <unordered_map>
63 #include "boost/any.hpp"
70 namespace persistence {
71 class PropertyListFormatter;
78 #pragma warning (push)
79 #pragma warning (disable: 444)
85 typedef std::shared_ptr<PropertyList>
Ptr;
86 typedef std::shared_ptr<PropertyList const>
ConstPtr;
97 template <
typename T> T
get(std::string
const& name)
const;
100 template <
typename T>
101 T
get(std::string
const& name, T
const& defaultValue)
const;
103 template <
typename T>
104 std::vector<T>
getArray(std::string
const& name)
const;
106 std::string
const&
getComment(std::string
const& name)
const;
109 std::list<std::string>::const_iterator
begin(
void)
const;
110 std::list<std::string>::const_iterator
end(
void)
const;
113 virtual std::string
toString(
bool topLevelOnly =
false,
114 std::string
const& indent =
"")
const;
117 template <
typename T>
void set(
118 std::string
const& name, T
const& value);
121 template <
typename T>
void set(
122 std::string
const& name, std::vector<T>
const& value);
124 std::string
const& name,
char const* value);
125 template <
typename T>
void add(
126 std::string
const& name, T
const& value);
127 template <
typename T>
void add(
128 std::string
const& name, std::vector<T>
const& value);
130 std::string
const& name,
char const* value);
132 template <
typename T>
void set(
133 std::string
const& name, T
const& value,
134 std::string
const& comment);
135 template <
typename T>
void set(
136 std::string
const& name, std::vector<T>
const& value,
137 std::string
const& comment);
139 std::string
const& name,
char const* value,
140 std::string
const& comment);
141 template <
typename T>
void add(
142 std::string
const& name, T
const& value,
143 std::string
const& comment);
144 template <
typename T>
void add(
145 std::string
const& name, std::vector<T>
const& value,
146 std::string
const& comment);
148 std::string
const& name,
char const* value,
149 std::string
const& comment);
151 template <
typename T>
void set(
152 std::string
const& name, T
const& value,
153 char const* comment) {
154 set(name, value, std::string(comment));
156 template <
typename T>
void set(
157 std::string
const& name, std::vector<T>
const& value,
158 char const* comment) {
159 set(name, value, std::string(comment));
162 std::string
const& name,
char const* value,
163 char const* comment) {
164 set(name, value, std::string(comment));
166 template <
typename T>
void add(
167 std::string
const& name, T
const& value,
168 char const* comment) {
169 add(name, value, std::string(comment));
171 template <
typename T>
void add(
172 std::string
const& name, std::vector<T>
const& value,
173 char const* comment) {
174 add(name, value, std::string(comment));
177 std::string
const& name,
char const* value,
178 char const* comment) {
179 add(name, value, std::string(comment));
183 std::string
const& name);
186 virtual void remove(std::string
const& name);
191 typedef std::unordered_map<std::
string, std::
string> CommentMap;
193 virtual
void _set(std::
string const& name,
194 std::shared_ptr< std::vector<boost::any> > vp);
195 virtual
void _moveToEnd(std::
string const& name);
196 virtual
void _commentOrderFix(
197 std::
string const& name, std::
string const& comment);
199 CommentMap _comments;
200 std::list<std::
string> _order;
204 #pragma warning (pop)
std::shared_ptr< PropertySet > Ptr
void set(std::string const &name, T const &value, char const *comment)
std::string const & getComment(std::string const &name) const
Get the comment for a string property name (possibly hierarchical).
std::vector< T > getArray(std::string const &name) const
Class for storing ordered metadata with comments.
virtual void combine(PropertySet::ConstPtr source)
Appends all value vectors from the source to their corresponding properties.
void set(std::string const &name, T const &value)
Replace all values for a property name (possibly hierarchical) with a new value.
virtual void copy(std::string const &dest, PropertySet::ConstPtr source, std::string const &name)
Replaces a single value vector in the destination with one from the source.
std::shared_ptr< PropertySet const > ConstPtr
std::list< std::string >::const_iterator begin(void) const
PropertyList(void)
Constructor.
std::shared_ptr< PropertyList const > ConstPtr
std::shared_ptr< PropertyList > Ptr
void add(std::string const &name, std::vector< T > const &value, char const *comment)
void add(std::string const &name, T const &value)
Appends a single value to the vector of values for a property name (possibly hierarchical).
virtual ~PropertyList(void)
Destructor.
std::vector< std::string > getOrderedNames(void) const
std::list< std::string >::const_iterator end(void) const
virtual std::string toString(bool topLevelOnly=false, std::string const &indent="") const
Generate a string representation of the PropertyList.
void set(std::string const &name, std::vector< T > const &value, char const *comment)
void add(std::string const &name, char const *value, char const *comment)
Class for storing generic metadata.
void set(std::string const &name, char const *value, char const *comment)
#define LSST_PERSIST_FORMATTER(formatter...)
Macro used to connect the persistable class with the Formatter and boost::serialization.
Interface for PropertySet class.
virtual PropertySet::Ptr deepCopy(void) const
Copy the PropertyList and all of its contents.
void add(std::string const &name, T const &value, char const *comment)