lsst.daf.base  16.0-4-g50d071e+1
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 persistence
64 
65 namespace base {
66 
67 #if defined(__ICC)
68 #pragma warning(push)
69 #pragma warning(disable : 444)
70 #endif
71 
72 class PropertyList : public PropertySet {
73 public:
74  // Typedefs
77 
79  PropertyList(void);
81  virtual ~PropertyList(void);
82 
83  // Accessors
84 
90  virtual PropertySet::Ptr deepCopy(void) const;
91 
92  // I can't make copydoc work for this so...
104  template <typename T>
105  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, std::string const& indent = "") const;
147 
148  // Modifiers
149 
151  template <typename T>
152  void set(std::string const& name, T const& value);
153 
162  void set(std::string const& name, PropertySet::Ptr const& value);
163 
165  template <typename T>
166  void set(std::string const& name, std::vector<T> const& value);
167 
169  void set(std::string const& name, char const* value);
170 
172  template <typename T>
173  void add(std::string const& name, T const& value);
174 
176  template <typename T>
177  void add(std::string const& name, std::vector<T> const& value);
178 
180  void add(std::string const& name, char const* value);
181 
190  template <typename T>
191  void set(std::string const& name, T const& value, std::string const& comment);
192 
201  template <typename T>
202  void set(std::string const& name, std::vector<T> const& value, std::string const& comment);
203 
212  void set(std::string const& name, char const* value, std::string const& comment);
213 
222  template <typename T>
223  void add(std::string const& name, T const& value, std::string const& comment);
224 
233  template <typename T>
234  void add(std::string const& name, std::vector<T> const& value, std::string const& comment);
235 
244  void add(std::string const& name, char const* value, std::string const& comment);
245 
247  template <typename T>
248  void set(std::string const& name, T const& value, char const* comment) {
249  set(name, value, std::string(comment));
250  }
251 
253  template <typename T>
254  void set(std::string const& name, std::vector<T> const& value, char const* comment) {
255  set(name, value, std::string(comment));
256  }
257 
259  void set(std::string const& name, char const* value, char const* comment) {
260  set(name, value, std::string(comment));
261  }
262 
264  template <typename T>
265  void add(std::string const& name, T const& value, char const* comment) {
266  add(name, value, std::string(comment));
267  }
269  template <typename T>
270  void add(std::string const& name, std::vector<T> const& value, char const* comment) {
271  add(name, value, std::string(comment));
272  }
273 
275  void add(std::string const& name, char const* value, char const* comment) {
276  add(name, value, std::string(comment));
277  }
278 
280  virtual void copy(std::string const& dest, PropertySet::ConstPtr source, std::string const& name,
281  bool asScalar = false);
282 
284  virtual void combine(PropertySet::ConstPtr source);
285 
287  virtual void remove(std::string const& name);
288 
289 private:
290  LSST_PERSIST_FORMATTER(lsst::daf::persistence::PropertyListFormatter)
291 
293 
294  virtual void _set(std::string const& name, std::shared_ptr<std::vector<boost::any> > vp);
295  virtual void _moveToEnd(std::string const& name);
296  virtual void _commentOrderFix(std::string const& name, std::string const& comment);
297 
298  CommentMap _comments;
299  std::list<std::string> _order;
300 };
301 
302 #if defined(__ICC)
303 #pragma warning(pop)
304 #endif
305 }
306 } // namespace daf
307 } // namespace lsst
308 
309 #endif
Class for storing ordered metadata with comments.
Definition: PropertyList.h:72
STL class.
std::shared_ptr< PropertyList const > ConstPtr
Definition: PropertyList.h:76
std::shared_ptr< PropertyList > Ptr
Definition: PropertyList.h:75
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:270
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:275
Class for storing generic metadata.
Definition: PropertySet.h:72
#define LSST_PERSIST_FORMATTER(formatter...)
Macro used to connect the persistable class with the Formatter and boost::serialization.
Definition: Persistable.h:97
void add(std::string const &name, T const &value, char const *comment)
Version of add scalar value that accepts a comment.
Definition: PropertyList.h:265