private H5File(H5Context context, H5NamedReference reference, ObjectHeader header, string absoluteFilePath, bool deleteOnClose) : base(context, reference, header) { this.Path = absoluteFilePath; _deleteOnClose = deleteOnClose; }
internal H5Group(H5File file, H5Context context, H5NamedReference reference, ObjectHeader header) : base(context, reference, header) { _file = file; }
internal bool TryGetReference(H5ObjectReference reference, HashSet <ulong> alreadyVisited, H5LinkAccess linkAccess, int recursionLevel, out H5NamedReference namedReference) { // similar to H5Gint.c (H5G_visit) if (recursionLevel >= 100) { throw new Exception("Too much recursion."); } bool skip = false; namedReference = default; /* If its ref count is > 1, we add it to the list of visited objects * (because it could come up again during traversal) */ if (this.ReferenceCount > 1) { if (alreadyVisited.Contains(this.Reference.Value)) { skip = true; } else { alreadyVisited.Add(this.Reference.Value); } } if (!skip) { var references = this .EnumerateReferences(linkAccess) .ToList(); namedReference = references .FirstOrDefault(current => current.Value == reference.Value); if (namedReference.Name != null /* if struct value is not equal to default */) { return(true); } else { // search childs for reference foreach (var childReference in references) { var group = childReference.Dereference() as H5Group; if (group != null) { if (group.TryGetReference(reference, alreadyVisited, linkAccess, recursionLevel + 1, out namedReference)) { return(true); } } } } } return(false); }
internal H5Group(H5File file, H5Context context, H5NamedReference reference) : base(context, reference) { _file = file; _scratchPad = reference.ScratchPad; }
// Only for H5File constructor internal H5Group(H5Context context, H5NamedReference reference, ObjectHeader header) : base(context, reference, header) { // }
private bool TryGetReference(string name, H5LinkAccess linkAccess, out H5NamedReference namedReference) { namedReference = default; /* cached data */ if (_scratchPad != null) { var localHeap = _scratchPad.LocalHeap; this.Context.Reader.Seek((long)_scratchPad.BTree1Address, SeekOrigin.Begin); var tree = new BTree1Node <BTree1GroupKey>(this.Context.Reader, this.Context.Superblock, this.DecodeGroupKey); var b = tree.EnumerateNodes().ToList(); this.Context.Reader.Seek((long)_scratchPad.NameHeapAddress, SeekOrigin.Begin); var heap = new LocalHeap(this.Context.Reader, this.Context.Superblock); var c = heap.GetObjectName(0); var success = _scratchPad .GetBTree1(this.DecodeGroupKey) .TryFindUserData(out var userData, (leftKey, rightKey) => this.NodeCompare3(localHeap, name, leftKey, rightKey), (ulong address, out BTree1SymbolTableUserData userData) => this.NodeFound(localHeap, name, address, out userData)); if (success) { namedReference = this.GetObjectReferencesForSymbolTableEntry(localHeap, userData.SymbolTableEntry, linkAccess); return(true); } } else { var symbolTableHeaderMessages = this.Header.GetMessages <SymbolTableMessage>(); if (symbolTableHeaderMessages.Any()) { /* Original approach. * IV.A.2.r.: The Symbol Table Message * Required for "old style" groups; may not be repeated. */ if (symbolTableHeaderMessages.Count() != 1) { throw new Exception("There may be only a single symbol table header message."); } var smessage = symbolTableHeaderMessages.First(); var localHeap = smessage.LocalHeap; var success = smessage .GetBTree1(this.DecodeGroupKey) .TryFindUserData(out var userData, (leftKey, rightKey) => this.NodeCompare3(localHeap, name, leftKey, rightKey), (ulong address, out BTree1SymbolTableUserData userData) => this.NodeFound(localHeap, name, address, out userData)); if (success) { namedReference = this.GetObjectReferencesForSymbolTableEntry(localHeap, userData.SymbolTableEntry, linkAccess); return(true); } } else { var linkInfoMessages = this.Header.GetMessages <LinkInfoMessage>(); if (linkInfoMessages.Any()) { if (linkInfoMessages.Count() != 1) { throw new Exception("There may be only a single link info message."); } var lmessage = linkInfoMessages.First(); /* New (1.8) indexed format (in combination with Group Info Message) * IV.A.2.c. The Link Info Message * Optional; may not be repeated. */ if (!this.Context.Superblock.IsUndefinedAddress(lmessage.BTree2NameIndexAddress)) { if (this.TryGetLinkMessageFromLinkInfoMessage(lmessage, name, out var linkMessage)) { namedReference = this.GetObjectReference(linkMessage, linkAccess); return(true); } } /* New (1.8) compact format * IV.A.2.g. The Link Message * A group is storing its links compactly when the fractal heap address * in the Link Info Message is set to the "undefined address" value. */ else { var linkMessage = this.Header .GetMessages <LinkMessage>() .FirstOrDefault(message => message.LinkName == name); if (linkMessage != null) { namedReference = this.GetObjectReference(linkMessage, linkAccess); return(true); } } } else { throw new Exception("No link information found in object header."); } } } return(false); }
internal H5AttributableObject(H5Context context, H5NamedReference reference) : base(context, reference) { // }
internal H5AttributableObject(H5Context context, H5NamedReference reference, ObjectHeader header) : base(context, reference, header) { // }
internal H5Dataset(H5Context context, H5NamedReference reference, ObjectHeader header) : base(context, reference, header) { foreach (var message in this.Header.HeaderMessages) { var type = message.Data.GetType(); if (typeof(DataLayoutMessage).IsAssignableFrom(type)) { this.DataLayout = (DataLayoutMessage)message.Data; } else if (type == typeof(DataspaceMessage)) { this.Dataspace = (DataspaceMessage)message.Data; } else if (type == typeof(DatatypeMessage)) { this.Datatype = (DatatypeMessage)message.Data; } else if (type == typeof(FillValueMessage)) { this.FillValue = (FillValueMessage)message.Data; } else if (type == typeof(FilterPipelineMessage)) { this.FilterPipeline = (FilterPipelineMessage)message.Data; } else if (type == typeof(ObjectModificationMessage)) { this.ObjectModification = (ObjectModificationMessage)message.Data; } else if (type == typeof(ExternalFileListMessage)) { this.ExternalFileList = (ExternalFileListMessage)message.Data; } } // check that required fields are set if (this.DataLayout == null) { throw new Exception("The data layout message is missing."); } if (this.Dataspace == null) { throw new Exception("The dataspace message is missing."); } if (this.Datatype == null) { throw new Exception("The data type message is missing."); } if (this.FillValue == null) { throw new Exception("The fill value message is missing."); } }
internal H5Object(H5Context context, H5NamedReference reference, ObjectHeader header) { this.Context = context; this.Reference = reference; _header = header; }
internal H5Object(H5Context context, H5NamedReference reference) { this.Context = context; this.Reference = reference; }
internal H5CommitedDatatype(H5Context context, ObjectHeader header, H5NamedReference reference) : base(context, reference, header) { this.Datatype = header.GetMessage <DatatypeMessage>(); }
internal H5UnresolvedLink(H5NamedReference reference) : base(default, reference) { this.Reason = reference.Exception; }