XdmfAttribute.hpp 9.39 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 : XdmfAttribute.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.                                                 */
/*                                                                           */
/*****************************************************************************/

Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
24 25 26
#ifndef XDMFATTRIBUTE_HPP_
#define XDMFATTRIBUTE_HPP_

27
// C Compatible Includes
28
#include "Xdmf.hpp"
29
#include "XdmfArray.hpp"
30 31 32 33 34
#include "XdmfAttributeCenter.hpp"
#include "XdmfAttributeType.hpp"
#include "XdmfTime.hpp"

#ifdef __cplusplus
35

36
/**
37
 * @brief Holds values located at specific parts of an XdmfGrid.
38
 *
39 40 41 42 43
 * XdmfAttribute holds values centered at specific locations of an
 * XdmfGrid. An attribute contains two properties that should be set,
 * XdmfAttributeCenter, which describes where the values are centered,
 * and XdmfAttributeType, which describes what types of values the
 * attribute contains.
44
 */
45
class XDMF_EXPORT XdmfAttribute : public XdmfArray {
Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
46

47
public:
48 49 50 51

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

  virtual ~XdmfAttribute();

72
  LOKI_DEFINE_VISITABLE(XdmfAttribute, XdmfArray)
73
  XDMF_CHILDREN(XdmfAttribute, XdmfArray, AuxiliaryArray, Name)
74 75
  static const std::string ItemTag;

76 77 78 79 80 81
  using XdmfArray::insert;

#if defined(SWIG)
  using XdmfItem::insert;
#endif

82 83 84
  /**
   * Get the XdmfAttributeCenter associated with this attribute.
   *
85 86 87 88
   * Example of use:
   *
   * C++
   *
89
   * @dontinclude ExampleXdmfAttribute.cpp
90 91 92 93 94 95
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#setCenter
   * @until //#setCenter
   * @skipline //#getCenter
   * @until //#getCenter
96 97 98
   *
   * Python
   *
99
   * @dontinclude XdmfExampleAttribute.py
100 101 102 103 104 105
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//setCenter
   * @until #//setCenter
   * @skipline #//getCenter
   * @until #//getCenter
106
   *
107
   * @return    XdmfAttributeCenter of the attribute.
108
   */
109
  shared_ptr<const XdmfAttributeCenter> getCenter() const;
110 111 112 113 114 115 116 117

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

  std::string getItemTag() const;

  /**
   * Get the name of the attribute.
   *
118 119 120 121
   * Example of use:
   *
   * C++
   *
122
   * @dontinclude ExampleXdmfAttribute.cpp
123 124 125 126 127 128
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#setName
   * @until //#setName
   * @skipline //#getName
   * @until //#getName
129 130 131
   *
   * Python
   *
132
   * @dontinclude XdmfExampleAttribute.py
133 134 135 136 137 138
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//setName
   * @until #//setName
   * @skipline #//getName
   * @until #//getName
139
   *
140
   * @return    A string containing the name of the attribute.
141 142 143 144 145 146
   */
  std::string getName() const;

  /**
   * Get the XdmfAttributeType associated with this attribute.
   *
147 148 149 150
   * Example of use:
   *
   * C++
   *
151
   * @dontinclude ExampleXdmfAttribute.cpp
152 153 154 155 156 157
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#setType
   * @until //#setType
   * @skipline //#getType
   * @until //#getType
158 159 160
   *
   * Python
   *
161
   * @dontinclude XdmfExampleAttribute.py
162 163 164 165 166 167
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//setType
   * @until #//setType
   * @skipline #//getType
   * @until #//getType
168
   *
169
   * @return    XdmfAttributeType of the attribute.
170
   */
171
  shared_ptr<const XdmfAttributeType> getType() const;
172

173 174 175 176 177 178 179
  /**
   * Get the ItemType associated with this attribute.
   *
   * @return    ItemType of the attribute.
   */
  std::string getItemType() const;

180
  /**
181 182 183 184 185 186
   * Get the ElementFamily associated with this attribute.
   *
   * @return    ElementFamily of the attribute.
   */
  std::string getElementFamily() const;

187
  /**
188 189 190 191 192 193
   * Get the ElementDegree associated with this attribute.
   *
   * @return    ElementDegree of the attribute.
   */
  unsigned int getElementDegree() const;

194 195 196 197 198
  /**
   * Get the ElementCell associated with this attribute.
   *
   * @return    ElementCell of the attribute.
   */
199 200
  std::string getElementCell() const;

201 202 203
  /**
   * Set the XdmfAttributeCenter associated with this attribute.
   *
204 205 206 207
   * Example of use:
   *
   * C++
   *
208
   * @dontinclude ExampleXdmfAttribute.cpp
209 210 211 212
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#setCenter
   * @until //#setCenter
213 214 215
   *
   * Python
   *
216
   * @dontinclude XdmfExampleAttribute.py
217 218 219 220
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//setCenter
   * @until #//setCenter
221
   *
222
   * @param     center  The XdmfAttributeCenter to set.
223
   */
224
  void setCenter(const shared_ptr<const XdmfAttributeCenter> center);
225 226 227 228

