MISR Toolkit  1.5.1
H5PacketTable.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group. *
3  * Copyright by the Board of Trustees of the University of Illinois. *
4  * All rights reserved. *
5  * *
6  * This file is part of HDF5. The full HDF5 copyright notice, including *
7  * terms governing use, modification, and redistribution, is contained in *
8  * the COPYING file, which can be found at the root of the source code *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10  * If you do not have access to either file, you may request a copy from *
11  * help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /* Packet Table wrapper classes
15  *
16  * Wraps the H5PT Packet Table C functions in C++ objects
17  *
18  * Nat Furrer and James Laird
19  * February 2004
20  */
21 
22 #ifndef H5PTWRAP_H
23 #define H5PTWRAP_H
24 
25 /* Public HDF5 header */
26 #include "hdf5.h"
27 
28 #include "H5PTpublic.h"
29 #include "H5api_adpt.h"
30 
32 {
33 public:
34  /* Null constructor
35  * Sets table_id to "invalid"
36  */
37  PacketTable() {table_id = H5I_BADID;}
38 
39  /* "Open" Constructor
40  * Opens an existing packet table, which can contain either fixed-length or
41  * variable-length packets.
42  */
43  PacketTable(hid_t fileID, const char* name);
44 
45  /* "Open" Constructor - will be deprecated because of char* name */
46  PacketTable(hid_t fileID, char* name);
47 
48  /* Destructor
49  * Cleans up the packet table
50  */
51  virtual ~PacketTable();
52 
53  /* IsValid
54  * Returns true if this packet table is valid, false otherwise.
55  * Use this after the constructor to ensure HDF did not have
56  * any trouble making or opening the packet table.
57  */
58  bool IsValid();
59 
60  /* IsVariableLength
61  * Return 1 if this packet table uses variable-length datatype,
62  * return 0 if it is Fixed Length. Returns -1 if the table is
63  * invalid (not open).
64  */
65  int IsVariableLength();
66 
67  /* ResetIndex
68  * Sets the "current packet" index to point to the first packet in the
69  * packet table
70  */
71  void ResetIndex();
72 
73  /* SetIndex
74  * Sets the current packet to point to the packet specified by index.
75  * Returns 0 on success, negative on failure (if index is out of bounds)
76  */
77  int SetIndex(hsize_t index);
78 
79  /* GetIndex
80  * Returns the position of the current packet.
81  * On failure, returns 0 and error is set to negative.
82  */
83  hsize_t GetIndex(int& error);
84 
85  /* GetPacketCount
86  * Returns the number of packets in the packet table. Error
87  * is set to 0 on success. On failure, returns 0 and
88  * error is set to negative.
89  */
90  hsize_t GetPacketCount(int& error);
91 
93  {
94  int ignoreError;
95  return GetPacketCount(ignoreError);
96  }
97 
98  /* GetTableId
99  * Returns the identifier of the packet table.
100  */
101  hid_t GetTableId();
102 
103  /* GetDatatype
104  * Returns the datatype identifier used by the packet table, on success,
105  * or FAIL, on failure.
106  * Note: it is best to avoid using this identifier in applications, unless
107  * the desired functionality cannot be performed via the packet table ID.
108  */
109  hid_t GetDatatype();
110 
111  /* GetDataset
112  * Returns the dataset identifier associated with the packet table, on
113  * success, or FAIL, on failure.
114  * Note: it is best to avoid using this identifier in applications, unless
115  * the desired functionality cannot be performed via the packet table ID.
116  */
117  hid_t GetDataset();
118 
119  /* FreeBuff
120  * Frees the buffers created when variable-length packets are read.
121  * Takes the number of hvl_t structs to be freed and a pointer to their
122  * location in memory.
123  * Returns 0 on success, negative on error.
124  */
125  int FreeBuff(size_t numStructs, hvl_t * buffer);
126 
127 protected:
129 };
130 
131 class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable
132 {
133 public:
134  /* Constructor
135  * Creates a packet table to store either fixed- or variable-length packets.
136  * Takes the ID of the file the packet table will be created in, the ID of
137  * the property list to specify compression, the name of the packet table,
138  * the ID of the datatype, and the size of a memory chunk used in chunking.
139  */
140  FL_PacketTable(hid_t fileID, const char* name, hid_t dtypeID, hsize_t chunkSize = 0, hid_t plistID = H5P_DEFAULT);
141 
142  /* Constructors - deprecated
143  * Creates a packet table in which to store fixed length packets.
144  * Takes the ID of the file the packet table will be created in, the name of
145  * the packet table, the ID of the datatype of the set, the size
146  * of a memory chunk used in chunking, and the desired compression level
147  * (0-9, or -1 for no compression).
148  * Note: these overloaded constructors will be deprecated in favor of the
149  * constructor above.
150  */
151  FL_PacketTable(hid_t fileID, hid_t plist_id, const char* name, hid_t dtypeID, hsize_t chunkSize);
152  FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression = 0);
153 
154  /* "Open" Constructor
155  * Opens an existing fixed-length packet table.
156  * Fails if the packet table specified is variable-length.
157  */
158  FL_PacketTable(hid_t fileID, const char* name);
159 
160  /* "Open" Constructor - will be deprecated because of char* name */
161  FL_PacketTable(hid_t fileID, char* name);
162 
163  /* Destructor
164  * Cleans up the packet table
165  */
166  virtual ~FL_PacketTable() {};
167 
168  /* AppendPacket
169  * Adds a single packet to the packet table. Takes a pointer
170  * to the location of the data in memory.
171  * Returns 0 on success, negative on failure
172  */
173  int AppendPacket(void * data);
174 
175  /* AppendPackets (multiple packets)
176  * Adds multiple packets to the packet table. Takes the number of packets
177  * to be added and a pointer to their location in memory.
178  * Returns 0 on success, -1 on failure.
179  */
180  int AppendPackets(size_t numPackets, void * data);
181 
182  /* GetPacket (indexed)
183  * Gets a single packet from the packet table. Takes the index
184  * of the packet (with 0 being the first packet) and a pointer
185  * to memory where the data should be stored.
186  * Returns 0 on success, negative on failure
187  */
188  int GetPacket(hsize_t index, void * data);
189 
190  /* GetPackets (multiple packets)
191  * Gets multiple packets at once, all packets between
192  * startIndex and endIndex inclusive. Also takes a pointer to
193  * the memory where these packets should be stored.
194  * Returns 0 on success, negative on failure.
195  */
196  int GetPackets(hsize_t startIndex, hsize_t endIndex, void * data);
197 
198  /* GetNextPacket (single packet)
199  * Gets the next packet in the packet table. Takes a pointer to
200  * memory where the packet should be stored.
201  * Returns 0 on success, negative on failure. Index
202  * is not advanced to the next packet on failure.
203  */
204  int GetNextPacket(void * data);
205 
206  /* GetNextPackets (multiple packets)
207  * Gets the next numPackets packets in the packet table. Takes a
208  * pointer to memory where these packets should be stored.
209  * Returns 0 on success, negative on failure. Index
210  * is not advanced on failure.
211  */
212  int GetNextPackets(size_t numPackets, void * data);
213 };
214 
215 /* Removed "#ifdef VLPT_REMOVED" block. 03/08/2016, -BMR */
216 
217 #endif /* H5PTWRAP_H */
#define H5_HLCPPDLL
Definition: H5api_adpt.h:266
unsigned long long hsize_t
Definition: H5public.h:169
#define H5P_DEFAULT
Definition: H5Ppublic.h:94
HDFFCLIBAPI intf intf intf intf void * buffer
HDFFCLIBAPI _fcd name
virtual ~FL_PacketTable()
int hid_t
Definition: H5Ipublic.h:54
hsize_t GetPacketCount()
Definition: H5PacketTable.h:92
HDFFCLIBAPI void * data
HDFFCLIBAPI intf * index

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:53