public static object GetObject(Hdf5Identifier _fileId, AbstractHdf5Object _parent, string _objectName) { Hdf5Path combinedPath = _parent.Path.Append(_objectName); object output = null; if (combinedPath != null) { string fullPath = combinedPath.FullPath; H5O.info_t gInfo = new H5O.info_t(); H5O.get_info_by_name(_fileId.Value, fullPath, ref gInfo); var id = H5O.open(_fileId.Value, fullPath).ToId(); if (id.Value > 0) { if (gInfo.type == H5O.type_t.DATASET) { output = DatasetHelper.LoadDataset(_fileId, id, fullPath); } if (gInfo.type == H5O.type_t.GROUP) { Hdf5Group group = new Hdf5Group(_fileId, id, fullPath); group.FileId = _fileId; group.LoadChildObjects(); output = group; } H5O.close(id.Value); } } return(output); }
/// <summary> /// Loads all attributes on an object into the supplied attributes collection. /// Assumes that the object is already open. /// </summary> /// <param name="_attributes"></param> public static void LoadAttributes( Hdf5Attributes _attributes) { ulong n = 0; AbstractHdf5Object obj = _attributes.ParentObject; int id = H5A.iterate(obj.Id.Value, H5.index_t.NAME, H5.iter_order_t.NATIVE, ref n, delegate(int _id, IntPtr _namePtr, ref H5A.info_t _ainfo, IntPtr _data) { string attributeName = Marshal.PtrToStringAnsi(_namePtr); var attributeId = H5A.open(_id, attributeName).ToId(); if (attributeId.Value > 0) { var attributeTypeId = H5A.get_type(attributeId.Value).ToId(); var type = TypeHelper.GetDataTypeByType(attributeTypeId); if (attributeTypeId.Value > 0) { Hdf5Attribute attribute = null; if (type.NativeType.Value == H5T.C_S1) { attribute = GetStringAttribute(obj.Id, attributeName); } else { attribute = GetAttribute(attributeId, attributeName, type); } if (attribute != null) { _attributes.Add(attribute); } H5T.close(attributeTypeId.Value); } H5A.close(attributeId.Value); } return(0); }, new IntPtr()); }