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

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

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

References g_hdf5Mutex, and Field3DInputFile::parsePartition().

Referenced by Field3DInputFile::readPartitionAndLayerInfo().

1115 {
1116  GlobalLock lock(g_hdf5Mutex);
1117 
1118  herr_t status;
1119  H5O_info_t infobuf;
1120 
1121  status = H5Oget_info_by_name(loc_id, itemName, &infobuf, H5P_DEFAULT);
1122 
1123  if (status < 0) {
1124  return -1;
1125  }
1126 
1127  if (infobuf.type == H5O_TYPE_GROUP) {
1128 
1129  // Check that we have a name
1130  if (!itemName) {
1131  return -1;
1132  }
1133 
1134  // check that this group is not "groupMembership"
1135  if (string(itemName) != "field3d_group_membership" &&
1136  string(itemName) != "field3d_global_metadata")
1137  {
1138 
1139  // Get a pointer to the file data structure
1140  Field3DInputFile* fileObject = static_cast<Field3DInputFile*>(opdata);
1141  if (!fileObject) {
1142  return -1;
1143  }
1144 
1145  return fileObject->parsePartition(loc_id, itemName);
1146  }
1147  }
1148  return 0;
1149 }
boost::recursive_mutex::scoped_lock GlobalLock
Definition: Hdf5Util.h:78
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:434
FIELD3D_NAMESPACE_OPEN FIELD3D_API boost::recursive_mutex g_hdf5Mutex
Definition: Hdf5Util.cpp:67
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 1153 of file Field3DFile.cpp.

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

Referenced by Field3DInputFile::readPartitionAndLayerInfo().

1155 {
1156  GlobalLock lock(g_hdf5Mutex);
1157 
1158  herr_t status;
1159  H5O_info_t infobuf;
1160 
1161  status = H5Oget_info_by_name (loc_id, itemName, &infobuf, H5P_DEFAULT);
1162 
1163  if (infobuf.type == H5O_TYPE_GROUP) {
1164 
1165  // Check that we have a name
1166  if (!itemName)
1167  return -1;
1168 
1169  // Get a pointer to the file data structure
1170  ParseLayersInfo* info = static_cast<ParseLayersInfo*>(opdata);
1171  if (!info)
1172  return -1;
1173 
1174  // Open up the layer group
1175  H5ScopedGopen layerGroup(loc_id, itemName);
1176 
1177  // Check if it's a layer
1178  string classType;
1179  try {
1180  if (!readAttribute(layerGroup.id(), "class_type", classType)) {
1181  return 0;
1182  }
1183  if (classType == string("field3d_layer"))
1184  return info->file->parseLayer(layerGroup.id(), info->partitionName,
1185  itemName);
1186 
1187  }
1188  catch (MissingAttributeException &) {
1189 
1190  }
1191  return 0;
1192 
1193  }
1194 
1195  return 0;
1196 }
FIELD3D_API bool readAttribute(hid_t location, const std::string &attrName, std::string &value)
Reads a string attribute.
boost::recursive_mutex::scoped_lock GlobalLock
Definition: Hdf5Util.h:78
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.
FIELD3D_NAMESPACE_OPEN FIELD3D_API boost::recursive_mutex g_hdf5Mutex
Definition: Hdf5Util.cpp:67
struct used to pass the class and partition info back to the parseLayers() callback ...
Definition: Field3DFile.h:881
Field3DInputFile * file
Definition: Field3DFile.h:883
Scoped object - opens a group on creation and closes it on destruction.
Definition: Hdf5Util.h:194