source: anuga_core/install/winxp/NetCDFWinInstaller/include/H5PacketTable.h @ 7310

Last change on this file since 7310 was 7310, checked in by rwilson, 15 years ago

Added the NetCDF Windows installer.

  • Property svn:executable set to *
File size: 8.6 KB
Line 
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 files COPYING and Copyright.html.  COPYING can be found at the root   *
9 * of the source code distribution tree; Copyright.html can be found at the  *
10 * root level of an installed copy of the electronic HDF5 document set and   *
11 * is linked from the top-level documents page.  It can also be found at     *
12 * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
13 * access to either file, you may request a copy from help@hdfgroup.org.     *
14 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15
16/* Packet Table wrapper classes
17 *
18 * Wraps the H5PT Packet Table C functions in C++ objects
19 *
20 * Nat Furrer and James Laird
21 * February 2004
22 */
23
24#ifndef H5PTWRAP_H
25#define H5PTWRAP_H
26
27/* Public HDF5 header */
28#include "hdf5.h"
29
30#include "H5PTpublic.h"
31#include "H5api_adpt.h"
32
33class H5_HLCPPDLL  PacketTable
34{
35public:
36    /* Null constructor
37     * Sets table_id to "invalid"
38     */
39    PacketTable() {table_id = H5I_BADID;}
40
41    /* "Open" Constructor
42     * Opens an existing packet table, which can contain either fixed-length or
43     * variable-length packets.
44     */
45    PacketTable(hid_t fileID, char* name);
46
47    /* Destructor
48     * Cleans up the packet table
49     */
50    ~PacketTable();
51
52    /* IsValid
53     * Returns true if this packet table is valid, false otherwise.
54     * Use this after the constructor to ensure HDF did not have
55     * any trouble making or opening the packet table.
56     */
57    bool IsValid();
58
59#ifdef VLPT_REMOVED
60    /* IsVariableLength
61     * Return 1 if this packet table is a Variable Length packet table,
62     * return 0 if it is Fixed Length.  Returns -1 if the table is
63     * invalid (not open).
64     */
65    int IsVariableLength();
66#endif /* VLPT_REMOVED */
67
68    /* ResetIndex
69     * Sets the "current packet" index to point to the first packet in the
70     * packet table
71     */
72    void ResetIndex();
73
74    /* SetIndex
75     * Sets the current packet to point to the packet specified by index.
76     * Returns 0 on success, negative on failure (if index is out of bounds)
77     */
78    int SetIndex(hsize_t index);
79
80    /* GetIndex
81     * Returns the position of the current packet.
82     * On failure, returns 0 and error is set to negative.
83     */
84    hsize_t GetIndex(int& error);
85
86    /* GetPacketCount
87     * Returns the number of packets in the packet table.  Error
88     * is set to 0 on success.  On failure, returns 0 and
89     * error is set to negative.
90     */
91    hsize_t GetPacketCount(int& error);
92
93    hsize_t GetPacketCount()
94    {
95        int ignoreError;
96        return GetPacketCount(ignoreError);
97    }
98
99protected:
100    hid_t table_id;
101};
102
103class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable
104{
105public:
106    /* Constructor
107     * Creates a packet table in which to store fixed length packets.
108     * Takes the ID of the file the packet table will be created in, the name of
109     * the packet table, the ID of the datatype of the set, the size
110     * of a memory chunk used in chunking, and the desired compression level
111     * (0-9, or -1 for no compression).
112     */
113    FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression = -1);
114
115    /* "Open" Constructor
116     * Opens an existing fixed-length packet table.
117     * Fails if the packet table specified is variable-length.
118     */
119    FL_PacketTable(hid_t fileID, char* name);
120
121    /* AppendPacket
122     * Adds a single packet to the packet table.  Takes a pointer
123     * to the location of the data in memory.
124     * Returns 0 on success, negative on failure
125     */
126    int AppendPacket(void * data);
127
128    /* AppendPackets (multiple packets)
129     * Adds multiple packets to the packet table.  Takes the number of packets
130     * to be added and a pointer to their location in memory.
131     * Returns 0 on success, -1 on failure.
132     */
133    int AppendPackets(size_t numPackets, void * data);
134
135    /* GetPacket (indexed)
136     * Gets a single packet from the packet table.  Takes the index
137     * of the packet (with 0 being the first packet) and a pointer
138     * to memory where the data should be stored.
139     * Returns 0 on success, negative on failure
140     */
141    int GetPacket(hsize_t index, void * data);
142
143    /* GetPackets (multiple packets)
144     * Gets multiple packets at once, all packets between
145     * startIndex and endIndex inclusive.  Also takes a pointer to
146     * the memory where these packets should be stored.
147     * Returns 0 on success, negative on failure.
148     */
149    int GetPackets(hsize_t startIndex, hsize_t endIndex, void * data);
150
151    /* GetNextPacket (single packet)
152     * Gets the next packet in the packet table.  Takes a pointer to
153     * memory where the packet should be stored.
154     * Returns 0 on success, negative on failure.  Index
155     * is not advanced to the next packet on failure.
156     */
157    int GetNextPacket(void * data);
158
159    /* GetNextPackets (multiple packets)
160     * Gets the next numPackets packets in the packet table.  Takes a
161     * pointer to memory where these packets should be stored.
162     * Returns 0 on success, negative on failure.  Index
163     * is not advanced on failure.
164     */
165    int GetNextPackets(size_t numPackets, void * data);
166};
167
168#ifdef VLPT_REMOVED
169class H5_HLCPPDLL  VL_PacketTable : virtual public PacketTable
170{
171public:
172    /* Constructor
173     * Creates a packet table in which to store variable length packets.
174     * Takes the ID of the file the packet table will be created in, the name of
175     * the packet table, and the size of a memory chunk used in chunking.
176     */
177    VL_PacketTable(hid_t fileID, char* name, hsize_t chunkSize);
178
179    /* "Open" Constructor
180     * Opens an existing variable-length packet table.
181     * Fails if the packet table specified is fixed-length.
182     */
183    VL_PacketTable(hid_t fileID, char* name);
184
185    /* AppendPacket
186     * Adds a single packet of any length to the packet table.
187     * Takes a pointer to the location of the data in memory and the length of the data
188     * in bytes.
189     * Returns 0 on success, negative on failure.
190     */
191    int AppendPacket(void * data, size_t length);
192
193    /* AppendPackets (multiple packets)
194     * Adds multiple variable-length packets to the packet table.  Takes the
195     * number of packets to be added and a pointer to an array of
196     * hvl_t structs in memory.
197     * Returns 0 on success, negative on failure.
198     */
199    int AppendPackets(size_t numPackets, hvl_t * data);
200
201    /* GetPacket (indexed)
202     * Gets a single variable-length packet from the packet table.  Takes
203     * the index of the packet (with 0 being the first packet) and a pointer
204     * to a hvl_t struct in which to store the packet's size and location.
205     * Returns 0 on success, negative on failure.
206     */
207    int GetPacket(hsize_t index, hvl_t * data);
208
209    /* GetPackets (multiple packets)
210     * Gets multiple variable-length packets at once, all packets between
211     * startIndex and endIndex inclusive.  Takes a pointer to an array
212     * of hvl_t structs in memory in which to store pointers to the packets.
213     * Returns 0 on success, negative on failure.
214     */
215    int GetPackets(hsize_t startIndex, hsize_t endIndex, hvl_t * data);
216
217    /* GetNextPacket (single packet)
218     * Gets the next packet in the packet table.  Takes a pointer to
219     * an hvl_t struct where the packet should be stored.
220     * Returns 0 on success, negative on failure.  Index
221     * is not advanced to the next packet on failure.
222     */
223    int GetNextPacket(hvl_t * data);
224
225    /* GetNextPackets (multiple packets)
226     * Gets the next numPackets packets in the packet table.  Takes a
227     * pointer to an array of hvl_t structs where pointers to the packets
228     * should be stored.
229     * Returns 0 on success, negative on failure.  Index
230     * is not advanced on failure.
231     */
232    int GetNextPackets(size_t numPackets, hvl_t * data);
233
234    /* FreeReadbuff
235     * Frees the buffers created when variable-length packets are read.
236     * Takes the number of hvl_t structs to be freed and a pointer to their
237     * location in memory.
238     * Returns 0 on success, negative on error.
239     */
240    int FreeReadbuff(size_t numStructs, hvl_t * buffer);
241};
242#endif /* VLPT_REMOVED */
243
244#endif /* H5PTWRAP_H */
Note: See TracBrowser for help on using the repository browser.