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 
55 //----------------------------------------------------------------------------//
56 
57 #include "ns.h"
58 
60 
61 //----------------------------------------------------------------------------//
62 
63 class FieldMappingIO : public RefBase
64 {
65 
66 public:
67 
68  // Typedefs ------------------------------------------------------------------
69 
70  typedef boost::intrusive_ptr<FieldMappingIO> Ptr;
71 
72  // RTTI replacement ----------------------------------------------------------
73 
76 
78  static const char *staticClassType()
79  {
80  return "FieldMappingIO";
81  }
82 
83  // Ctors, dtor ---------------------------------------------------------------
84 
87  : RefBase()
88  { }
89 
91  virtual ~FieldMappingIO()
92  { }
93 
94  // Methods to be implemented by subclasses -----------------------------------
95 
99  virtual FieldMapping::Ptr read(hid_t mappingGroup) = 0;
100 
103  virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping) = 0;
104 
107  virtual std::string className() const = 0;
108 
109 private:
110 
111  // Typedefs ------------------------------------------------------------------
112 
114  typedef RefBase base;
115 };
116 
117 //----------------------------------------------------------------------------//
118 // NullFieldMappingIO
119 //----------------------------------------------------------------------------//
120 
126 //----------------------------------------------------------------------------//
127 
129 {
130 
131 public:
132 
133  // Typedefs ------------------------------------------------------------------
134 
135  typedef boost::intrusive_ptr<NullFieldMappingIO> Ptr;
136 
137  // RTTI replacement ----------------------------------------------------------
138 
141 
142  static const char *staticClassType()
143  {
144  return "NullFieldMappingIO";
145  }
146 
147  // Constructors --------------------------------------------------------------
148 
151  : FieldMappingIO()
152  { }
153 
155  { return Ptr(new NullFieldMappingIO); }
156 
157  // From FieldMappingIO -------------------------------------------------------
158 
162  virtual FieldMapping::Ptr read(hid_t mappingGroup);
163 
166  virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping);
167 
169  virtual std::string className() const;
170 
171 private:
172 
173  // Typedefs ------------------------------------------------------------------
174 
177 
178 };
179 
180 //----------------------------------------------------------------------------//
181 // MatrixFieldMappingIO
182 //----------------------------------------------------------------------------//
183 
189 //----------------------------------------------------------------------------//
190 
192 {
193 
194 public:
195 
196  // Typedefs ------------------------------------------------------------------
197 
198  typedef boost::intrusive_ptr<MatrixFieldMappingIO> Ptr;
199 
200  // RTTI replacement ----------------------------------------------------------
201 
204 
205  static const char *staticClassType()
206  {
207  return "MatrixFieldMappingIO";
208  }
209 
210  // Constructors --------------------------------------------------------------
211 
214  : FieldMappingIO()
215  { }
216 
218  { return Ptr(new MatrixFieldMappingIO); }
219 
220  // From FieldMappingIO -------------------------------------------------------
221 
225  virtual FieldMapping::Ptr read(hid_t mappingGroup);
226 
229  virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping);
230 
232  virtual std::string className() const;
233 
234 private:
235 
236  // Typedefs ------------------------------------------------------------------
237 
240 
241 };
242 
243 //----------------------------------------------------------------------------//
244 // FrustumFieldMappingIO
245 //----------------------------------------------------------------------------//
246 
252 //----------------------------------------------------------------------------//
253 
255 {
256 
257 public:
258 
259  // Typedefs ------------------------------------------------------------------
260 
261  typedef boost::intrusive_ptr<FrustumFieldMappingIO> Ptr;
262 
263  // RTTI replacement ----------------------------------------------------------
264 
267 
268  static const char *staticClassType()
269  {
270  return "FrustumFieldMappingIO";
271  }
272 
273  // Constructors --------------------------------------------------------------
274 
277  : FieldMappingIO()
278  { }
279 
281  { return Ptr(new FrustumFieldMappingIO); }
282 
283  // From FieldMappingIO -------------------------------------------------------
284 
288  virtual FieldMapping::Ptr read(hid_t mappingGroup);
289 
292  virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping);
293 
295  virtual std::string className() const;
296 
297 private:
298 
299  // Typedefs ------------------------------------------------------------------
300 
303 
304 };
305 
306 //----------------------------------------------------------------------------//
307 
309 
310 //----------------------------------------------------------------------------//
311 
312 #endif // Include guard
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition: ns.h:58
boost::intrusive_ptr< FieldMappingIO > Ptr
static const char * staticClassType()
MatrixFieldMappingIO class_type
virtual FieldMapping::Ptr read(hid_t mappingGroup)=0
Read the field at the given hdf5 group.
static const char * staticClassType()
FieldMappingIO base
Convenience typedef for referring to base class.
boost::intrusive_ptr< NullFieldMappingIO > Ptr
virtual std::string className() const =0
Returns the class name. This is used when registering the class in the ClassFactory.
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.
Contains the FieldMapping base class and the NullFieldMapping and MatrixFieldMapping subclasses...
boost::intrusive_ptr< FrustumFieldMappingIO > Ptr
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()
boost::intrusive_ptr< MatrixFieldMappingIO > Ptr
FieldMappingIO()
Ctor.
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)=0
Write the field to the given mapping group.
static FieldMappingIO::Ptr create()
static FieldMappingIO::Ptr create()
FrustumFieldMappingIO class_type