Field3D
InputFile Namespace Reference

Namespace for file input specifics. More...

Classes

struct  ParseLayersInfo
 struct used to pass the class and partition info back to the parseLayers() callback More...
 

Functions

herr_t 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...
 
herr_t 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...
 

Detailed Description

Namespace for file input specifics.

Function Documentation

◆ parsePartitions()

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.

Definition at line 1110 of file Field3DFile.cpp.

References Field3DInputFile::parsePartition().

Referenced by Field3DInputFile::readPartitionAndLayerInfo().

1112 {
1113  herr_t status;
1114  H5O_info_t infobuf;
1115 
1116  status = H5Oget_info_by_name(loc_id, itemName, &infobuf, H5P_DEFAULT);
1117 
1118  if (status < 0) {
1119  return -1;
1120  }
1121 
1122  if (infobuf.type == H5O_TYPE_GROUP) {
1123 
1124  // Check that we have a name
1125  if (!itemName) {
1126  return -1;
1127  }
1128 
1129  // check that this group is not "groupMembership"
1130  if (string(itemName) != "field3d_group_membership" &&
1131  string(itemName) != "field3d_global_metadata")
1132  {
1133 
1134  // Get a pointer to the file data structure
1135  Field3DInputFile* fileObject = static_cast<Field3DInputFile*>(opdata);
1136  if (!fileObject) {
1137  return -1;
1138  }
1139 
1140  return fileObject->parsePartition(loc_id, itemName);
1141  }
1142  }
1143  return 0;
1144 }
herr_t parsePartition(hid_t loc_id, const std::string partitionName)
Gets called from parsePartitions. Not intended for any other use.
Provides reading of .f3d (internally, hdf5) files.Refer to using_files for examples of how to use thi...
Definition: Field3DFile.h:431

◆ parseLayers()

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.

Definition at line 1148 of file Field3DFile.cpp.

References InputFile::ParseLayersInfo::file, Hdf5Util::H5Base::id(), Field3DInputFile::parseLayer(), InputFile::ParseLayersInfo::partitionName, and Hdf5Util::readAttribute().

Referenced by Field3DInputFile::readPartitionAndLayerInfo().

1150 {
1151  herr_t status;
1152  H5O_info_t infobuf;
1153 
1154  status = H5Oget_info_by_name (loc_id, itemName, &infobuf, H5P_DEFAULT);
1155 
1156  if (infobuf.type == H5O_TYPE_GROUP) {
1157 
1158  // Check that we have a name
1159  if (!itemName)
1160  return -1;
1161 
1162  // Get a pointer to the file data structure
1163  ParseLayersInfo* info = static_cast<ParseLayersInfo*>(opdata);
1164  if (!info)
1165  return -1;
1166 
1167  // Open up the layer group
1168  H5ScopedGopen layerGroup(loc_id, itemName);
1169 
1170  // Check if it's a layer
1171  string classType;
1172  try {
1173  if (!readAttribute(layerGroup.id(), "class_type", classType)) {
1174  return 0;
1175  }
1176  if (classType == string("field3d_layer"))
1177  return info->file->parseLayer(layerGroup.id(), info->partitionName,
1178  itemName);
1179 
1180  }
1181  catch (MissingAttributeException &e) {
1182 
1183  }
1184  return 0;
1185 
1186  }
1187 
1188  return 0;
1189 }
herr_t parseLayer(hid_t loc_id, const std::string &partitionName, const std::string &layerName)
Gets called from parsePartitions. Not intended for any other use.
bool readAttribute(hid_t location, const std::string &attrName, std::string &value)
Reads a string attribute.
struct used to pass the class and partition info back to the parseLayers() callback ...
Definition: Field3DFile.h:743
Field3DInputFile * file
Definition: Field3DFile.h:745
Scoped object - opens a group on creation and closes it on destruction.
Definition: Hdf5Util.h:176