lsst.daf.base  14.0-5-g744ff5f+4
PropertyList.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
25 #ifndef LSST_DAF_BASE_PROPERTYLIST
26 #define LSST_DAF_BASE_PROPERTYLIST
27 
47 #include <list>
48 #include <memory>
49 #include <string>
50 #include <typeinfo>
51 #include <unordered_map>
52 #include <vector>
53 
54 #include "boost/any.hpp"
55 
57 
58 namespace lsst {
59 namespace daf {
60 
61 namespace persistence {
62  class PropertyListFormatter;
63 } // namespace lsst::daf::persistence
64 
65 
66 namespace base {
67 
68 #if defined(__ICC)
69 #pragma warning (push)
70 #pragma warning (disable: 444)
71 #endif
72 
73 class PropertyList : public PropertySet {
74 public:
75 // Typedefs
78 
80  PropertyList(void);
82  virtual ~PropertyList(void);
83 
84 // Accessors
85 
91  virtual PropertySet::Ptr deepCopy(void) const;
92 
93  // I can't make copydoc work for this so...
105  template <typename T> T get(std::string const& name) const;
106 
107  // I can't make copydoc work for this so...
120  template <typename T>
121  T get(std::string const& name, T const& defaultValue) const;
122 
124  template <typename T>
125  std::vector<T> getArray(std::string const& name) const;
126 
134  std::string const& getComment(std::string const& name) const;
135 
137  std::vector<std::string> getOrderedNames(void) const;
138 
140  std::list<std::string>::const_iterator begin(void) const;
141 
144 
146  virtual std::string toString(bool topLevelOnly = false,
147  std::string const& indent = "") const;
148 
149 // Modifiers
150 
152  template <typename T> void set(
153  std::string const& name, T const& value);
154 
163  void set(
164  std::string const& name, PropertySet::Ptr const& value);
165 
167  template <typename T> void set(
168  std::string const& name, std::vector<T> const& value);
169 
171  void set(
172  std::string const& name, char const* value);
173 
175  template <typename T> void add(
176  std::string const& name, T const& value);
177 
179  template <typename T> void add(
180  std::string const& name, std::vector<T> const& value);
181 
183  void add(
184  std::string const& name, char const* value);
185 
194  template <typename T> void set(
195  std::string const& name, T const& value,
196  std::string const& comment);
197 
206  template <typename T> void set(
207  std::string const& name, std::vector<T> const& value,
208  std::string const& comment);
209 
218  void set(
219  std::string const& name, char const* value,
220  std::string const& comment);
221 
230  template <typename T> void add(
231  std::string const& name, T const& value,
232  std::string const& comment);
233 
242  template <typename T> void add(
243  std::string const& name, std::vector<T> const& value,
244  std::string const& comment);
245 
254  void add(
255  std::string const& name, char const* value,
256  std::string const& comment);
257 
259  template <typename T> void set(
260  std::string const& name, T const& value,
261  char const* comment) {
262  set(name, value, std::string(comment));
263  }
264 
266  template <typename T> void set(
267  std::string const& name, std::vector<T> const& value,
268  char const* comment) {
269  set(name, value, std::string(comment));
270  }
271 
273  void set(
274  std::string const& name, char const* value,
275  char const* comment) {
276  set(name, value, std::string(comment));
277  }
278 
280  template <typename T> void add(
281  std::string const& name, T const& value,
282  char const* comment) {
283  add(name, value, std::string(comment));
284  }
286  template <typename T> void add(
287  std::string const& name, std::vector<T> const& value,
288  char const* comment) {
289  add(name, value, std::string(comment));
290  }
291 
293  void add(
294  std::string const& name, char const* value,
295  char const* comment) {
296  add(name, value, std::string(comment));
297  }
298 
300  virtual void copy(std::string const& dest, PropertySet::ConstPtr source,
301  std::string const& name, bool asScalar = false);
302 
304  virtual void combine(PropertySet::ConstPtr source);
305 
307  virtual void remove(std::string const& name);
308 
309 private:
310  LSST_PERSIST_FORMATTER(lsst::daf::persistence::PropertyListFormatter)
311 
313 
314  virtual void _set(std::string const& name,
316  virtual void _moveToEnd(std::string const& name);
317  virtual void _commentOrderFix(
318  std::string const& name, std::string const& comment);
319 
320  CommentMap _comments;
321  std::list<std::string> _order;
322 };
323 
324 #if defined(__ICC)
325 #pragma warning (pop)
326 #endif
327 
328 }}} // namespace lsst::daf::base
329 
330 #endif
Class for storing ordered metadata with comments.
Definition: PropertyList.h:73
STL class.
std::shared_ptr< PropertyList const > ConstPtr
Definition: PropertyList.h:77
std::shared_ptr< PropertyList > Ptr
Definition: PropertyList.h:76
void add(std::string const &name, std::vector< T > const &value, char const *comment)
Version of add vector value that accepts a comment.
Definition: PropertyList.h:286
STL class.
STL class.
void add(std::string const &name, char const *value, char const *comment)
Version of add char* value that accepts a comment.
Definition: PropertyList.h:293
Class for storing generic metadata.
Definition: PropertySet.h:73
#define LSST_PERSIST_FORMATTER(formatter...)
Macro used to connect the persistable class with the Formatter and boost::serialization.
Definition: Persistable.h:98
void add(std::string const &name, T const &value, char const *comment)
Version of add scalar value that accepts a comment.
Definition: PropertyList.h:280