Field3DFileBase Class Referenceabstract
File I/O

`#include <Field3DFile.h>`

Inheritance diagram for Field3DFileBase:

## Classes

struct | LayerInfo

## Public Types

typedef std::map< std::string, std::string > | GroupMembershipMap

## Public Member Functions

void | clear ()
| Clear the data structures and close the file.
bool | close ()
| Closes the file. No need to call this unless you specifically want to close the file early. It will close once the File object goes out of scope.
FieldMetadata & | metadata ()
| accessor to the m_metadata class
const FieldMetadata & | metadata () const
| Read only access to the m_metadata class.
virtual void | metadataHasChanged (const std::string &)
| This function should implemented by concrete classes to get the callback when metadata changes.
Constructors & destructor
| Field3DFileBase ()
virtual | ~Field3DFileBase ()=0
| Pure virtual destructor to ensure we never instantiate this class.
Retreiving partition and layer names
void | getPartitionNames (std::vector< std::string > &names) const
| Gets the names of all the partitions in the file.
void | getScalarLayerNames (std::vector< std::string > &names, const std::string &partitionName) const
| Gets the names of all the scalar layers in a given partition.
void | getVectorLayerNames (std::vector< std::string > &names, const std::string &partitionName) const
| Gets the names of all the vector layers in a given partition.
Convenience methods for partitionName
void | addGroupMembership (const GroupMembershipMap &groupMembers)
| Add to the group membership.
Debug
void | printHierarchy () const

## Protected Types

typedef std::map< std::string, int > | PartitionCountMap
typedef std::vector< File::Partition::Ptr > | PartitionList

## Protected Member Functions

Convenience methods
File::Partition::Ptr | getPartition (const std::string &partitionName) const
| Returns a pointer to the given partition.
virtual void | closeInternal ()=0
| Closes the file if open.
File::Partition::Ptr | partition (const std::string &partitionName)
| Returns a pointer to the given partition.
File::Partition::Ptr | partition (const std::string &partitionName) const
| Returns a pointer to the given partition.
void | getIntPartitionNames (std::vector< std::string > &names) const
| Gets the names of all the -internal- partitions in the file.
void | getIntScalarLayerNames (std::vector< std::string > &names, const std::string &intPartitionName) const
| Gets the names of all the scalar layers in a given partition, but assumes that partition name is the -internal- partition name.
void | getIntVectorLayerNames (std::vector< std::string > &names, const std::string &intPartitionName) const
| Gets the names of all the vector layers in a given partition, but assumes that partition name is the -internal- partition name.
int | numIntPartitions (const std::string &partitionName) const
| Returns the number of internal partitions for a given partition name.
std::string | makeIntPartitionName (const std::string &partitionsName, int i) const
| Makes an internal partition name given the external partition name. Effectively just tacks on .X to the name, where X is the number.
std::string | intPartitionName (const std::string &partitionName, const std::string &layerName, FieldRes::Ptr field)
| Returns a unique partition name given the requested name. This ensures that partitions with matching mappings get the same name but each subsequent differing mapping gets a new, separate name.
std::string | removeUniqueId (const std::string &partitionName) const
| Strips any unique identifiers from the partition name and returns the original name.

## Protected Attributes

GroupMembershipMap | m_groupMembership
| Keeps track of group membership for each layer of partition name. The key is the "group" and the value is a space separated list of "partitionName.0:Layer1 partitionName.1:Layer0 ...".
boost::shared_ptr< Field3DFileHDF5Base > | m_hdf5Base
| HDF5 fallback.
std::vector< LayerInfo > | m_layerInfo
| This stores layer info.
FieldMetadata | m_metadata
| metadata
PartitionCountMap | m_partitionCount
| Contains a counter for each partition name. This is used to keep multiple fields with the same name unique in the file.
std::vector< std::string > | m_partitionNames
| This stores partition names.
PartitionList | m_partitions
| Vector of partitions.

## Private Member Functions

| Field3DFileBase (const Field3DFileBase &)
void | operator= (const Field3DFileBase &)

## Detailed Description

Provides some common functionality for Field3DInputFile and Field3DOutputFile. It hold the partition->layer data structures, but knows nothing about how to actually get them to/from disk.

Definition at line 210 of file Field3DFile.h.

## Member Typedef Documentation

## GroupMembershipMap

typedef std::map<std::string, std::string> Field3DFileBase::GroupMembershipMap

Definition at line 228 of file Field3DFile.h.

## PartitionList

typedef std::vector<File::Partition::Ptr> Field3DFileBase::PartitionList

protected

Definition at line 311 of file Field3DFile.h.

