FieldMappingIO.h
Go to the documentation of this file.
//----------------------------------------------------------------------------//
/*
* Copyright (c) 2009 Sony Pictures Imageworks Inc
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution. Neither the name of Sony Pictures Imageworks nor the
* names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
#ifndef _INCLUDED_Field3D_FieldMappingIO_H_
#define _INCLUDED_Field3D_FieldMappingIO_H_
//----------------------------------------------------------------------------//
#include <hdf5.h>
#include "FieldMapping.h"
#include "OgawaFwd.h"
//----------------------------------------------------------------------------//
#include "ns.h"
FIELD3D_NAMESPACE_OPEN
//----------------------------------------------------------------------------//
class FieldMappingIO : public RefBase
{
public:
// Typedefs ------------------------------------------------------------------
typedef boost::intrusive_ptr<FieldMappingIO> Ptr;
// RTTI replacement ----------------------------------------------------------
typedef FieldMappingIO class_type;
DEFINE_FIELD_RTTI_ABSTRACT_CLASS;
static const char *staticClassType()
{
return "FieldMappingIO";
}
// Ctors, dtor ---------------------------------------------------------------
FieldMappingIO()
: RefBase()
{ }
virtual ~FieldMappingIO()
{ }
// Methods to be implemented by subclasses -----------------------------------
virtual FieldMapping::Ptr read(hid_t mappingGroup) = 0;
virtual FieldMapping::Ptr read(const OgIGroup &mappingGroup) = 0;
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping) = 0;
virtual bool write(OgOGroup &mappingGroup, FieldMapping::Ptr mapping) = 0;
virtual std::string className() const = 0;
private:
// Typedefs ------------------------------------------------------------------
typedef RefBase base;
};
//----------------------------------------------------------------------------//
// NullFieldMappingIO
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
class NullFieldMappingIO : public FieldMappingIO
{
public:
// Typedefs ------------------------------------------------------------------
typedef boost::intrusive_ptr<NullFieldMappingIO> Ptr;
// RTTI replacement ----------------------------------------------------------
typedef NullFieldMappingIO class_type;
DEFINE_FIELD_RTTI_CONCRETE_CLASS;
static const char *staticClassType()
{
return "NullFieldMappingIO";
}
// Constructors --------------------------------------------------------------
NullFieldMappingIO()
: FieldMappingIO()
{ }
static FieldMappingIO::Ptr create()
{ return Ptr(new NullFieldMappingIO); }
// From FieldMappingIO -------------------------------------------------------
virtual FieldMapping::Ptr read(hid_t mappingGroup);
virtual FieldMapping::Ptr read(const OgIGroup &mappingGroup);
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping);
virtual bool write(OgOGroup &mappingGroup, FieldMapping::Ptr mapping);
virtual std::string className() const;
private:
// Typedefs ------------------------------------------------------------------
typedef FieldMappingIO base;
};
//----------------------------------------------------------------------------//
// MatrixFieldMappingIO
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
class MatrixFieldMappingIO : public FieldMappingIO
{
public:
// Typedefs ------------------------------------------------------------------
typedef boost::intrusive_ptr<MatrixFieldMappingIO> Ptr;
// RTTI replacement ----------------------------------------------------------
typedef MatrixFieldMappingIO class_type;
DEFINE_FIELD_RTTI_CONCRETE_CLASS;
static const char *staticClassType()
{
return "MatrixFieldMappingIO";
}
// Constructors --------------------------------------------------------------
MatrixFieldMappingIO()
: FieldMappingIO()
{ }
static FieldMappingIO::Ptr create()
{ return Ptr(new MatrixFieldMappingIO); }
// From FieldMappingIO -------------------------------------------------------
virtual FieldMapping::Ptr read(hid_t mappingGroup);
virtual FieldMapping::Ptr read(const OgIGroup &mappingGroup);
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping);
virtual bool write(OgOGroup &mappingGroup, FieldMapping::Ptr mapping);
virtual std::string className() const;
private:
// Typedefs ------------------------------------------------------------------
typedef FieldMappingIO base;
};
//----------------------------------------------------------------------------//
// FrustumFieldMappingIO
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
class FrustumFieldMappingIO : public FieldMappingIO
{
public:
// Typedefs ------------------------------------------------------------------
typedef boost::intrusive_ptr<FrustumFieldMappingIO> Ptr;
// RTTI replacement ----------------------------------------------------------
typedef FrustumFieldMappingIO class_type;
DEFINE_FIELD_RTTI_CONCRETE_CLASS;
static const char *staticClassType()
{
return "FrustumFieldMappingIO";
}
// Constructors --------------------------------------------------------------
FrustumFieldMappingIO()
: FieldMappingIO()
{ }
static FieldMappingIO::Ptr create()
{ return Ptr(new FrustumFieldMappingIO); }
// From FieldMappingIO -------------------------------------------------------
virtual FieldMapping::Ptr read(hid_t mappingGroup);
virtual FieldMapping::Ptr read(const OgIGroup &mappingGroup);
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping);
virtual bool write(OgOGroup &mappingGroup, FieldMapping::Ptr mapping);
virtual std::string className() const;
private:
// Typedefs ------------------------------------------------------------------
typedef FieldMappingIO base;
};
//----------------------------------------------------------------------------//
FIELD3D_NAMESPACE_HEADER_CLOSE
//----------------------------------------------------------------------------//
#endif // Include guard
FieldMapping.h
Contains the FieldMapping base class and the NullFieldMapping and MatrixFieldMapping subclasses.
OgawaFwd.h
Contains forward declarations for Ogawa classes.
FieldMappingIO::read
virtual FieldMapping::Ptr read(hid_t mappingGroup)=0
Read the field at the given hdf5 group.
FieldMappingIO::write
virtual bool write(OgOGroup &mappingGroup, FieldMapping::Ptr mapping)=0
Write the field to the given mapping group.
FieldMappingIO::FieldMappingIO
FieldMappingIO()
Ctor.
Definition FieldMappingIO.h:87
FieldMappingIO::read
virtual FieldMapping::Ptr read(const OgIGroup &mappingGroup)=0
Read the field at the given hdf5 group.
FieldMappingIO::Ptr
boost::intrusive_ptr< FieldMappingIO > Ptr
Definition FieldMappingIO.h:71
FieldMappingIO::DEFINE_FIELD_RTTI_ABSTRACT_CLASS
DEFINE_FIELD_RTTI_ABSTRACT_CLASS
Definition FieldMappingIO.h:76
FieldMappingIO::~FieldMappingIO
virtual ~FieldMappingIO()
Dtor.
Definition FieldMappingIO.h:92
FieldMappingIO::staticClassType
static const char * staticClassType()
RTTI replacement.
Definition FieldMappingIO.h:79
FieldMappingIO::write
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)=0
Write the field to the given mapping group.
FieldMappingIO::className
virtual std::string className() const =0
Returns the class name. This is used when registering the class in the ClassFactory.
FieldMappingIO::class_type
FieldMappingIO class_type
Definition FieldMappingIO.h:75
FieldMappingIO::base
RefBase base
Convenience typedef for referring to base class.
Definition FieldMappingIO.h:124
FieldMapping::Ptr
boost::intrusive_ptr< FieldMapping > Ptr
Definition FieldMapping.h:92
FrustumFieldMappingIO::DEFINE_FIELD_RTTI_CONCRETE_CLASS
DEFINE_FIELD_RTTI_CONCRETE_CLASS
Definition FieldMappingIO.h:294
FrustumFieldMappingIO::write
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)
Writes the given field mapping to disk.
Definition FieldMappingIO.cpp:491
FrustumFieldMappingIO::className
virtual std::string className() const
Returns the class name.
Definition FieldMappingIO.cpp:605
FrustumFieldMappingIO::class_type
FrustumFieldMappingIO class_type
Definition FieldMappingIO.h:293
FrustumFieldMappingIO::FrustumFieldMappingIO
FrustumFieldMappingIO()
Ctor.
Definition FieldMappingIO.h:304
FrustumFieldMappingIO::Ptr
boost::intrusive_ptr< FrustumFieldMappingIO > Ptr
Definition FieldMappingIO.h:289
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
FrustumFieldMappingIO::create
static FieldMappingIO::Ptr create()
Definition FieldMappingIO.h:308
FrustumFieldMappingIO::staticClassType
static const char * staticClassType()
Definition FieldMappingIO.h:296
FrustumFieldMappingIO::base
FieldMappingIO base
Convenience typedef for referring to base class.
Definition FieldMappingIO.h:339
MatrixFieldMappingIO::class_type
MatrixFieldMappingIO class_type
Definition FieldMappingIO.h:221
MatrixFieldMappingIO::DEFINE_FIELD_RTTI_CONCRETE_CLASS
DEFINE_FIELD_RTTI_CONCRETE_CLASS
Definition FieldMappingIO.h:222
MatrixFieldMappingIO::write
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)
Writes the given field mapping to disk.
Definition FieldMappingIO.cpp:250
MatrixFieldMappingIO::className
virtual std::string className() const
Returns the class name.
Definition FieldMappingIO.cpp:334
MatrixFieldMappingIO::staticClassType
static const char * staticClassType()
Definition FieldMappingIO.h:224
MatrixFieldMappingIO::create
static FieldMappingIO::Ptr create()
Definition FieldMappingIO.h:236
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
MatrixFieldMappingIO::MatrixFieldMappingIO
MatrixFieldMappingIO()
Ctor.
Definition FieldMappingIO.h:232
MatrixFieldMappingIO::Ptr
boost::intrusive_ptr< MatrixFieldMappingIO > Ptr
Definition FieldMappingIO.h:217
MatrixFieldMappingIO::base
FieldMappingIO base
Convenience typedef for referring to base class.
Definition FieldMappingIO.h:267
NullFieldMappingIO::create
static FieldMappingIO::Ptr create()
Definition FieldMappingIO.h:164
NullFieldMappingIO::Ptr
boost::intrusive_ptr< NullFieldMappingIO > Ptr
Definition FieldMappingIO.h:145
NullFieldMappingIO::class_type
NullFieldMappingIO class_type
Definition FieldMappingIO.h:149
NullFieldMappingIO::write
virtual bool write(hid_t mappingGroup, FieldMapping::Ptr mapping)
Writes the given field mapping to disk.
Definition FieldMappingIO.cpp:116
NullFieldMappingIO::base
FieldMappingIO base
Convenience typedef for referring to base class.
Definition FieldMappingIO.h:195
NullFieldMappingIO::staticClassType
static const char * staticClassType()
Definition FieldMappingIO.h:152
NullFieldMappingIO::className
virtual std::string className() const
Returns the class name.
Definition FieldMappingIO.cpp:138
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
NullFieldMappingIO::NullFieldMappingIO
NullFieldMappingIO()
Ctor.
Definition FieldMappingIO.h:160
NullFieldMappingIO::DEFINE_FIELD_RTTI_CONCRETE_CLASS
DEFINE_FIELD_RTTI_CONCRETE_CLASS
Definition FieldMappingIO.h:150
RefBase::RefBase
RefBase()
Definition RefCount.h:120
FIELD3D_NAMESPACE_OPEN
Definition FieldMapping.cpp:74
ns.h
FIELD3D_NAMESPACE_HEADER_CLOSE
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition ns.h:58