Field3DFileHDF5.h File Reference
Fields

Contains the Field3DFileHDF5 classes. More...

`#include <list>`
`#include <string>`
`#include <vector>`
`#include <hdf5.h>`
`#include <boost/intrusive_ptr.hpp>`
`#include "EmptyField.h"`
`#include "Field.h"`
`#include "FieldCache.h"`
`#include "FieldMetadata.h"`
`#include "ClassFactory.h"`
`#include "Hdf5Util.h"`
`#include "ns.h"`

Go to the source code of this file.

## Classes

class | Field3DFileHDF5Base
struct | Field3DFileHDF5Base::LayerInfo
class | Field3DInputFileHDF5
| Provides reading of .f3d (internally, hdf5) files. More...
class | Field3DOutputFileHDF5
| Provides writing of .f3d (internally, hdf5) files. More...
class | FileHDF5::Layer
class | FileHDF5::Partition
struct | InputFileHDF5::ParseLayersInfo
| struct used to pass the class and partition info back to the parseLayers() callback More...

## Namespaces

namespace | FileHDF5
| Namespace for file I/O specifics.
namespace | InputFileHDF5
| Namespace for file input specifics.

## Functions

FIELD3D_API herr_t | InputFileHDF5::parseLayers (hid_t loc_id, const char *partitionName, const H5L_info_t *linfo, void *opdata)
| Gets called from readPartitionAndLayerInfo to check each group found under the root of the file. It checks to see if it can find a "partition" and then passes that to writePartition.
FIELD3D_API herr_t | InputFileHDF5::parsePartitions (hid_t loc_id, const char *partitionName, const H5L_info_t *linfo, void *opdata)
| Gets called from readPartitionAndLayerInfo to check each group found under the root of the file. It checks to see if it can find a "partition" and then passes that to writePartition.
classFactory IO functions
template<class Data_T>
Field< Data_T >::Ptr | readField (const std::string &className, hid_t layerGroup, const std::string &filename, const std::string &layerPath)
| This function creates a FieldIO instance based on className which then reads the field data from layerGroup location.
FIELD3D_API FieldMapping::Ptr | readFieldMapping (hid_t mappingGroup)
| This function creates a FieldMappingIO instance based on className read from mappingGroup location which then reads FieldMapping data.
FIELD3D_API bool | writeField (hid_t layerGroup, FieldBase::Ptr field)
| This function creates a FieldIO instance based on field->className() which then writes the field data in layerGroup location.
FIELD3D_API bool | writeFieldMapping (hid_t mappingGroup, FieldMapping::Ptr mapping)
| This function creates a FieldMappingIO instance based on mapping->className() which then writes FieldMapping data to mappingGroup location.

## Detailed Description

Contains the Field3DFileHDF5 classes.

OSS sanitized

Definition in file Field3DFileHDF5.h.

## Function Documentation

## readField()

template<class Data_T>

Field< Data_T >::Ptr readField | ( | const std::string & | className,
|  | hid_t | layerGroup,
|  | const std::string & | filename,
|  | const std::string & | layerPath )

This function creates a FieldIO instance based on className which then reads the field data from layerGroup location.

Definition at line 1644 of file Field3DFileHDF5.h.

{
ClassFactory &factory = ClassFactory::singleton();
typedef typename Field<Data_T>::Ptr FieldPtr;
FieldIO::Ptr io = factory.createFieldIO(className);
if (!io) {
Msg::print(Msg::SevWarning, "Unable to find class type: " +
className);
return FieldPtr();
}
DataTypeEnum typeEnum = DataTypeTraits<Data_T>::typeEnum();
FieldBase::Ptr field = io->read(layerGroup, filename, layerPath, typeEnum);
if (!field) {
// We don't need to print a message, because it could just be that
// a layer of the specified data type and name couldn't be found
return FieldPtr();
}
FieldPtr result = field_dynamic_cast<Field<Data_T> >(field);
if (result)
return result;
return FieldPtr();
}
DataTypeEnum
DataTypeEnum
Definition Traits.h:108
ClassFactory
Definition ClassFactory.h:72
ClassFactory::createFieldIO
FieldIO::Ptr createFieldIO(const std::string &className) const
Instances an IO object by name.
Definition ClassFactory.cpp:165
ClassFactory::singleton
static ClassFactory & singleton()
}
Definition ClassFactory.cpp:278
FieldBase::Ptr
boost::intrusive_ptr< FieldBase > Ptr
Definition Field.h:97
FieldIO::Ptr
boost::intrusive_ptr< FieldIO > Ptr
Definition FieldIO.h:91
Field::Ptr
boost::intrusive_ptr< Field > Ptr
Definition Field.h:395
field_dynamic_cast
Field_T::Ptr field_dynamic_cast(RefBase::Ptr field)
Dynamic cast that uses string-comparison in order to be safe even after an object crosses a shared li...
Definition RefCount.h:256
Msg::SevWarning
@ SevWarning
Definition Log.h:68
Msg::print
FIELD3D_API void print(Severity severity, const std::string &message)
Sends the string to the assigned output, prefixing the message with the severity.
Definition Log.cpp:70
DataTypeTraits::typeEnum
static DataTypeEnum typeEnum()