## PartitionCountMap

typedef std::map<std::string, int> Field3DFileBase::PartitionCountMap

protected

Definition at line 312 of file Field3DFile.h.

## Constructor & Destructor Documentation

## Field3DFileBase() [1/2]

Field3DFileBase::Field3DFileBase | ( |  | ) |

Definition at line 405 of file Field3DFile.cpp.

: m_metadata(this)
{
// Empty
}
Field3DFileBase::m_metadata
FieldMetadata m_metadata
metadata
Definition Field3DFile.h:385

References m_metadata.

Referenced by Field3DFileBase(), and operator=().

## ~Field3DFileBase()

Field3DFileBase::~Field3DFileBase | ( |  | ) |

pure virtual

Pure virtual destructor to ensure we never instantiate this class.

Definition at line 413 of file Field3DFile.cpp.

{
m_partitions.clear();
m_groupMembership.clear();
}
Field3DFileBase::m_groupMembership
GroupMembershipMap m_groupMembership
Keeps track of group membership for each layer of partition name. The key is the "group" and the valu...
Definition Field3DFile.h:382
Field3DFileBase::m_partitions
PartitionList m_partitions
Vector of partitions.
Definition Field3DFile.h:371

References m_groupMembership, and m_partitions.

## Field3DFileBase() [2/2]

Field3DFileBase::Field3DFileBase | ( | const Field3DFileBase & |  | ) |

private

References Field3DFileBase().

## Member Function Documentation

## clear()

void Field3DFileBase::clear | ( |  | ) |

Clear the data structures and close the file.

Definition at line 616 of file Field3DFile.cpp.

{
if (m_hdf5Base) {
m_hdf5Base->clear();
return;
}
closeInternal();
m_partitions.clear();
m_groupMembership.clear();
}
Field3DFileBase::m_hdf5Base
boost::shared_ptr< Field3DFileHDF5Base > m_hdf5Base
HDF5 fallback.
Definition Field3DFile.h:388
Field3DFileBase::closeInternal
virtual void closeInternal()=0
Closes the file if open.

References closeInternal(), m_groupMembership, m_hdf5Base, and m_partitions.

Referenced by Field3DInputFile::open().

## close()

bool Field3DFileBase::close | ( |  | ) |

Closes the file. No need to call this unless you specifically want to close the file early. It will close once the File object goes out of scope.

Definition at line 630 of file Field3DFile.cpp.

{
if (m_hdf5Base) {
return m_hdf5Base->close();
}
closeInternal();
return true;
}

References closeInternal(), and m_hdf5Base.

Referenced by Field3DInputFile::open().

## getPartitionNames()

void Field3DFileBase::getPartitionNames | ( | std::vector< std::string > & | names | ) | const

Gets the names of all the partitions in the file.

Definition at line 492 of file Field3DFile.cpp.

{
if (m_hdf5Base) {
m_hdf5Base->getPartitionNames(names);
return;
}
names.clear();
vector<string> tempNames;
for (PartitionList::const_iterator i = m_partitions.begin();
i != m_partitions.end(); ++i) {
tempNames.push_back(removeUniqueId((**i).name));
}
names = makeUnique(tempNames);
}
Field3DFileBase::removeUniqueId
std::string removeUniqueId(const std::string &partitionName) const
Strips any unique identifiers from the partition name and returns the original name.
Definition Field3DFile.cpp:479

References m_hdf5Base, m_partitions, and removeUniqueId().

Referenced by FieldGroup< BaseTypeList_T, Dims_T >::load(), Field3DInputFile::readProxyScalarLayers(), and Field3DInputFile::readProxyVectorLayers().

## getScalarLayerNames()

void Field3DFileBase::getScalarLayerNames | ( | std::vector< std::string > & | names,
|  | const std::string & | partitionName ) const

Gets the names of all the scalar layers in a given partition.

Todo
  Make this really only return scalar layers

Definition at line 514 of file Field3DFile.cpp.

{
if (m_hdf5Base) {
m_hdf5Base->getScalarLayerNames(names, partitionName);
return;
}
names.clear();
for (int i = 0; i < numIntPartitions(partitionName); i++) {
string internalName = makeIntPartitionName(partitionName, i);
File::Partition::Ptr part = partition(internalName);
if (part)
part->getLayerNames(names);
}
names = makeUnique(names);
}
Field3DFileBase::makeIntPartitionName
std::string makeIntPartitionName(const std::string &partitionsName, int i) const
Makes an internal partition name given the external partition name. Effectively just tacks on ....
Definition Field3DFile.cpp:665
Field3DFileBase::partition
File::Partition::Ptr partition(const std::string &partitionName)
Returns a pointer to the given partition.
Field3DFileBase::numIntPartitions
int numIntPartitions(const std::string &partitionName) const
Returns the number of internal partitions for a given partition name.
Definition Field3DFile.cpp:644
File::Partition::Ptr
boost::intrusive_ptr< Partition > Ptr
Definition Field3DFile.h:127

