XdmfInformation.hpp 6.58 KB
Newer Older
Kenneth Leiter's avatar
Kenneth Leiter committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*****************************************************************************/
/*                                    XDMF                                   */
/*                       eXtensible Data Model and Format                    */
/*                                                                           */
/*  Id : XdmfInformation.hpp                                                 */
/*                                                                           */
/*  Author:                                                                  */
/*     Kenneth Leiter                                                        */
/*     kenneth.leiter@arl.army.mil                                           */
/*     US Army Research Laboratory                                           */
/*     Aberdeen Proving Ground, MD                                           */
/*                                                                           */
/*     Copyright @ 2011 US Army Research Laboratory                          */
/*     All Rights Reserved                                                   */
/*     See Copyright.txt for details                                         */
/*                                                                           */
/*     This software is distributed WITHOUT ANY WARRANTY; without            */
/*     even the implied warranty of MERCHANTABILITY or FITNESS               */
/*     FOR A PARTICULAR PURPOSE.  See the above copyright notice             */
/*     for more information.                                                 */
/*                                                                           */
/*****************************************************************************/

24 25 26
#ifndef XDMFINFORMATION_HPP_
#define XDMFINFORMATION_HPP_

27 28 29
// Forward declarations
class XdmfArray;

30
// Includes
31
#include "XdmfCore.hpp"
32 33 34
#include "XdmfItem.hpp"

/**
35 36
 * @brief Holds a key/value pair that can be attached to an Xdmf
 * structure.
37
 *
38 39 40
 * XdmfInformation stores two strings as a key value pair. These can
 * be used to store input parameters to a code or for simple result
 * data like wall time.
41
 */
42
class XDMFCORE_EXPORT XdmfInformation : public XdmfItem {
43

44
public:
45 46 47 48

  /**
   * Create a new XdmfInformation.
   *
49 50 51 52
   * Example of use:
   *
   * C++
   *
53
   * @dontinclude ExampleXdmfInformation.cpp
54 55
   * @skipline //#initialization
   * @until //#initialization
56 57 58
   *
   * Python
   *
59
   * @dontinclude XdmfExampleInformation.py
60 61
   * @skipline #//initialization
   * @until #//initialization
62
   *
63
   * @return    Constructed XdmfInformation.
64
   */
65
  static shared_ptr<XdmfInformation> New();
66 67 68 69

  /**
   * Create a new XdmfInformation.
   *
70 71 72 73
   * Example of use:
   *
   * C++
   *
74
   * @dontinclude ExampleXdmfInformation.cpp
75 76
   * @skipline //#initializationfull
   * @until //#initializationfull
77 78 79
   *
   * Python
   *
80
   * @dontinclude XdmfExampleInformation.py
81 82
   * @skipline #//initializationfull
   * @until #//initializationfull
83
   *
84 85
   * @param     key     A string containing the key of the XdmfInformation to create.
   * @param     value   A string containing the value of the XdmfInformation to
86 87
   * create.
   *
88
   * @return    Constructed XdmfInformation
89
   */
90 91
  static shared_ptr<XdmfInformation> New(const std::string & key,
                                         const std::string & value);
92 93 94 95

  virtual ~XdmfInformation();

  LOKI_DEFINE_VISITABLE(XdmfInformation, XdmfItem);
96
  XDMF_CHILDREN(XdmfInformation, XdmfArray, Array, Name);
97 98 99 100 101 102 103 104 105
  static const std::string ItemTag;

  std::map<std::string, std::string> getItemProperties() const;

  virtual std::string getItemTag() const;

  /**
   * Get the key for this information item.
   *
106 107 108 109
   * Example of use:
   *
   * C++
   *
110
   * @dontinclude ExampleXdmfInformation.cpp
111 112 113 114
   * @skipline //#initializationfull
   * @until //#initializationfull
   * @skipline //#getKey
   * @until //#getKey
115 116 117
   *
   * Python
   *
118
   * @dontinclude XdmfExampleInformation.py
119 120 121 122
   * @skipline #//initializationfull
   * @until #//initializationfull
   * @skipline #//getKey
   * @until #//getKey
123
   *
124
   * @return    A string containing the key.
125 126 127 128 129 130
   */
  std::string getKey() const;

  /**
   * Get the value for this information item.
   *
131 132 133 134
   * Example of use:
   *
   * C++
   *
135
   * @dontinclude ExampleXdmfInformation.cpp
136 137 138 139
   * @skipline //#initializationfull
   * @until //#initializationfull
   * @skipline //#getValue
   * @until //#getValue
140 141 142
   *
   * Python
   *
143
   * @dontinclude XdmfExampleInformation.py
144 145 146 147
   * @skipline #//initializationfull
   * @until #//initializationfull
   * @skipline #//getValue
   * @until #//getValue
148
   *
149
   * @return    A string containing the value.
150 151 152
   */
  std::string getValue() const;

153 154
  using XdmfItem::insert;

155 156 157
  /**
   * Set the key for this information item.
   *
158 159 160 161
   * Example of use:
   *
   * C++
   *
162
   * @dontinclude ExampleXdmfInformation.cpp
163 164 165 166
   * @skipline //#initializationfull
   * @until //#initializationfull
   * @skipline //#setKey
   * @until //#setKey
167 168 169
   *
   * Python
   *
170
   * @dontinclude XdmfExampleInformation.py
171 172 173 174
   * @skipline #//initializationfull
   * @until #//initializationfull
   * @skipline #//setKey
   * @until #//setKey
175
   *
176
   * @param     key     A string containing the key to set.
177 178 179 180 181 182
   */
  void setKey(const std::string & key);

  /**
   * Set the value for this information item.
   *
183 184 185 186
   * Example of use:
   *
   * C++
   *
187
   * @dontinclude ExampleXdmfInformation.cpp
188 189 190 191
   * @skipline //#initializationfull
   * @until //#initializationfull
   * @skipline //#setValue
   * @until //#setValue
192 193 194
   *
   * Python
   *
195
   * @dontinclude XdmfExampleInformation.py
196 197 198 199
   * @skipline #//initializationfull
   * @until #//initializationfull
   * @skipline #//setValue
   * @until #//setValue
200
   *
201
   * @param     value   A string containing the value to set.
202 203 204
   */
  void setValue(const std::string & value);

205 206
  virtual void traverse(const shared_ptr<XdmfBaseVisitor> visitor);

207
protected:
208 209 210 211 212 213

  XdmfInformation(const std::string & key = "",
                  const std::string & value = "");

  virtual void
  populateItem(const std::map<std::string, std::string> & itemProperties,
214
               const std::vector<shared_ptr<XdmfItem> > & childItems,
215 216
               const XdmfCoreReader * const reader);

217
private:
218 219 220 221 222 223

  XdmfInformation(const XdmfInformation &);  // Not implemented.
  void operator=(const XdmfInformation &);  // Not implemented.

  std::string mKey;
  std::string mValue;
224 225
};

226
#ifdef _WIN32
227
XDMFCORE_TEMPLATE template class XDMFCORE_EXPORT
228
shared_ptr<Loki::BaseVisitor>;
229
XDMFCORE_TEMPLATE template class XDMFCORE_EXPORT
230 231
Loki::Visitor<shared_ptr<XdmfInformation>,
              shared_ptr<XdmfItem> >;
232 233
#endif

234
#endif /* XDMFINFORMATION_HPP_ */