References ClassFactory::createFieldIO(), field_dynamic_cast(), Msg::print(), Msg::SevWarning, ClassFactory::singleton(), and DataTypeTraits< T >::typeEnum().

Referenced by Field3DInputFile::readLayer(), and Field3DInputFileHDF5::readLayer().

## writeField()

FIELD3D_API bool writeField | ( | hid_t | layerGroup,
|  | FieldBase::Ptr | field )

This function creates a FieldIO instance based on field->className() which then writes the field data in layerGroup location.

Definition at line 1589 of file Field3DFileHDF5.cpp.

{
ClassFactory &factory = ClassFactory::singleton();
FieldIO::Ptr io = factory.createFieldIO(field->className());
assert(io != 0);
if (!io) {
Msg::print(Msg::SevWarning, "Unable to find class type: " +
field->className());
return false;
}
// Add class name attribute
if (!writeAttribute(layerGroup, k_classNameAttrName,
field->className())) {
Msg::print(Msg::SevWarning, "Error adding class name attribute.");
return false;
}
return io->write(layerGroup, field);
}
Hdf5Util::writeAttribute
FIELD3D_API bool writeAttribute(hid_t location, const std::string &attrName, const std::string &value)
Writes a string attribute.

References ClassFactory::createFieldIO(), Msg::print(), Msg::SevWarning, ClassFactory::singleton(), and Hdf5Util::writeAttribute().

Referenced by Field3DOutputFile::writeLayer(), and Field3DOutputFileHDF5::writeLayer().

## readFieldMapping()

FIELD3D_API FieldMapping::Ptr readFieldMapping | ( | hid_t | mappingGroup | ) |

This function creates a FieldMappingIO instance based on className read from mappingGroup location which then reads FieldMapping data.

Definition at line 1613 of file Field3DFileHDF5.cpp.

{
ClassFactory &factory = ClassFactory::singleton();
std::string className;
if (!readAttribute(mappingGroup, k_mappingTypeAttrName, className)) {
Msg::print(Msg::SevWarning, "Couldn't find " + k_mappingTypeAttrName +
" attribute");
return FieldMapping::Ptr();
}
FieldMappingIO::Ptr io = factory.createFieldMappingIO(className);
assert(io != 0);
if (!io) {
Msg::print(Msg::SevWarning, "Unable to find class type: " +
className);
return FieldMapping::Ptr();
}
FieldMapping::Ptr mapping = io->read(mappingGroup);
if (!mapping) {
Msg::print(Msg::SevWarning, "Couldn't read mapping");
return FieldMapping::Ptr();
}
return mapping;
}
ClassFactory::createFieldMappingIO
FieldMappingIO::Ptr createFieldMappingIO(const std::string &className) const
Instances an IO object by name.
Definition ClassFactory.cpp:266
FieldMappingIO::Ptr
boost::intrusive_ptr< FieldMappingIO > Ptr
Definition FieldMappingIO.h:71
FieldMapping::Ptr
boost::intrusive_ptr< FieldMapping > Ptr
Definition FieldMapping.h:92
Hdf5Util::readAttribute
FIELD3D_API bool readAttribute(hid_t location, const std::string &attrName, std::string &value)
Reads a string attribute.

References ClassFactory::createFieldMappingIO(), Msg::print(), Hdf5Util::readAttribute(), Msg::SevWarning, and ClassFactory::singleton().

Referenced by Field3DInputFile::readPartitionAndLayerInfo(), and Field3DInputFileHDF5::readPartitionAndLayerInfo().

## writeFieldMapping()

FIELD3D_API bool writeFieldMapping | ( | hid_t | mappingGroup,
|  | FieldMapping::Ptr | mapping )

This function creates a FieldMappingIO instance based on mapping->className() which then writes FieldMapping data to mappingGroup location.

Definition at line 1645 of file Field3DFileHDF5.cpp.

{
ClassFactory &factory = ClassFactory::singleton();
std::string className = mapping->className();
if (!writeAttribute(mappingGroup, k_mappingTypeAttrName, className)) {
Msg::print(Msg::SevWarning, "Couldn't add " + className + " attribute");
return false;
}
FieldMappingIO::Ptr io = factory.createFieldMappingIO(className);
assert(io != 0);
if (!io) {
Msg::print(Msg::SevWarning, "Unable to find class type: " +
className);
return false;
}
return io->write(mappingGroup, mapping);
}

References ClassFactory::createFieldMappingIO(), Msg::print(), Msg::SevWarning, ClassFactory::singleton(), and Hdf5Util::writeAttribute().

Referenced by Field3DOutputFileHDF5::writeMapping().