References m_hdf5Base, makeIntPartitionName(), numIntPartitions(), and partition().

Referenced by Field3DInputFile::readProxyScalarLayers().

## getVectorLayerNames()

void Field3DFileBase::getVectorLayerNames | ( | std::vector< std::string > & | names,
|  | const std::string & | partitionName ) const

Gets the names of all the vector layers in a given partition.

Todo
  Make this really only return vector layers

Definition at line 539 of file Field3DFile.cpp.

{
if (m_hdf5Base) {
m_hdf5Base->getVectorLayerNames(names, partitionName);
return;
}
names.clear();
for (int i = 0; i < numIntPartitions(partitionName); i++) {
string internalName = makeIntPartitionName(partitionName, i);
File::Partition::Ptr part = partition(internalName);
if (part)
part->getLayerNames(names);
}
names = makeUnique(names);
}

References m_hdf5Base, makeIntPartitionName(), numIntPartitions(), and partition().

Referenced by Field3DInputFile::readProxyVectorLayers().

## addGroupMembership()

void Field3DFileBase::addGroupMembership | ( | const GroupMembershipMap & | groupMembers | ) |

Add to the group membership.

Definition at line 674 of file Field3DFile.cpp.

{
if (m_hdf5Base) {
m_hdf5Base->addGroupMembership(groupMembers);
return;
}
GroupMembershipMap::const_iterator i = groupMembers.begin();
GroupMembershipMap::const_iterator end = groupMembers.end();
for (; i != end; ++i) {
GroupMembershipMap::iterator foundGroupIter =
m_groupMembership.find(i->first);
if (foundGroupIter != m_groupMembership.end()){
std::string value = m_groupMembership[i->first] + i->second;
m_groupMembership[i->first] = value;
} else {
m_groupMembership[i->first] = i->second;
}
}
}

References m_groupMembership, and m_hdf5Base.

## metadata() [1/2]

FieldMetadata & Field3DFileBase::metadata | ( |  | ) |

inline

accessor to the m_metadata class

Definition at line 276 of file Field3DFile.h.

{
if (m_hdf5Base) {
return m_hdf5Base->metadata();
}
return m_metadata;
}

References m_hdf5Base, and m_metadata.

Referenced by Field3DInputFile::readMetadata(), and Field3DOutputFile::writeMetadata().

## metadata() [2/2]

const FieldMetadata & Field3DFileBase::metadata | ( |  | ) | const

inline

Read only access to the m_metadata class.

Definition at line 285 of file Field3DFile.h.

{
if (m_hdf5Base) {
return m_hdf5Base->metadata();
}
return m_metadata;
}

References m_hdf5Base, and m_metadata.

## metadataHasChanged()

virtual void Field3DFileBase::metadataHasChanged | ( | const std::string & |  | ) |

inline virtual

This function should implemented by concrete classes to
get the callback when metadata changes.

Reimplemented from MetadataCallback.

Definition at line 295 of file Field3DFile.h.

{ /* Empty */ }

## printHierarchy()

void Field3DFileBase::printHierarchy | ( |  | ) | const

Definition at line 1320 of file Field3DFile.cpp.

{
// For each partition
for (PartitionList::const_iterator i = m_partitions.begin();
i != m_partitions.end(); ++i) {
cout << "Name: " << (**i).name << endl;
if ((**i).mapping)
cout << " Mapping: " << (**i).mapping->className() << endl;
else
cout << " Mapping: NULL" << endl;
cout << " Layers: " << endl;
vector<string> names;
(**i).getLayerNames(names);
for_each(names.begin(), names.end(), print<string>(4));
}
}

References m_partitions.

## getPartition()

File::Partition::Ptr Field3DFileBase::getPartition | ( | const std::string & | partitionName | ) | const

inline protected

Returns a pointer to the given partition.

Returns
  NULL if no partition was found of that name

Definition at line 321 of file Field3DFile.h.

{ return partition(partitionName); }

References partition().

## closeInternal()

virtual void Field3DFileBase::closeInternal | ( |  | ) |

protected pure virtual

Closes the file if open.

Implemented in Field3DInputFile, and Field3DOutputFile.

Referenced by clear(), and close().

## partition() [1/2]

