Field3D
FieldMappingIO.h
Go to the documentation of this file.
1 //----------------------------------------------------------------------------//
2 
3 /*
4  * Copyright (c) 2009 Sony Pictures Imageworks Inc
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the
17  * distribution. Neither the name of Sony Pictures Imageworks nor the
18  * names of its contributors may be used to endorse or promote
19  * products derived from this software without specific prior written
20  * permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33  * OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 //----------------------------------------------------------------------------//
37 
44 //----------------------------------------------------------------------------//
45 
46 #ifndef _INCLUDED_Field3D_FieldMappingIO_H_
47 #define _INCLUDED_Field3D_FieldMappingIO_H_
48 
49 //----------------------------------------------------------------------------//
50 
51 #include <hdf5.h>
52 
53 #include "FieldMapping.h"
54 #include "OgawaFwd.h"
55 
56 //----------------------------------------------------------------------------//
57 
58 #include "ns.h"
59 
61 
62 //----------------------------------------------------------------------------//
63 
64 class FieldMappingIO : public RefBase
65 {
66 
67 public:
68 
69  // Typedefs ------------------------------------------------------------------
70 
71  typedef boost::intrusive_ptr<FieldMappingIO> Ptr;
72 
73  // RTTI replacement ----------------------------------------------------------
74 
77 
79  static const char *staticClassType()
80  {
81  return "FieldMappingIO";
82  }
83 
84  // Ctors, dtor ---------------------------------------------------------------
85 
88  : RefBase()
89  { }
90 
92  virtual ~FieldMappingIO()
93  { }
94 
95  // Methods to be implemented by subclasses -----------------------------------
96 
100  virtual FieldMapping::Ptr read(hid_t mappingGroup) = 0;
101 
105  virtual FieldMapping::Ptr read(const OgIGroup &mappingGroup) = 0;
106 
109  virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping) = 0;
110 
113  virtual bool write(OgOGroup &mappingGroup, FieldMapping::Ptr mapping) = 0;
114 
117  virtual std::string className() const = 0;
118 
119 private:
120 
121  // Typedefs ------------------------------------------------------------------
122 
124  typedef RefBase base;
125 };
126 
127 //----------------------------------------------------------------------------//
128 // NullFieldMappingIO
129 //----------------------------------------------------------------------------//
130 
136 //----------------------------------------------------------------------------//
137 
139 {
140 
141 public:
142 
143  // Typedefs ------------------------------------------------------------------
144 
145  typedef boost::intrusive_ptr<NullFieldMappingIO> Ptr;
146 
147  // RTTI replacement ----------------------------------------------------------
148 
151 
152  static const char *staticClassType()
153  {
154  return "NullFieldMappingIO";
155  }
156 
157  // Constructors --------------------------------------------------------------
158 
161  : FieldMappingIO()
162  { }
163 
165  { return Ptr(new NullFieldMappingIO); }
166 
167  // From FieldMappingIO -------------------------------------------------------
168 
172  virtual FieldMapping::Ptr read(hid_t mappingGroup);
173 
177  virtual FieldMapping::Ptr read(const OgIGroup &mappingGroup);
178 
181  virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping);
182 
185  virtual bool write(OgOGroup &mappingGroup, FieldMapping::Ptr mapping);
186 
188  virtual std::string className() const;
189 
190 private:
191 
192  // Typedefs ------------------------------------------------------------------
193 
196 
197 };
198 
199 //----------------------------------------------------------------------------//
200 // MatrixFieldMappingIO
201 //----------------------------------------------------------------------------//
202 
208 //----------------------------------------------------------------------------//
209 
211 {
212 
213 public:
214 
215  // Typedefs ------------------------------------------------------------------
216 
217  typedef boost::intrusive_ptr<MatrixFieldMappingIO> Ptr;
218 
219  // RTTI replacement ----------------------------------------------------------
220 
223 
224  static const char *staticClassType()
225  {
226  return "MatrixFieldMappingIO";
227  }
228 
229  // Constructors --------------------------------------------------------------
230 
233  : FieldMappingIO()
234  { }
235 
237  { return Ptr(new MatrixFieldMappingIO); }
238 
239  // From FieldMappingIO -------------------------------------------------------
240 
244  virtual FieldMapping::Ptr read(hid_t mappingGroup);
245 
249  virtual FieldMapping::Ptr read(const OgIGroup &mappingGroup);
250 
253  virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping);
254 
257  virtual bool write(OgOGroup &mappingGroup, FieldMapping::Ptr mapping);
258 
260  virtual std::string className() const;
261 
262 private:
263 
264  // Typedefs ------------------------------------------------------------------
265 
268 
269 };
270 
271 //----------------------------------------------------------------------------//
272 // FrustumFieldMappingIO
273 //----------------------------------------------------------------------------//
274 
280 //----------------------------------------------------------------------------//
281 
283 {
284 
285 public:
286 
287  // Typedefs ------------------------------------------------------------------
288 
289  typedef boost::intrusive_ptr<FrustumFieldMappingIO> Ptr;
290 
291  // RTTI replacement ----------------------------------------------------------
292 
295 
296  static const char *staticClassType()
297  {
298  return "FrustumFieldMappingIO";
299  }
300 
301  // Constructors --------------------------------------------------------------
302 
305  : FieldMappingIO()
306  { }
307 
309  { return Ptr(new FrustumFieldMappingIO); }
310 
311  // From FieldMappingIO -------------------------------------------------------
312 
316  virtual FieldMapping::Ptr read(hid_t mappingGroup);
317 
321  virtual FieldMapping::Ptr read(const OgIGroup &mappingGroup);
322 
325  virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping);
326 
329  virtual bool write(OgOGroup &mappingGroup, FieldMapping::Ptr mapping);
330 
332  virtual std::string className() const;
333 
334 private:
335 
336  // Typedefs ------------------------------------------------------------------
337 
340 
341 };
342 
343 //----------------------------------------------------------------------------//
344 
346 
347 //----------------------------------------------------------------------------//
348 
349 #endif // Include guard
FIELD3D_NAMESPACE_HEADER_CLOSE
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition: ns.h:58
FrustumFieldMappingIO::create
static FieldMappingIO::Ptr create()
Definition: FieldMappingIO.h:308
MatrixFieldMappingIO::DEFINE_FIELD_RTTI_CONCRETE_CLASS
DEFINE_FIELD_RTTI_CONCRETE_CLASS
Definition: FieldMappingIO.h:222
FieldMappingIO::className
virtual std::string className() const =0
Returns the class name. This is used when registering the class in the ClassFactory.
NullFieldMappingIO::create
static FieldMappingIO::Ptr create()
Definition: FieldMappingIO.h:164
FrustumFieldMappingIO::staticClassType
static const char * staticClassType()
Definition: FieldMappingIO.h:296
FrustumFieldMappingIO::className
virtual std::string className() const
Returns the class name.
Definition: FieldMappingIO.cpp:605
MatrixFieldMappingIO::MatrixFieldMappingIO
MatrixFieldMappingIO()
Ctor.
Definition: FieldMappingIO.h:232
FieldMappingIO::DEFINE_FIELD_RTTI_ABSTRACT_CLASS
DEFINE_FIELD_RTTI_ABSTRACT_CLASS
Definition: FieldMappingIO.h:76
FieldMappingIO::Ptr
boost::intrusive_ptr< FieldMappingIO > Ptr
Definition: FieldMappingIO.h:71
FrustumFieldMappingIO::write
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)
Writes the given field mapping to disk.
Definition: FieldMappingIO.cpp:491
FieldMappingIO::write
virtual bool write(OgOGroup &mappingGroup, FieldMapping::Ptr mapping)=0
Write the field to the given mapping group.
MatrixFieldMappingIO::className
virtual std::string className() const
Returns the class name.
Definition: FieldMappingIO.cpp:334
FrustumFieldMappingIO::FrustumFieldMappingIO
FrustumFieldMappingIO()
Ctor.
Definition: FieldMappingIO.h:304
FieldMapping::Ptr
boost::intrusive_ptr< FieldMapping > Ptr
Definition: FieldMapping.h:92
FieldMappingIO::write
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)=0
Write the field to the given mapping group.
NullFieldMappingIO::NullFieldMappingIO
NullFieldMappingIO()
Ctor.
Definition: FieldMappingIO.h:160
NullFieldMappingIO::DEFINE_FIELD_RTTI_CONCRETE_CLASS
DEFINE_FIELD_RTTI_CONCRETE_CLASS
Definition: FieldMappingIO.h:150
FieldMapping.h
Contains the FieldMapping base class and the NullFieldMapping and MatrixFieldMapping subclasses.
FieldMappingIO::read
virtual FieldMapping::Ptr read(hid_t mappingGroup)=0
Read the field at the given hdf5 group.
MatrixFieldMappingIO::Ptr
boost::intrusive_ptr< MatrixFieldMappingIO > Ptr
Definition: FieldMappingIO.h:217
NullFieldMappingIO::base
FieldMappingIO base
Convenience typedef for referring to base class.
Definition: FieldMappingIO.h:195
FieldMappingIO::staticClassType
static const char * staticClassType()
RTTI replacement.
Definition: FieldMappingIO.h:79
FrustumFieldMappingIO::Ptr
boost::intrusive_ptr< FrustumFieldMappingIO > Ptr
Definition: FieldMappingIO.h:289
FrustumFieldMappingIO::base
FieldMappingIO base
Convenience typedef for referring to base class.
Definition: FieldMappingIO.h:339
OgawaFwd.h
Contains forward declarations for Ogawa classes.
NullFieldMappingIO::staticClassType
static const char * staticClassType()
Definition: FieldMappingIO.h:152
FieldMappingIO::base
RefBase base
Convenience typedef for referring to base class.
Definition: FieldMappingIO.h:124
ns.h
FrustumFieldMappingIO
Definition: FieldMappingIO.h:283
NullFieldMappingIO::className
virtual std::string className() const
Returns the class name.
Definition: FieldMappingIO.cpp:138
FrustumFieldMappingIO::DEFINE_FIELD_RTTI_CONCRETE_CLASS
DEFINE_FIELD_RTTI_CONCRETE_CLASS
Definition: FieldMappingIO.h:294
MatrixFieldMappingIO::create
static FieldMappingIO::Ptr create()
Definition: FieldMappingIO.h:236
NullFieldMappingIO::read
virtual FieldMapping::Ptr read(hid_t mappingGroup)
Reads the field mapping and tries to create a NullFieldMapping object from it.
Definition: FieldMappingIO.cpp:88
FrustumFieldMappingIO::read
virtual FieldMapping::Ptr read(hid_t mappingGroup)
Reads the field mapping and tries to create a FrustumFieldMapping object from it.
Definition: FieldMappingIO.cpp:344
MatrixFieldMappingIO::read
virtual FieldMapping::Ptr read(hid_t mappingGroup)
Reads the field mapping and tries to create a MatrixFieldMapping object from it.
Definition: FieldMappingIO.cpp:148
FieldMappingIO::FieldMappingIO
FieldMappingIO()
Ctor.
Definition: FieldMappingIO.h:87
NullFieldMappingIO
Definition: FieldMappingIO.h:139
MatrixFieldMappingIO
Definition: FieldMappingIO.h:211
FrustumFieldMappingIO::class_type
FrustumFieldMappingIO class_type
Definition: FieldMappingIO.h:293
MatrixFieldMappingIO::class_type
MatrixFieldMappingIO class_type
Definition: FieldMappingIO.h:221
FieldMappingIO
Definition: FieldMappingIO.h:65
FieldMappingIO::class_type
FieldMappingIO class_type
Definition: FieldMappingIO.h:75
NullFieldMappingIO::class_type
NullFieldMappingIO class_type
Definition: FieldMappingIO.h:149
MatrixFieldMappingIO::staticClassType
static const char * staticClassType()
Definition: FieldMappingIO.h:224
FIELD3D_NAMESPACE_OPEN
Definition: FieldMapping.cpp:74
MatrixFieldMappingIO::base
FieldMappingIO base
Convenience typedef for referring to base class.
Definition: FieldMappingIO.h:267
NullFieldMappingIO::write
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)
Writes the given field mapping to disk.
Definition: FieldMappingIO.cpp:116
FieldMappingIO::~FieldMappingIO
virtual ~FieldMappingIO()
Dtor.
Definition: FieldMappingIO.h:92
RefBase
Definition: RefCount.h:107
MatrixFieldMappingIO::write
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)
Writes the given field mapping to disk.
Definition: FieldMappingIO.cpp:250
FieldMappingIO::read
virtual FieldMapping::Ptr read(const OgIGroup &mappingGroup)=0
Read the field at the given hdf5 group.
NullFieldMappingIO::Ptr
boost::intrusive_ptr< NullFieldMappingIO > Ptr
Definition: FieldMappingIO.h:145