48 #ifndef _INCLUDED_Field3D_Field3DFile_H_
49 #define _INCLUDED_Field3D_Field3DFile_H_
57 #include <boost/shared_ptr.hpp>
127 typedef boost::intrusive_ptr<Partition>
Ptr;
128 typedef boost::intrusive_ptr<const Partition>
CPtr;
152 virtual std::string className()
const;
162 const File::Layer* layer(
const std::string &name)
const;
165 void getLayerNames(std::vector<std::string> &names)
const;
168 OgOGroup& group()
const;
170 void setGroup(boost::shared_ptr<OgOGroup> ptr);
222 : name(nm), parentName(par), components(cpt)
255 void getPartitionNames(std::vector<std::string> &names)
const;
257 void getScalarLayerNames(std::vector<std::string> &names,
258 const std::string &partitionName)
const;
260 void getVectorLayerNames(std::vector<std::string> &names,
261 const std::string &partitionName)
const;
279 return m_hdf5Base->metadata();
288 return m_hdf5Base->metadata();
303 void printHierarchy()
const;
322 {
return partition(partitionName); }
325 virtual void closeInternal() = 0;
334 void getIntPartitionNames(std::vector<std::string> &names)
const;
337 void getIntScalarLayerNames(std::vector<std::string> &names,
338 const std::string &intPartitionName)
const;
341 void getIntVectorLayerNames(std::vector<std::string> &names,
342 const std::string &intPartitionName)
const;
345 int numIntPartitions(
const std::string &partitionName)
const;
349 std::string makeIntPartitionName(
const std::string &partitionsName,
355 std::string intPartitionName(
const std::string &partitionName,
356 const std::string &layerName,
361 std::string removeUniqueId(
const std::string &partitionName)
const;
431 bool open(
const std::string &filename);
436 const static std::string encodings[2] = {
"Ogawa",
"HDF5" };
437 return encodings[m_hdf5 ? 1 : 0];
443 template <
class Data_T>
445 readLayers(
const std::string &layerName = std::string(
""))
const;
447 template <
class Data_T>
449 readLayers(
const std::string &partitionName,
450 const std::string &layerName)
const;
459 template <
class Data_T>
464 return m_hdf5->readScalarLayers<Data_T>(layerName);
466 return readLayers<Data_T>(layerName);
470 template <
class Data_T>
473 const std::string &layerName)
const
476 return m_hdf5->readScalarLayers<Data_T>(partitionName, layerName);
478 return readLayers<Data_T>(partitionName, layerName);
485 template <
class Data_T>
490 return m_hdf5->readVectorLayers<Data_T>(layerName);
492 return readLayers<FIELD3D_VEC3_T<Data_T> >(layerName);
496 template <
class Data_T>
499 const std::string &layerName)
const
502 return m_hdf5->readVectorLayers<Data_T>(partitionName, layerName);
504 return readLayers<FIELD3D_VEC3_T<Data_T> >(partitionName, layerName);
517 template <
class Data_T>
519 readProxyLayer(
const std::string &partitionName,
520 const std::string &layerName,
521 bool isVectorLayer)
const;
528 template <
class Data_T>
530 readProxyScalarLayers(
const std::string &name = std::string(
""))
const;
537 template <
class Data_T>
539 readProxyVectorLayers(
const std::string &name = std::string(
""))
const;
550 m_hdf5->closeInternal();
563 m_partitions.clear();
574 template <
class Data_T>
576 readLayer(
const std::string &intPartitionName,
577 const std::string &layerName)
const;
582 template <
class Data_T>
584 readProxyLayer(OgIGroup &location,
const std::string &name,
585 const std::string &attribute,
589 bool readPartitionAndLayerInfo();
592 bool readMetadata(
const OgIGroup &metadataGroup,
FieldBase::Ptr field)
const;
595 bool readMetadata(
const OgIGroup &metadataGroup);
607 boost::shared_ptr<Field3DInputFileHDF5>
m_hdf5;
660 bool create(
const std::string &filename, CreateMode cm = OverwriteMode);
673 if (u.c[0] == 0x67) {
674 ms_doOgawa = enabled;
676 std::cerr <<
"WARNING: Field3D only supports Ogawa-backed files "
677 <<
"on little-endian systems." << std::endl;
686 template <
class Data_T>
690 return writeLayer<Data_T>(std::string(
"default"), layerName, layer);
695 template <
class Data_T>
696 bool writeLayer(
const std::string &partitionName,
697 const std::string &layerName,
702 template <
class Data_T>
705 return writeLayer<Data_T>(layer->
name, layer->
attribute, layer);
714 template <
class Data_T>
719 return m_hdf5->writeScalarLayer<Data_T>(layerName, layer);
721 return writeScalarLayer<Data_T>(std::string(
"default"), layerName, layer);
726 template <
class Data_T>
728 const std::string &layerName,
732 return m_hdf5->writeScalarLayer<Data_T>(partitionName, layerName, layer);
734 return writeLayer<Data_T>(partitionName, layerName, layer);
739 template <
class Data_T>
743 return m_hdf5->writeScalarLayer<Data_T>(layer);
745 return writeLayer<Data_T>(layer);
749 template <
class Data_T>
751 typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr layer)
754 return m_hdf5->writeVectorLayer<Data_T>(layerName, layer);
756 return writeVectorLayer<Data_T>(std::string(
"default"), layerName, layer);
761 template <
class Data_T>
763 const std::string &layerName,
764 typename Field<FIELD3D_VEC3_T<Data_T> >::Ptr layer)
767 return m_hdf5->writeVectorLayer<Data_T>(partitionName, layerName, layer);
769 return writeLayer<FIELD3D_VEC3_T<Data_T> >(partitionName, layerName, layer);
774 template <
class Data_T>
778 return m_hdf5->writeVectorLayer<Data_T>(layer);
780 return writeLayer<FIELD3D_VEC3_T<Data_T> >(layer);
784 bool writeGlobalMetadata();
788 bool writeGroupMembership();
799 m_hdf5->closeInternal();
811 m_partitions.clear();
821 std::string incrementPartitionName(std::string &pname);
825 createNewPartition(
const std::string &partitionName,
833 bool writeMetadata(OgOGroup &metadataGroup,
FieldBase::Ptr layer);
836 bool writeMetadata(OgOGroup &metadataGroup);
849 boost::shared_ptr<Field3DOutputFileHDF5>
m_hdf5;