File::Partition::Ptr Field3DFileBase::partition | ( | const std::string & | partitionName | ) |

protected

Returns a pointer to the given partition.

Returns
  NULL if no partition was found of that name

Referenced by Field3DOutputFile::createNewPartition(), getIntScalarLayerNames(), getIntVectorLayerNames(), getPartition(), getScalarLayerNames(), getVectorLayerNames(), Field3DInputFile::readLayer(), Field3DInputFile::readPartitionAndLayerInfo(), Field3DInputFile::readProxyLayer(), and Field3DOutputFile::writeLayer().

## partition() [2/2]

File::Partition::Ptr Field3DFileBase::partition | ( | const std::string & | partitionName | ) | const

protected

Returns a pointer to the given partition.

Returns
  NULL if no partition was found of that name

References getIntPartitionNames(), getIntScalarLayerNames(), getIntVectorLayerNames(), intPartitionName(), makeIntPartitionName(), numIntPartitions(), and removeUniqueId().

## getIntPartitionNames()

void Field3DFileBase::getIntPartitionNames | ( | std::vector< std::string > & | names | ) | const

protected

Gets the names of all the -internal- partitions in the file.

Definition at line 564 of file Field3DFile.cpp.

{
names.clear();
for (PartitionList::const_iterator i = m_partitions.begin();
i != m_partitions.end(); ++i) {
names.push_back((**i).name);
}
}

References m_partitions.

Referenced by partition(), Field3DInputFile::readLayers(), Field3DInputFile::readLayers(), and Field3DInputFile::readProxyLayer().

## getIntScalarLayerNames()

void Field3DFileBase::getIntScalarLayerNames | ( | std::vector< std::string > & | names,
|  | const std::string & | intPartitionName ) const

protected

Gets the names of all the scalar layers in a given partition, but assumes that partition name is the -internal- partition name.

Todo
  Make this really only return scalar layers

Definition at line 577 of file Field3DFile.cpp.

{
names.clear();
File::Partition::Ptr part = partition(intPartitionName);
if (!part) {
Msg::print("getIntScalarLayerNames no partition: " + intPartitionName);
return;
}
part->getLayerNames(names);
}
Field3DFileBase::intPartitionName
std::string intPartitionName(const std::string &partitionName, const std::string &layerName, FieldRes::Ptr field)
Returns a unique partition name given the requested name. This ensures that partitions with matching ...
Definition Field3DFile.cpp:422
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

References intPartitionName(), partition(), and Msg::print().

Referenced by partition(), Field3DInputFile::readLayers(), Field3DInputFile::readLayers(), and Field3DInputFile::readProxyLayer().

## getIntVectorLayerNames()

void Field3DFileBase::getIntVectorLayerNames | ( | std::vector< std::string > & | names,
|  | const std::string & | intPartitionName ) const

protected

Gets the names of all the vector layers in a given partition, but assumes that partition name is the -internal- partition name.

Todo
  Make this really only return vector layers

Definition at line 597 of file Field3DFile.cpp.

{
names.clear();
File::Partition::Ptr part = partition(intPartitionName);
if (!part) {
Msg::print("getIntVectorLayerNames no partition: " + intPartitionName);
return;
}
part->getLayerNames(names);
}

References intPartitionName(), partition(), and Msg::print().

Referenced by partition(), and Field3DInputFile::readProxyLayer().

## numIntPartitions()

int Field3DFileBase::numIntPartitions | ( | const std::string & | partitionName | ) | const

protected

Returns the number of internal partitions for a given partition name.

Definition at line 644 of file Field3DFile.cpp.

{
int count = 0;
for (PartitionList::const_iterator i = m_partitions.begin();
i != m_partitions.end(); ++i) {
string name = (**i).name;
size_t pos = name.rfind(".");
if (pos != name.npos) {
if (name.substr(0, pos) == partitionName) {
count++;
}
}
}
return count;
}

References m_partitions.

Referenced by getScalarLayerNames(), getVectorLayerNames(), and partition().

## makeIntPartitionName()

string Field3DFileBase::makeIntPartitionName | ( | const std::string & | partitionsName,
|  | int | i ) const

protected

Makes an internal partition name given the external partition name. Effectively just tacks on .X to the name, where X is the number.

Definition at line 665 of file Field3DFile.cpp.

{
return partitionName + "." + boost::lexical_cast<std::string>(i);
}

Referenced by getScalarLayerNames(), getVectorLayerNames(), Field3DOutputFile::incrementPartitionName(), intPartitionName(), and partition().

## intPartitionName()