  /**
   * Set the name of the attribute.
   *
229 230 231 232
   * Example of use:
   *
   * C++
   *
233
   * @dontinclude ExampleXdmfAttribute.cpp
234 235 236 237
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#setName
   * @until //#setName
238 239 240
   *
   * Python
   *
241
   * @dontinclude XdmfExampleAttribute.py
242 243 244 245
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//setName
   * @until #//setName
246
   *
247
   * @param     name    A string containing the name to set.
248 249 250 251 252 253
   */
  void setName(const std::string & name);

  /**
   * Set the XdmfAttributeType associated with this attribute.
   *
254 255 256 257
   * Example of use:
   *
   * C++
   *
258
   * @dontinclude ExampleXdmfAttribute.cpp
259 260 261 262
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#setType
   * @until //#setType
263 264 265
   *
   * Python
   *
266
   * @dontinclude XdmfExampleAttribute.py
267 268 269 270
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//setType
   * @until #//setType
271
   *
272
   * @param     type    XdmfAttributeType to set.
273
   */
274
  void setType(const shared_ptr<const XdmfAttributeType> type);
275

276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
   /**
   * Set the ItemType associated with this attribute.
   *
   * @param     type    ItemType to set.
   */
  void setItemType(std::string type);

   /**
   * Set the ElementFamily associated with this attribute.
   *
   * @param     type    ElementFamily to set.
   */
  void setElementFamily(std::string type);

   /**
   * Set the ElementDegree associated with this attribute.
   *
   * @param     type    ElementDegree to set.
   */
  void setElementDegree(unsigned int degree);

297 298 299 300 301
   /**
   * Set the ElementCell associated with this attribute.
   *
   * @param     type    ElementCell to set.
   */
302 303
  void setElementCell(std::string cell);

304
  XdmfAttribute(XdmfAttribute &);
305

306 307
  void traverse(const shared_ptr<XdmfBaseVisitor> visitor);

308
protected:
309 310 311 312 313

  XdmfAttribute();

  virtual void
  populateItem(const std::map<std::string, std::string> & itemProperties,
314
               const std::vector<shared_ptr<XdmfItem> > & childItems,
315 316
               const XdmfCoreReader * const reader);

317
private:
318 319 320 321

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

322
  shared_ptr<const XdmfAttributeCenter> mCenter;
323
  std::string mName;
324
  shared_ptr<const XdmfAttributeType> mType;
325 326 327
  std::string mItemType;
  unsigned int mElementDegree;
  std::string mElementFamily;
328
  std::string mElementCell;
329

Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
330 331
};

332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
#endif

#ifdef __cplusplus
extern "C" {
#endif

// C wrappers go here

struct XDMFATTRIBUTE; // Simply as a typedef to ensure correct typing
typedef struct XDMFATTRIBUTE XDMFATTRIBUTE;

XDMF_EXPORT XDMFATTRIBUTE * XdmfAttributeNew();

XDMF_EXPORT int XdmfAttributeGetCenter(XDMFATTRIBUTE * attribute);

XDMF_EXPORT int XdmfAttributeGetType(XDMFATTRIBUTE * attribute);

XDMF_EXPORT void XdmfAttributeSetCenter(XDMFATTRIBUTE * attribute, int center, int * status);

XDMF_EXPORT void XdmfAttributeSetType(XDMFATTRIBUTE * attribute, int type, int * status);

XDMF_ITEM_C_CHILD_DECLARE(XdmfAttribute, XDMFATTRIBUTE, XDMF)
XDMF_ARRAY_C_CHILD_DECLARE(XdmfAttribute, XDMFATTRIBUTE, XDMF)

#ifdef __cplusplus
}
#endif

Ken Leiter (Civ's avatar
Ken Leiter (Civ committed
360
#endif /* XDMFATTRIBUTE_HPP_ */