summaryrefslogtreecommitdiffstats
path: root/hl/c++/src
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2016-05-09 18:55:46 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2016-05-09 18:55:46 (GMT)
commit44640ecf685cfbd15fe176a1b96c6a7105288678 (patch)
treed812c113ba801562f0e9a607456bf8daa14a5c9e /hl/c++/src
parent45b57227d47476490cd720dc65e9c2fbfc94cd9f (diff)
parent57b7130acf69256ddaee7c6295a65c6ba16e3096 (diff)
downloadhdf5-44640ecf685cfbd15fe176a1b96c6a7105288678.zip
hdf5-44640ecf685cfbd15fe176a1b96c6a7105288678.tar.gz
hdf5-44640ecf685cfbd15fe176a1b96c6a7105288678.tar.bz2
[svn-r29903] merge from trunk.
Diffstat (limited to 'hl/c++/src')
-rw-r--r--hl/c++/src/CMakeLists.txt2
-rw-r--r--hl/c++/src/H5PacketTable.cpp204
-rw-r--r--hl/c++/src/H5PacketTable.h131
-rw-r--r--hl/c++/src/Makefile.am2
4 files changed, 124 insertions, 215 deletions
diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt
index e37c5ba..425a2fe 100644
--- a/hl/c++/src/CMakeLists.txt
+++ b/hl/c++/src/CMakeLists.txt
@@ -34,7 +34,7 @@ if (BUILD_SHARED_LIBS)
${HDF5_LIBSH_TARGET}
)
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_CPP_LIBSH_TARGET}")
- H5_SET_LIB_OPTIONS (${HDF5_HL_CPP_LIBSH_TARGET} ${HDF5_HL_CPP_LIB_NAME} SHARED)
+ H5_SET_LIB_OPTIONS (${HDF5_HL_CPP_LIBSH_TARGET} ${HDF5_HL_CPP_LIB_NAME} SHARED ${HDF5_HL_CXX_PACKAGE_SOVERSION})
set_target_properties (${HDF5_HL_CPP_LIBSH_TARGET} PROPERTIES
FOLDER libraries/hl
COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB"
diff --git a/hl/c++/src/H5PacketTable.cpp b/hl/c++/src/H5PacketTable.cpp
index 74b8029..50e11f6 100644
--- a/hl/c++/src/H5PacketTable.cpp
+++ b/hl/c++/src/H5PacketTable.cpp
@@ -34,6 +34,12 @@
* Opens an existing packet table, which can contain either fixed-length or
* variable-length packets.
*/
+ PacketTable::PacketTable(hid_t fileID, const char* name)
+ {
+ table_id = H5PTopen( fileID, name);
+ }
+
+ /* "Open" Constructor - will be deprecated because of char* name */
PacketTable::PacketTable(hid_t fileID, char* name)
{
table_id = H5PTopen( fileID, name);
@@ -60,17 +66,14 @@
return false;
}
-#ifdef VLPT_REMOVED
/* IsVariableLength
- * Return 1 if this packet table is a Variable Length packet table,
- * return 0 if it is Fixed Length. Returns -1 if the table is
- * invalid (not open).
+ * Return 1 if this packet table uses variable-length datatype,
+ * and 0, otherwise. Returns -1 if the table is invalid (not open).
*/
int PacketTable::IsVariableLength()
{
return H5PTis_varlen(table_id);
}
-#endif /* VLPT_REMOVED */
/* ResetIndex
* Sets the index to point to the first packet in the packet table
@@ -113,39 +116,87 @@
{
hsize_t npackets;
- error = H5PTget_num_packets( table_id, (hsize_t *)&npackets);
+ error = H5PTget_num_packets(table_id, &npackets);
return npackets;
}
+ /* GetTableId
+ * Returns the identifier of the packet table
+ */
+ hid_t PacketTable::GetTableId()
+ {
+ return table_id;
+ }
+
+ /* GetDatatype
+ * Returns the datatype identifier used by the packet table, on success,
+ * or FAIL, on failure.
+ * Note: it is best to avoid using this identifier in applications, unless
+ * the desired functionality cannot be performed via the packet table ID.
+ */
+ hid_t PacketTable::GetDatatype()
+ {
+ return H5PTget_type(table_id);
+ }
+
+ /* GetDataset
+ * Returns the dataset identifier associated with the packet table, on
+ * success, or FAIL, on failure.
+ * Note: it is best to avoid using this identifier in applications, unless
+ * the desired functionality cannot be performed via the packet table ID.
+ */
+ hid_t PacketTable::GetDataset()
+ {
+ return H5PTget_dataset(table_id);
+ }
+
+ /* FreeBuff
+ * Frees the buffers created when variable-length packets are read.
+ * Takes the number of hvl_t structs to be freed and a pointer to their
+ * location in memory.
+ * Returns 0 on success, negative on error.
+ */
+ int PacketTable::FreeBuff(size_t numStructs, hvl_t * buffer)
+ {
+ return H5PTfree_vlen_buff( table_id, numStructs, buffer);
+ }
+
+
/********************************/
/* Fixed-Length Packet Table */
/********************************/
/* Constructor
- * Creates a packet table in which to store fixed length packets.
+ * Creates a packet table to store either fixed- or variable-length packets.
+ * Takes the ID of the file the packet table will be created in, the ID of
+ * the property list to specify compression, the name of the packet table,
+ * the ID of the datatype, and the size of a memory chunk used in chunking.
+ */
+ FL_PacketTable::FL_PacketTable(hid_t fileID, hid_t plist_id, const char* name, hid_t dtypeID, hsize_t chunkSize)
+ {
+ table_id = H5PTcreate(fileID, name, dtypeID, chunkSize, plist_id);
+ }
+
+ /* Constructor
+ * Creates a packet table to store either fixed- or variable-length packets.
* Takes the ID of the file the packet table will be created in, the name of
* the packet table, the ID of the datatype of the set, and the size
* of a memory chunk used in chunking.
+ * Note: this overload will be deprecated in favor of the constructor above.
*/
FL_PacketTable::FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression)
{
- table_id = H5PTcreate_fl ( fileID, name, dtypeID, chunkSize, compression);
+ table_id = H5PTcreate_fl(fileID, name, dtypeID, chunkSize, compression);
}
/* "Open" Constructor
* Opens an existing fixed-length packet table.
* Fails if the packet table specified is variable-length.
*/
- FL_PacketTable::FL_PacketTable(hid_t fileID, char* name) : PacketTable(fileID, name)
- {
-#ifdef VLPT_REMOVED
- if( H5PTis_varlen(table_id) != 0 ) // If this is not a fixed-length table
- {
- H5PTclose(table_id);
- table_id = -1;
- }
-#endif /* VLPT_REMOVED */
- }
+ FL_PacketTable::FL_PacketTable(hid_t fileID, const char* name) : PacketTable(fileID, name) {}
+
+ /* "Open" Constructor - will be deprecated because of char* name */
+ FL_PacketTable::FL_PacketTable(hid_t fileID, char* name) : PacketTable(fileID, name) {}
/* AppendPacket
* Adds a single packet to the packet table. Takes a pointer
@@ -215,119 +266,4 @@
return H5PTget_next(table_id, numPackets, data);
}
-
-#ifdef VLPT_REMOVED
- /********************************/
- /* Variable-Length Packet Table */
- /********************************/
-
- /* Constructor
- * Creates a packet table in which to store variable length packets.
- * Takes the ID of the file the packet table will be created in, the name of
- * the packet table, and the size of a memory chunk used in chunking.
- */
- VL_PacketTable::VL_PacketTable(hid_t fileID, char* name, hsize_t chunkSize)
- {
- table_id = H5PTcreate_vl ( fileID, name, chunkSize);
- }
-
- /* "Open" Constructor
- * Opens an existing variable-length packet table.
- * Fails if the packet table specified is fixed-length.
- */
- VL_PacketTable::VL_PacketTable(hid_t fileID, char* name) : PacketTable(fileID, name)
- {
- if( H5PTis_varlen(table_id) != 1 ) // If this is not a variable-length table
- {
- H5PTclose(table_id);
- table_id = -1;
- }
- }
-
- /* AppendPacket (variable-length)
- * Adds a single variable-length packet to the packet table.
- * Takes a pointer to the location of the data in memory and the length of the data
- * in bytes.
- * Returns 0 on success, negative on failure.
- */
- int VL_PacketTable::AppendPacket(void * data, size_t length)
- {
- hvl_t packet;
-
- packet.len = length;
- packet.p = data;
-
- return H5PTappend(table_id, 1, &packet);
- }
-
- /* AppendPackets (multiple packets)
- * Adds multiple variable-length packets to the packet table. Takes the
- * number of
- * packets to be added and a pointer to an array of hvl_t structs in memory.
- * Returns 0 on success, negative on failure.
- */
- int VL_PacketTable::AppendPackets(size_t numPackets, hvl_t * data)
- {
- return H5PTappend(table_id, numPackets, data);
- }
-
- /* GetPacket (indexed)
- * Gets a single variable-length packet from the packet table. Takes the
- * index of the packet (with 0 being the first packet) and a pointer
- * to a hvl_t struct in which to store the packet's size and location.
- * Returns 0 on success, negative on failure.
- */
- int VL_PacketTable::GetPacket(hsize_t index, hvl_t * data)
- {
- return H5PTread_packets(table_id, index, 1, data);
- }
-
- /* GetPackets (multiple packets)
- * Gets multiple variable-length packets at once, all packets between
- * startIndex and endIndex inclusive. Takes a pointer to an array
- * of hvl_t structs in memory in which to store pointers to the packets.
- * Returns 0 on success, negative on failure.
- */
- int VL_PacketTable::GetPackets(hsize_t startIndex, hsize_t endIndex, hvl_t * data)
- {
- // Make sure the range of indexes is valid
- if (startIndex > endIndex)
- return -1;
-
- return H5PTread_packets(table_id, startIndex, endIndex-startIndex+1, data);
- }
-
- /* GetNextPacket (single packet)
- * Gets the next packet in the packet table. Takes a pointer to
- * an hvl_t struct where the packet should be stored.
- * Returns 0 on success, negative on failure. Index
- * is not advanced to the next packet on failure.
- */
- int VL_PacketTable::GetNextPacket(hvl_t * data)
- {
- return H5PTget_next(table_id, 1, data);
- }
-
- /* GetNextPackets (multiple packets)
- * Gets the next numPackets packets in the packet table. Takes a
- * pointer to an array of hvl_t structs where pointers to the packets
- * should be stored.
- * Returns 0 on success, negative on failure. Index
- * is not advanced on failure.
- */
- int VL_PacketTable::GetNextPackets(size_t numPackets, hvl_t * data)
- {
- return H5PTget_next(table_id, numPackets, data);
- }
-
- /* FreeReadbuff
- * Frees the buffers created when variable-length packets are read.
- * Takes the number of hvl_t structs to be freed and a pointer to their
- * location in memory.
- * Returns 0 on success, negative on error.
- */
- int VL_PacketTable::FreeReadbuff(size_t numStructs, hvl_t * buffer)
- {
- return H5PTfree_vlen_readbuff( table_id, numStructs, buffer);
- }
-#endif /* VLPT_REMOVED */
+/* Removed "ifdef VLPT_REMOVED" block. 03/08/2016, -BMR */
diff --git a/hl/c++/src/H5PacketTable.h b/hl/c++/src/H5PacketTable.h
index 5f9a213..bdd669d 100644
--- a/hl/c++/src/H5PacketTable.h
+++ b/hl/c++/src/H5PacketTable.h
@@ -42,12 +42,15 @@ public:
* Opens an existing packet table, which can contain either fixed-length or
* variable-length packets.
*/
+ PacketTable(hid_t fileID, const char* name);
+
+ /* "Open" Constructor - will be deprecated because of char* name */
PacketTable(hid_t fileID, char* name);
/* Destructor
* Cleans up the packet table
*/
- ~PacketTable();
+ virtual ~PacketTable();
/* IsValid
* Returns true if this packet table is valid, false otherwise.
@@ -56,14 +59,12 @@ public:
*/
bool IsValid();
-#ifdef VLPT_REMOVED
/* IsVariableLength
- * Return 1 if this packet table is a Variable Length packet table,
+ * Return 1 if this packet table uses variable-length datatype,
* return 0 if it is Fixed Length. Returns -1 if the table is
* invalid (not open).
*/
int IsVariableLength();
-#endif /* VLPT_REMOVED */
/* ResetIndex
* Sets the "current packet" index to point to the first packet in the
@@ -96,6 +97,35 @@ public:
return GetPacketCount(ignoreError);
}
+ /* GetTableId
+ * Returns the identifier of the packet table.
+ */
+ hid_t GetTableId();
+
+ /* GetDatatype
+ * Returns the datatype identifier used by the packet table, on success,
+ * or FAIL, on failure.
+ * Note: it is best to avoid using this identifier in applications, unless
+ * the desired functionality cannot be performed via the packet table ID.
+ */
+ hid_t GetDatatype();
+
+ /* GetDataset
+ * Returns the dataset identifier associated with the packet table, on
+ * success, or FAIL, on failure.
+ * Note: it is best to avoid using this identifier in applications, unless
+ * the desired functionality cannot be performed via the packet table ID.
+ */
+ hid_t GetDataset();
+
+ /* FreeBuff
+ * Frees the buffers created when variable-length packets are read.
+ * Takes the number of hvl_t structs to be freed and a pointer to their
+ * location in memory.
+ * Returns 0 on success, negative on error.
+ */
+ int FreeBuff(size_t numStructs, hvl_t * buffer);
+
protected:
hid_t table_id;
};
@@ -104,11 +134,20 @@ class H5_HLCPPDLL FL_PacketTable : virtual public PacketTable
{
public:
/* Constructor
+ * Creates a packet table to store either fixed- or variable-length packets.
+ * Takes the ID of the file the packet table will be created in, the ID of
+ * the property list to specify compression, the name of the packet table,
+ * the ID of the datatype, and the size of a memory chunk used in chunking.
+ */
+ FL_PacketTable(hid_t fileID, hid_t plist_id, const char* name, hid_t dtypeID, hsize_t chunkSize);
+
+ /* Constructor
* Creates a packet table in which to store fixed length packets.
* Takes the ID of the file the packet table will be created in, the name of
* the packet table, the ID of the datatype of the set, the size
* of a memory chunk used in chunking, and the desired compression level
* (0-9, or -1 for no compression).
+ * Note: this overload will be deprecated in favor of the constructor above.
*/
FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, int compression = -1);
@@ -116,8 +155,16 @@ public:
* Opens an existing fixed-length packet table.
* Fails if the packet table specified is variable-length.
*/
+ FL_PacketTable(hid_t fileID, const char* name);
+
+ /* "Open" Constructor - will be deprecated because of char* name */
FL_PacketTable(hid_t fileID, char* name);
+ /* Destructor
+ * Cleans up the packet table
+ */
+ virtual ~FL_PacketTable() {};
+
/* AppendPacket
* Adds a single packet to the packet table. Takes a pointer
* to the location of the data in memory.
@@ -165,80 +212,6 @@ public:
int GetNextPackets(size_t numPackets, void * data);
};
-#ifdef VLPT_REMOVED
-class H5_HLCPPDLL VL_PacketTable : virtual public PacketTable
-{
-public:
- /* Constructor
- * Creates a packet table in which to store variable length packets.
- * Takes the ID of the file the packet table will be created in, the name of
- * the packet table, and the size of a memory chunk used in chunking.
- */
- VL_PacketTable(hid_t fileID, char* name, hsize_t chunkSize);
-
- /* "Open" Constructor
- * Opens an existing variable-length packet table.
- * Fails if the packet table specified is fixed-length.
- */
- VL_PacketTable(hid_t fileID, char* name);
-
- /* AppendPacket
- * Adds a single packet of any length to the packet table.
- * Takes a pointer to the location of the data in memory and the length of the data
- * in bytes.
- * Returns 0 on success, negative on failure.
- */
- int AppendPacket(void * data, size_t length);
-
- /* AppendPackets (multiple packets)
- * Adds multiple variable-length packets to the packet table. Takes the
- * number of packets to be added and a pointer to an array of
- * hvl_t structs in memory.
- * Returns 0 on success, negative on failure.
- */
- int AppendPackets(size_t numPackets, hvl_t * data);
-
- /* GetPacket (indexed)
- * Gets a single variable-length packet from the packet table. Takes
- * the index of the packet (with 0 being the first packet) and a pointer
- * to a hvl_t struct in which to store the packet's size and location.
- * Returns 0 on success, negative on failure.
- */
- int GetPacket(hsize_t index, hvl_t * data);
-
- /* GetPackets (multiple packets)
- * Gets multiple variable-length packets at once, all packets between
- * startIndex and endIndex inclusive. Takes a pointer to an array
- * of hvl_t structs in memory in which to store pointers to the packets.
- * Returns 0 on success, negative on failure.
- */
- int GetPackets(hsize_t startIndex, hsize_t endIndex, hvl_t * data);
-
- /* GetNextPacket (single packet)
- * Gets the next packet in the packet table. Takes a pointer to
- * an hvl_t struct where the packet should be stored.
- * Returns 0 on success, negative on failure. Index
- * is not advanced to the next packet on failure.
- */
- int GetNextPacket(hvl_t * data);
-
- /* GetNextPackets (multiple packets)
- * Gets the next numPackets packets in the packet table. Takes a
- * pointer to an array of hvl_t structs where pointers to the packets
- * should be stored.
- * Returns 0 on success, negative on failure. Index
- * is not advanced on failure.
- */
- int GetNextPackets(size_t numPackets, hvl_t * data);
-
- /* FreeReadbuff
- * Frees the buffers created when variable-length packets are read.
- * Takes the number of hvl_t structs to be freed and a pointer to their
- * location in memory.
- * Returns 0 on success, negative on error.
- */
- int FreeReadbuff(size_t numStructs, hvl_t * buffer);
-};
-#endif /* VLPT_REMOVED */
+/* Removed "#ifdef VLPT_REMOVED" block. 03/08/2016, -BMR */
#endif /* H5PTWRAP_H */
diff --git a/hl/c++/src/Makefile.am b/hl/c++/src/Makefile.am
index b268948..c78f5fa 100644
--- a/hl/c++/src/Makefile.am
+++ b/hl/c++/src/Makefile.am
@@ -28,7 +28,7 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/hl/src
lib_LTLIBRARIES=libhdf5_hl_cpp.la
# Add libtool numbers to the HDF5 HL C++ library (from config/lt_vers.am)
-libhdf5_hl_cpp_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) $(AM_LDFLAGS)
+libhdf5_hl_cpp_la_LDFLAGS= -version-info $(LT_HL_CXX_VERS_INTERFACE):$(LT_HL_CXX_VERS_REVISION):$(LT_HL_CXX_VERS_AGE) $(AM_LDFLAGS)
# Source files for the library
# At the moment, only the H5PT Packet Table has a C++ API.