Field3D
Field3DFile.h File Reference

Contains the Field3DFile classesOSS sanitized. More...

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

Go to the source code of this file.

Classes

class  Field3DFileBase
 
struct  Field3DFileBase::LayerInfo
 
class  Field3DInputFile
 Provides reading of .f3d (internally, hdf5) files.Refer to using_files for examples of how to use this in your code. More...
 
class  Field3DOutputFile
 Provides writing of .f3d (internally, hdf5) files. More...
 
class  File::Layer
 
class  File::Partition
 
struct  InputFile::ParseLayersInfo
 struct used to pass the class and partition info back to the parseLayers() callback More...
 

Namespaces

 File
 Namespace for file I/O specifics.
 
 InputFile
 Namespace for file input specifics.
 

Functions

bool fileExists (const std::string &filename)
 checks to see if a file/directory exists or not More...
 
FIELD3D_API 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. More...
 
FIELD3D_API 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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

Contains the Field3DFile classes

OSS sanitized.

Definition in file Field3DFile.h.

Function Documentation

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 1641 of file Field3DFile.h.

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

1643 {
1644 
1646 
1647  typedef typename Field<Data_T>::Ptr FieldPtr;
1648 
1649  FieldIO::Ptr io = factory.createFieldIO(className);
1650  assert(io != 0);
1651  if (!io) {
1652  Msg::print(Msg::SevWarning, "Unable to find class type: " +
1653  className);
1654  return FieldPtr();
1655  }
1656 
1658  FieldBase::Ptr field = io->read(layerGroup, filename, layerPath, typeEnum);
1659 
1660  if (!field) {
1661  // We don't need to print a message, because it could just be that
1662  // a layer of the specified data type and name couldn't be found
1663  return FieldPtr();
1664  }
1665 
1666  FieldPtr result = field_dynamic_cast<Field<Data_T> >(field);
1667 
1668  if (result)
1669  return result;
1670 
1671  return FieldPtr();
1672 }
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
Definition: Field.h:394
boost::intrusive_ptr< FieldBase > Ptr
Definition: Field.h:97
static ClassFactory & singleton()
}
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:66
static DataTypeEnum typeEnum()
FieldIO::Ptr createFieldIO(const std::string &className) const
Instances an IO object by name.
boost::intrusive_ptr< FieldIO > Ptr
Definition: FieldIO.h:90
DataTypeEnum
Definition: Traits.h:66
boost::intrusive_ptr< Field > Ptr
Definition: Field.h:400
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 1585 of file Field3DFile.cpp.

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

Referenced by Field3DOutputFile::writeLayer().

1586 {
1588 
1589  FieldIO::Ptr io = factory.createFieldIO(field->className());
1590  assert(io != 0);
1591  if (!io) {
1592  Msg::print(Msg::SevWarning, "Unable to find class type: " +
1593  field->className());
1594  return false;
1595  }
1596 
1597  // Add class name attribute
1598  if (!writeAttribute(layerGroup, k_classNameAttrName,
1599  field->className())) {
1600  Msg::print(Msg::SevWarning, "Error adding class name attribute.");
1601  return false;
1602  }
1603 
1604  return io->write(layerGroup, field);
1605 }
FIELD3D_API bool writeAttribute(hid_t location, const std::string &attrName, const std::string &value)
Writes a string attribute.
static ClassFactory & singleton()
}
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:66
FieldIO::Ptr createFieldIO(const std::string &className) const
Instances an IO object by name.
boost::intrusive_ptr< FieldIO > Ptr
Definition: FieldIO.h:90
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 1609 of file Field3DFile.cpp.

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

Referenced by Field3DInputFile::readPartitionAndLayerInfo().

1610 {
1612 
1613  std::string className;
1614 
1615  if (!readAttribute(mappingGroup, k_mappingTypeAttrName, className)) {
1616  Msg::print(Msg::SevWarning, "Couldn't find " + k_mappingTypeAttrName +
1617  " attribute");
1618  return FieldMapping::Ptr();
1619  }
1620 
1621  FieldMappingIO::Ptr io = factory.createFieldMappingIO(className);
1622  assert(io != 0);
1623  if (!io) {
1624  Msg::print(Msg::SevWarning, "Unable to find class type: " +
1625  className);
1626  return FieldMapping::Ptr();
1627  }
1628 
1629 
1630  FieldMapping::Ptr mapping = io->read(mappingGroup);
1631  if (!mapping) {
1632  Msg::print(Msg::SevWarning, "Couldn't read mapping");
1633  return FieldMapping::Ptr();
1634  }
1635 
1636  return mapping;
1637 }
boost::intrusive_ptr< FieldMappingIO > Ptr
FIELD3D_API bool readAttribute(hid_t location, const std::string &attrName, std::string &value)
Reads a string attribute.
static ClassFactory & singleton()
}
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:66
boost::intrusive_ptr< FieldMapping > Ptr
Definition: FieldMapping.h:92
FieldMappingIO::Ptr createFieldMappingIO(const std::string &className) const
Instances an IO object by name.
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 1641 of file Field3DFile.cpp.

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

Referenced by Field3DOutputFile::writeMapping().

1642 {
1644 
1645  std::string className = mapping->className();
1646 
1647  if (!writeAttribute(mappingGroup, k_mappingTypeAttrName, className)) {
1648  Msg::print(Msg::SevWarning, "Couldn't add " + className + " attribute");
1649  return false;
1650  }
1651 
1652  FieldMappingIO::Ptr io = factory.createFieldMappingIO(className);
1653  assert(io != 0);
1654  if (!io) {
1655  Msg::print(Msg::SevWarning, "Unable to find class type: " +
1656  className);
1657  return false;
1658  }
1659 
1660  return io->write(mappingGroup, mapping);
1661 }
boost::intrusive_ptr< FieldMappingIO > Ptr
FIELD3D_API bool writeAttribute(hid_t location, const std::string &attrName, const std::string &value)
Writes a string attribute.
static ClassFactory & singleton()
}
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:66
FieldMappingIO::Ptr createFieldMappingIO(const std::string &className) const
Instances an IO object by name.
bool fileExists ( const std::string &  filename)

checks to see if a file/directory exists or not

Parameters
[in]filenamethe file/directory to check
Return values
trueif it exists
falseif it does not exist

Definition at line 1572 of file Field3DFile.cpp.

Referenced by FileSequence::FileSequence().

1573 {
1574 #ifdef WIN32
1575  struct __stat64 statbuf;
1576  return (_stat64(filename.c_str(), &statbuf) != -1);
1577 #else
1578  struct stat statbuf;
1579  return (stat(filename.c_str(), &statbuf) != -1);
1580 #endif
1581 }