std::string Field3DFileBase::intPartitionName | ( | const std::string & | partitionName,
|  | const std::string & | layerName,
|  | FieldRes::Ptr | field )

protected

Returns a unique partition name given the requested name. This ensures that partitions with matching mappings get the same name but each subsequent differing mapping gets a new, separate name.

Definition at line 422 of file Field3DFile.cpp.

{
// Loop over existing partitions and see if there's a matching mapping
for (PartitionList::const_iterator i = m_partitions.begin();
i != m_partitions.end(); ++i) {
if (removeUniqueId((**i).name) == partitionName) {
if ((**i).mapping->isIdentical(field->mapping())) {
return (**i).name;
}
}
}
// If there was no previously matching name, then make a new one
int nextIdx = -1;
if (m_partitionCount.find(partitionName) != m_partitionCount.end()) {
nextIdx = ++m_partitionCount[partitionName];
} else {
nextIdx = 0;
m_partitionCount[partitionName] = 0;
}
return makeIntPartitionName(partitionName, nextIdx);
}
Field3DFileBase::m_partitionCount
PartitionCountMap m_partitionCount
Contains a counter for each partition name. This is used to keep multiple fields with the same name u...
Definition Field3DFile.h:377

References m_partitionCount, m_partitions, makeIntPartitionName(), and removeUniqueId().

Referenced by getIntScalarLayerNames(), getIntVectorLayerNames(), partition(), Field3DInputFile::readLayer(), and Field3DOutputFile::writeLayer().

## removeUniqueId()

std::string Field3DFileBase::removeUniqueId | ( | const std::string & | partitionName | ) | const

protected

Strips any unique identifiers from the partition name and returns the original name.

Definition at line 479 of file Field3DFile.cpp.

{
size_t pos = partitionName.rfind(".");
if (pos == partitionName.npos) {
return partitionName;
} else {
return partitionName.substr(0, pos);
}
}

Referenced by getPartitionNames(), Field3DOutputFile::incrementPartitionName(), intPartitionName(), partition(), Field3DInputFile::readLayer(), Field3DInputFile::readLayers(), and Field3DInputFile::readProxyLayer().

## operator=()

void Field3DFileBase::operator= | ( | const Field3DFileBase & |  | ) |

private

References Field3DFileBase().

## Member Data Documentation

## m_layerInfo

std::vector<LayerInfo> Field3DFileBase::m_layerInfo

protected

This stores layer info.

Definition at line 368 of file Field3DFile.h.

## m_partitions

PartitionList Field3DFileBase::m_partitions

protected

Vector of partitions.

Definition at line 371 of file Field3DFile.h.

Referenced by Field3DInputFile::cleanup(), Field3DOutputFile::cleanup(), clear(), Field3DOutputFile::createNewPartition(), getIntPartitionNames(), getPartitionNames(), intPartitionName(), numIntPartitions(), printHierarchy(), Field3DInputFile::readPartitionAndLayerInfo(), and ~Field3DFileBase().

## m_partitionNames

std::vector<std::string> Field3DFileBase::m_partitionNames

protected

This stores partition names.

Definition at line 373 of file Field3DFile.h.

## m_partitionCount

PartitionCountMap Field3DFileBase::m_partitionCount

protected

Contains a counter for each partition name. This is used to keep multiple fields with the same name unique in the file.

Definition at line 377 of file Field3DFile.h.

Referenced by Field3DOutputFile::incrementPartitionName(), and intPartitionName().

## m_groupMembership

GroupMembershipMap Field3DFileBase::m_groupMembership

protected

Keeps track of group membership for each layer of partition name. The key is the "group" and the value is a space separated list of "partitionName.0:Layer1 partitionName.1:Layer0 ...".

Definition at line 382 of file Field3DFile.h.

Referenced by addGroupMembership(), clear(), Field3DOutputFile::writeGroupMembership(), and ~Field3DFileBase().

## m_metadata

FieldMetadata Field3DFileBase::m_metadata

protected

metadata

Definition at line 385 of file Field3DFile.h.

Referenced by Field3DFileBase(), metadata(), and metadata().

## m_hdf5Base

boost::shared_ptr<Field3DFileHDF5Base> Field3DFileBase::m_hdf5Base

protected

HDF5 fallback.

Definition at line 388 of file Field3DFile.h.

Referenced by addGroupMembership(), clear(), close(), Field3DOutputFile::create(), getPartitionNames(), getScalarLayerNames(), getVectorLayerNames(), metadata(), metadata(), and Field3DInputFile::open().

The documentation for this class was generated from the following files:

- export/Field3DFile.h
- src/Field3DFile.cpp