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
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition: ns.h:58
boost::intrusive_ptr< FieldMappingIO > Ptr
static const char * staticClassType()
MatrixFieldMappingIO class_type
Contains forward declarations for Ogawa classes.
virtual FieldMapping::Ptr read(hid_t mappingGroup)=0
Read the field at the given hdf5 group.
virtual FieldMapping::Ptr read(hid_t mappingGroup)
Reads the field mapping and tries to create a NullFieldMapping object from it.
static const char * staticClassType()
virtual std::string className() const
Returns the class name.
virtual std::string className() const
Returns the class name.
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)
Writes the given field mapping to disk.
FieldMappingIO base
Convenience typedef for referring to base class.
boost::intrusive_ptr< NullFieldMappingIO > Ptr
RefBase base
Convenience typedef for referring to base class.
boost::intrusive_ptr< FieldMapping > Ptr
Definition: FieldMapping.h:92
FieldMappingIO class_type
virtual ~FieldMappingIO()
Dtor.
static const char * staticClassType()
RTTI replacement.
virtual std::string className() const =0
Returns the class name. This is used when registering the class in the ClassFactory.
Contains the FieldMapping base class and the NullFieldMapping and MatrixFieldMapping subclasses...
boost::intrusive_ptr< FrustumFieldMappingIO > Ptr
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)
Writes the given field mapping to disk.
FieldMappingIO base
Convenience typedef for referring to base class.
NullFieldMappingIO class_type
FieldMappingIO base
Convenience typedef for referring to base class.
static FieldMappingIO::Ptr create()
static const char * staticClassType()
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)
Writes the given field mapping to disk.
boost::intrusive_ptr< MatrixFieldMappingIO > Ptr
FieldMappingIO()
Ctor.
virtual std::string className() const
Returns the class name.
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)=0
Write the field to the given mapping group.
virtual FieldMapping::Ptr read(hid_t mappingGroup)
Reads the field mapping and tries to create a FrustumFieldMapping object from it. ...
static FieldMappingIO::Ptr create()
virtual FieldMapping::Ptr read(hid_t mappingGroup)
Reads the field mapping and tries to create a MatrixFieldMapping object from it.
static FieldMappingIO::Ptr create()
FrustumFieldMappingIO class_type