XdmfCoreReader.hpp 6.76 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 : XdmfCoreReader.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 27 28 29 30 31
#ifndef XDMFCOREREADER_HPP_
#define XDMFCOREREADER_HPP_

// Forward Declarations
class XdmfCoreItemFactory;
class XdmfItem;

// Includes
32
#include <string>
33
#include <vector>
34 35
#include "XdmfCore.hpp"
#include "XdmfSharedPtr.hpp"
36 37

/**
38
 * @brief Reads an Xdmf file stored on disk into memory.
39
 *
40 41 42 43
 * Reads an Xdmf file stored on disk into an Xdmf structure in memory.
 * All light data is parsed in order to create appropriate Xdmf
 * objects.  Heavy data controllers are created and attached to
 * XdmfArrays but no heavy data is read into memory.
44 45
 *
 * XdmfCoreReader is an abstract base class.
46
 */
47
class XDMFCORE_EXPORT XdmfCoreReader {
48

49
public:
50 51 52

  virtual ~XdmfCoreReader() = 0;

53 54 55 56
  /**
   * Parse a string containing light data into an Xdmf structure in
   * memory.
   *
57 58 59 60
   * Example of use:
   *
   * C++
   *
61
   * @dontinclude ExampleXdmfCoreReader.cpp
62 63 64 65
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#parse
   * @until //#parse
66 67 68
   *
   * Python
   *
69
   * @dontinclude XdmfExampleCoreReader.py
70 71 72 73
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//parse
   * @until #//parse
74
   *
75 76
   * @param     lightData       A string containing light data description of an
   *                            Xdmf file.
77
   *
78
   * @return                    An XdmfItem at the root of the Xdmf tree.
79 80 81
   */  
  virtual shared_ptr<XdmfItem> parse(const std::string & lightData) const;

82 83 84
  /**
   * Read an Xdmf file from disk into memory.
   *
85 86 87 88
   * Example of use:
   *
   * C++
   *
89
   * @dontinclude ExampleXdmfCoreReader.cpp
90 91 92 93 94 95
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#readpath
   * @until //#readpath
   * @skipline //#readroot
   * @until //#readroot
96 97 98
   *
   * Python
   *
99
   * @dontinclude XdmfExampleCoreReader.py
100 101 102 103 104 105
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//readpath
   * @until #//readpath
   * @skipline #//readroot
   * @until #//readroot
106
   *
107
   * @param     filePath        The path of the Xdmf file to read in from disk.
108
   *
109
   * @return                    An XdmfItem at the root of the Xdmf tree.
110
   */
111
  virtual shared_ptr<XdmfItem> read(const std::string & filePath) const;
112 113 114 115

  /**
   * Read part of an Xdmf file from disk into memory.
   *
116 117 118 119
   * Example of use:
   *
   * C++
   *
120
   * @dontinclude ExampleXdmfCoreReader.cpp
121 122 123 124 125 126
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#readpath
   * @until //#readpath
   * @skipline //#readXPath
   * @until //#readXPath
127 128 129
   *
   * Python
   *
130
   * @dontinclude XdmfExampleCoreReader.py
131 132 133 134 135 136
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//readpath
   * @until #//readpath
   * @skipline #//readXPath
   * @until #//readXPath
137
   *
138 139 140
   * @param     filePath        The path of the Xdmf file to read in from disk.
   * @param     xPath           An XPath corresponding to the portion of the
   *                            file to read.
141
   *
142 143
   * @return                    A vector of XdmfItems that are included
   *                            in the XPath.
144
   */
145
  virtual std::vector<shared_ptr<XdmfItem> >
146 147 148 149 150 151
  read(const std::string & filePath,
       const std::string & xPath) const;

  /**
   * Read an Xdmf file from disk into memory.
   *
152 153 154 155
   * Example of use:
   *
   * C++
   *
156
   * @dontinclude ExampleXdmfCoreReader.cpp
157 158 159 160 161 162
   * @skipline //#initialization
   * @until //#initialization
   * @skipline //#readpath
   * @until //#readpath
   * @skipline //#readItems
   * @until //#readItems
163 164 165
   *
   * Python
   *
166
   * @dontinclude XdmfExampleCoreReader.py
167 168 169 170 171 172
   * @skipline #//initialization
   * @until #//initialization
   * @skipline #//readpath
   * @until #//readpath
   * @skipline #//readItems
   * @until #//readItems
173
   *
174
   * @param     filePath        The path of the Xdmf file to read in from disk.
175
   *
176
   * @return                    A vector of XdmfItems at the root of the Xdmf tree.
177
   */
178
  virtual std::vector<shared_ptr<XdmfItem> >
179 180
  readItems(const std::string & filePath) const;

181 182 183 184 185
  /**
   * Used by the other functions to read items from an open file.
   *
   * Since files are closed between reads, this does nothing by itself.
   *
186
   * @param     xPath   An XPath corresponding to the portion of the file to read.
187
   *
188
   * @return            A vector of items at the X path provided.
189
   */
190
  std::vector<shared_ptr<XdmfItem> >
191 192
  readPathObjects(const std::string & xPath) const;

193
protected:
194 195 196 197

  /**
   * Constructor
   *
198 199
   * @param itemFactory an XdmfCoreItemFactory to construct XdmfItems
   * for a specific language.
200
   */
201
  XdmfCoreReader(const shared_ptr<const XdmfCoreItemFactory> itemFactory);
202

203
private:
204 205 206 207 208 209 210 211 212 213

  /**
   * PIMPL
   */
  class XdmfCoreReaderImpl;

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

  XdmfCoreReaderImpl * const mImpl;
214

215 216
};

217
#ifdef _WIN32
218
XDMFCORE_TEMPLATE template class XDMFCORE_EXPORT
219
std::allocator<shared_ptr<XdmfItem> >;
220
XDMFCORE_TEMPLATE template class XDMFCORE_EXPORT
221 222
std::vector<shared_ptr<XdmfItem>,
            std::allocator<shared_ptr<XdmfItem> > >;
223 224
#endif

225
#endif /* XDMFCOREREADER_HPP_ */