Field3D
Field3DFile.cpp File Reference

Contains implementations of Field3DFile-related member functions. More...

#include <sys/stat.h>
#include <unistd.h>
#include <hdf5.h>
#include <H5Epublic.h>
#include <boost/tokenizer.hpp>
#include <boost/utility.hpp>
#include "Field3DFile.h"
#include "Field.h"
#include "ClassFactory.h"

Go to the source code of this file.

Namespaces

namespace  InputFile
 

Namespace for file input specifics.


Functions

herr_t InputFile::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.
herr_t InputFile::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.
FieldMapping::Ptr readFieldMapping (hid_t mappingGroup)
 This function creates a FieldMappingIO instance based on className read from mappingGroup location which then reads FieldMapping data.
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.
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 implementations of Field3DFile-related member functions.

Definition in file Field3DFile.cpp.


Function Documentation

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 1558 of file Field3DFile.cpp.

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

Referenced by Field3DOutputFile::writeLayer().

{
  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);
}
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 1582 of file Field3DFile.cpp.

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

Referenced by Field3DInputFile::readPartitionAndLayerInfo().

{
  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;
}
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 1614 of file Field3DFile.cpp.

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

Referenced by Field3DOutputFile::writeMapping().

{
  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);
}