XdmfSet.hpp 6.77 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 : XdmfSet.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 XDMFSET_HPP_
#define XDMFSET_HPP_

27 28 29 30 31 32 33 34
// C Compatible Includes
#include "Xdmf.hpp"
#include "XdmfArray.hpp"
#include "XdmfAttribute.hpp"
#include "XdmfSetType.hpp"

#ifdef __cplusplus

35
// Forward Declarations
36
class XdmfAttribute;
37
class XdmfHDF5Controller;
38 39

/**
40 41
 * @brief Holds a collection of individual nodes, cells, faces, or
 * edges that are part of an XdmfGrid.
42
 *
43 44 45 46 47 48
 * An XdmfSet holds a collection of nodes, cells, faces, or edges that
 * are part of an XdmfGrid. For instance, a simulation may want to
 * hold a set of nodes on a boundary. The individual elements making
 * up the set are determined by their id. An XdmfSet can have
 * XdmfAttributes attached that contain extra values attached to the
 * elements in the set.
49
 */
50
class XDMF_EXPORT XdmfSet : public XdmfArray {
51

52
public:
53

54 55 56
  /**
   * Create a new XdmfSet.
   *
57 58 59 60
   * Example of use:
   *
   * C++
   *
61
   * @dontinclude ExampleXdmfSet.cpp
62 63
   * @skipline //#initialize
   * @until //#initialize
64 65 66
   *
   * Python
   *
67
   * @dontinclude XdmfExampleSet.py
68 69
   * @skipline #//initialize
   * @until #//initialize
70
   *
71
   * @return    Constructed XdmfSet.
72
   */
73
  static shared_ptr<XdmfSet> New();
74

75
  virtual ~XdmfSet();
76

77 78
  LOKI_DEFINE_VISITABLE(XdmfSet, XdmfArray)
  XDMF_CHILDREN(XdmfSet, XdmfAttribute, Attribute, Name)
79
  static const std::string ItemTag;
80

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

83
  std::string getItemTag() const;
84

85 86 87
  /**
   * Get the name of the set.
   *
88 89 90 91
   * Example of use:
   *
   * C++
   *
92
   * @dontinclude ExampleXdmfSet.cpp
93 94 95 96 97 98
   * @skipline //#initialize
   * @until //#initialize
   * @skipline //#setName
   * @until //#setName
   * @skipline //#getName
   * @until //#getName
99 100 101
   *
   * Python
   *
102
   * @dontinclude XdmfExampleSet.py
103 104 105 106 107 108
   * @skipline #//initialize
   * @until #//initialize
   * @skipline #//setName
   * @until #//setName
   * @skipline #//getName
   * @until #//getName
109
   *
110
   * @return    A string containing the name of the set.
111 112
   */
  std::string getName() const;
113

114 115 116
  /**
   * Get the XdmfSetType associated with this set.
   *
117 118 119 120
   * Example of use:
   *
   * C++
   *
121
   * @dontinclude ExampleXdmfSet.cpp
122 123 124 125 126 127
   * @skipline //#initialize
   * @until //#initialize
   * @skipline //#setType
   * @until //#setType
   * @skipline //#getType
   * @until //#getType
128 129 130
   *
   * Python
   *
131
   * @dontinclude XdmfExampleSet.py
132 133 134 135 136 137
   * @skipline #//initialize
   * @until #//initialize
   * @skipline #//setType
   * @until #//setType
   * @skipline #//getType
   * @until #//getType
138
   *
139
   * @return    XdmfSetType of this set.
140
   */
141
  shared_ptr<const XdmfSetType> getType() const;
142

143
  using XdmfArray::insert;
144 145 146 147
  
#if defined(SWIG)
  using XdmfItem::insert;
#endif
148

149 150 151
  /**
   * Set the name of the set.
   *
152 153 154 155
   * Example of use:
   *
   * C++
   *
156
   * @dontinclude ExampleXdmfSet.cpp
157 158 159 160
   * @skipline //#initialize
   * @until //#initialize
   * @skipline //#setName
   * @until //#setName
161 162 163
   *
   * Python
   *
164
   * @dontinclude XdmfExampleSet.py
165 166 167 168
   * @skipline #//initialize
   * @until #//initialize
   * @skipline #//setName
   * @until #//setName
169
   *
170
   * @param     name    A string containing the name to set.
171 172
   */
  void setName(const std::string & name);
173

174 175 176
  /**
   * Set the XdmfSetType associated with this set.
   *
177 178 179 180
   * Example of use:
   *
   * C++
   *
181
   * @dontinclude ExampleXdmfSet.cpp
182 183 184 185
   * @skipline //#initialize
   * @until //#initialize
   * @skipline //#setType
   * @until //#setType
186 187 188
   *
   * Python
   *
189
   * @dontinclude XdmfExampleSet.py
190 191 192 193
   * @skipline //#initialize
   * @until //#initialize
   * @skipline //#setType
   * @until //#setType
194
   *
195
   * @param     type    The XdmfSetType to set.
196
   */
197
  void setType(const shared_ptr<const XdmfSetType> type);
198

199
  void traverse(const shared_ptr<XdmfBaseVisitor> visitor);
200

201 202
  XdmfSet(XdmfSet &);

203
protected:
204

205
  XdmfSet();
206

207 208
  virtual void
  populateItem(const std::map<std::string, std::string> & itemProperties,
209
               const std::vector<shared_ptr<XdmfItem> > & childItems,
210
               const XdmfCoreReader * const reader);
211

212
private:
213

214
  XdmfSet(const XdmfSet &);
215 216 217
  void operator=(const XdmfSet &);  // Not implemented.

  std::string mName;
218
  shared_ptr<const XdmfSetType> mType;
219 220
};

221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
#endif

#ifdef __cplusplus
extern "C" {
#endif

// C wrappers go here

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

XDMF_EXPORT XDMFSET * XdmfSetNew();

XDMF_EXPORT XDMFATTRIBUTE * XdmfSetGetAttribute(XDMFSET * set, unsigned int index);

XDMF_EXPORT XDMFATTRIBUTE * XdmfSetGetAttributeByName(XDMFSET * set, char * Name);

XDMF_EXPORT unsigned int XdmfSetGetNumberAttributes(XDMFSET * set);

XDMF_EXPORT int XdmfSetGetType(XDMFSET * set);

XDMF_EXPORT void XdmfSetInsertAttribute(XDMFSET * set, XDMFATTRIBUTE * Attribute, int passControl);

XDMF_EXPORT void XdmfSetRemoveAttribute(XDMFSET * set, unsigned int index);

XDMF_EXPORT void XdmfSetRemoveAttributeByName(XDMFSET * set, char * Name);

XDMF_EXPORT void XdmfSetSetType(XDMFSET * set, int type, int * status);

XDMF_ITEM_C_CHILD_DECLARE(XdmfSet, XDMFSET, XDMF)
XDMF_ARRAY_C_CHILD_DECLARE(XdmfSet, XDMFSET, XDMF)

#ifdef __cplusplus
}
#endif

257
#endif /* XDMFSET_HPP_ */