Field3D
FieldIO.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 
42 //----------------------------------------------------------------------------//
43 
44 #ifndef _INCLUDED_Field3D_FieldIO_H_
45 #define _INCLUDED_Field3D_FieldIO_H_
46 
47 //----------------------------------------------------------------------------//
48 
49 #include <boost/intrusive_ptr.hpp>
50 
51 #include <string>
52 #include <map>
53 #include <list>
54 
55 #include <hdf5.h>
56 #include <typeinfo>
57 
58 #include "Field.h"
59 #include "OgawaFwd.h"
60 #include "Log.h"
61 
62 //----------------------------------------------------------------------------//
63 
64 #include "ns.h"
65 
67 
68 //----------------------------------------------------------------------------//
69 // FieldIO
70 //----------------------------------------------------------------------------//
71 
82 //----------------------------------------------------------------------------//
83 
84 class FieldIO : public RefBase
85 {
86 
87 public:
88 
89  // Typedefs ------------------------------------------------------------------
90 
91  typedef boost::intrusive_ptr<FieldIO> Ptr;
92 
93  // RTTI replacement ----------------------------------------------------------
94 
97 
98  static const char * staticClassType()
99  {
100  return "FieldIO";
101  }
102 
103  // Ctors, dtor ---------------------------------------------------------------
104 
107  : RefBase()
108  { }
109 
111  virtual ~FieldIO() {}
112 
113  // Methods to be implemented by subclasses -----------------------------------
114 
118  virtual FieldBase::Ptr read(hid_t layerGroup, const std::string &filename,
119  const std::string &layerPath,
120  DataTypeEnum typeEnum) = 0;
121 
125  virtual FieldBase::Ptr read(const OgIGroup &layerGroup,
126  const std::string &filename,
127  const std::string &layerPath,
128  OgDataType typeEnum) = 0;
129 
132  virtual bool write(hid_t layerGroup, FieldBase::Ptr field) = 0;
133 
136  virtual bool write(OgOGroup &layerGroup, FieldBase::Ptr field) = 0;
137 
140  virtual std::string className() const = 0;
141 
142  // Strings used when reading/writing -----------------------------------------
143 
144 private:
145 
146  // Typedefs ------------------------------------------------------------------
147 
149  typedef RefBase base;
150 
151 };
152 
153 //----------------------------------------------------------------------------//
154 
156 
157 //----------------------------------------------------------------------------//
158 
159 #endif
Contains Field, WritableField and ResizableField classes.
Contains the Log class which can be used to redirect output to an arbitrary destination.
Contains forward declarations for Ogawa classes.
OgDataType
Enumerates the various uses for Ogawa-level groups.
Definition: Traits.h:125
DataTypeEnum
Definition: Traits.h:108
boost::intrusive_ptr< FieldBase > Ptr
Definition: Field.h:97
virtual bool write(hid_t layerGroup, FieldBase::Ptr field)=0
Write the field to the given layer group.
boost::intrusive_ptr< FieldIO > Ptr
Definition: FieldIO.h:91
virtual bool write(OgOGroup &layerGroup, FieldBase::Ptr field)=0
Write the field to the given layer group.
FieldIO class_type
Definition: FieldIO.h:95
virtual FieldBase::Ptr read(hid_t layerGroup, const std::string &filename, const std::string &layerPath, DataTypeEnum typeEnum)=0
Read the field at the given hdf5 group.
virtual FieldBase::Ptr read(const OgIGroup &layerGroup, const std::string &filename, const std::string &layerPath, OgDataType typeEnum)=0
Read the field at the given Ogawa group.
FieldIO()
Ctor.
Definition: FieldIO.h:106
DEFINE_FIELD_RTTI_ABSTRACT_CLASS
Definition: FieldIO.h:96
virtual ~FieldIO()
Dtor.
Definition: FieldIO.h:111
virtual std::string className() const =0
Returns the class name. This is used when registering the class to the FieldIOFactory object.
RefBase base
Convenience typedef for referring to base class.
Definition: FieldIO.h:149
static const char * staticClassType()
Definition: FieldIO.h:98
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition: ns.h:58