summaryrefslogtreecommitdiffstats
path: root/c++/src/H5IdComponent.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2017-04-11 19:44:31 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2017-04-11 19:44:31 (GMT)
commitbee3ca742946eff20f64e35048dc00429b99e362 (patch)
tree32b6f476e2783c1c306d8a1b7d406b5f861465b1 /c++/src/H5IdComponent.cpp
parent1f2db88a88be64145e4fbb6d6c48fa754613034b (diff)
downloadhdf5-bee3ca742946eff20f64e35048dc00429b99e362.zip
hdf5-bee3ca742946eff20f64e35048dc00429b99e362.tar.gz
hdf5-bee3ca742946eff20f64e35048dc00429b99e362.tar.bz2
Description:
Only format changes: mostly tabs vs. spaces Platforms tested: Linux/64 (jelly)
Diffstat (limited to 'c++/src/H5IdComponent.cpp')
-rw-r--r--c++/src/H5IdComponent.cpp266
1 files changed, 133 insertions, 133 deletions
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp
index d71c953..67b2e11 100644
--- a/c++/src/H5IdComponent.cpp
+++ b/c++/src/H5IdComponent.cpp
@@ -20,7 +20,7 @@
#include "H5Library.h"
#include "H5IdComponent.h"
#include "H5DataSpace.h"
-#include "H5private.h" // for HDmemset
+#include "H5private.h" // for HDmemset
namespace H5 {
@@ -36,21 +36,21 @@ bool IdComponent::H5dontAtexit_called = false;
#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
-// Function: IdComponent::incRefCount
-///\brief Increment reference counter for a given id.
-// Programmer Binh-Minh Ribler - May 2005
+// Function: IdComponent::incRefCount
+///\brief Increment reference counter for a given id.
+// Programmer Binh-Minh Ribler - May 2005
//--------------------------------------------------------------------------
void IdComponent::incRefCount(const hid_t obj_id) const
{
if (p_valid_id(obj_id))
- if (H5Iinc_ref(obj_id) < 0)
- throw IdComponentException(inMemFunc("incRefCount"), "incrementing object ref count failed");
+ if (H5Iinc_ref(obj_id) < 0)
+ throw IdComponentException(inMemFunc("incRefCount"), "incrementing object ref count failed");
}
//--------------------------------------------------------------------------
-// Function: IdComponent::incRefCount
-///\brief Increment reference counter for the id of this object.
-// Programmer Binh-Minh Ribler - 2000
+// Function: IdComponent::incRefCount
+///\brief Increment reference counter for the id of this object.
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void IdComponent::incRefCount() const
{
@@ -58,31 +58,31 @@ void IdComponent::incRefCount() const
}
//--------------------------------------------------------------------------
-// Function: IdComponent::decRefCount
-///\brief Decrement reference counter for a given id.
-// Programmer Binh-Minh Ribler - May 2005
+// Function: IdComponent::decRefCount
+///\brief Decrement reference counter for a given id.
+// Programmer Binh-Minh Ribler - May 2005
// Modification:
-// Added the check for ref counter to give a little more info
-// on why H5Idec_ref fails in some cases - BMR 5/19/2005
+// Added the check for ref counter to give a little more info
+// on why H5Idec_ref fails in some cases - BMR 5/19/2005
//--------------------------------------------------------------------------
void IdComponent::decRefCount(const hid_t obj_id) const
{
if (p_valid_id(obj_id))
- if (H5Idec_ref(obj_id) < 0)
- {
- if (H5Iget_ref(obj_id) <= 0)
- throw IdComponentException(inMemFunc("decRefCount"),
- "object ref count is 0 or negative");
- else
- throw IdComponentException(inMemFunc("decRefCount"),
- "decrementing object ref count failed");
- }
+ if (H5Idec_ref(obj_id) < 0)
+ {
+ if (H5Iget_ref(obj_id) <= 0)
+ throw IdComponentException(inMemFunc("decRefCount"),
+ "object ref count is 0 or negative");
+ else
+ throw IdComponentException(inMemFunc("decRefCount"),
+ "decrementing object ref count failed");
+ }
}
//--------------------------------------------------------------------------
-// Function: IdComponent::decRefCount
-///\brief Decrement reference counter for the id of this object.
-// Programmer Binh-Minh Ribler - 2000
+// Function: IdComponent::decRefCount
+///\brief Decrement reference counter for the id of this object.
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void IdComponent::decRefCount() const
{
@@ -90,28 +90,28 @@ void IdComponent::decRefCount() const
}
//--------------------------------------------------------------------------
-// Function: IdComponent::getCounter
-///\brief Returns the reference counter for a given id.
-///\return Reference count
-// Programmer Binh-Minh Ribler - May 2005
+// Function: IdComponent::getCounter
+///\brief Returns the reference counter for a given id.
+///\return Reference count
+// Programmer Binh-Minh Ribler - May 2005
//--------------------------------------------------------------------------
int IdComponent::getCounter(const hid_t obj_id) const
{
int counter = 0;
if (p_valid_id(obj_id))
{
- counter = H5Iget_ref(obj_id);
- if (counter < 0)
- throw IdComponentException(inMemFunc("incRefCount"), "getting object ref count failed - negative");
+ counter = H5Iget_ref(obj_id);
+ if (counter < 0)
+ throw IdComponentException(inMemFunc("incRefCount"), "getting object ref count failed - negative");
}
return (counter);
}
//--------------------------------------------------------------------------
-// Function: IdComponent::getCounter
-///\brief Returns the reference counter for the id of this object.
-///\return Reference count
-// Programmer Binh-Minh Ribler - 2000
+// Function: IdComponent::getCounter
+///\brief Returns the reference counter for the id of this object.
+///\return Reference count
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
int IdComponent::getCounter() const
{
@@ -119,43 +119,43 @@ int IdComponent::getCounter() const
}
//--------------------------------------------------------------------------
-// Function: getHDFObjType (static)
-///\brief Given an id, returns the type of the object.
-///\return a valid HDF object type, which may be one of the following:
-/// \li \c H5I_FILE
-/// \li \c H5I_GROUP
-/// \li \c H5I_DATATYPE
-/// \li \c H5I_DATASPACE
-/// \li \c H5I_DATASET
-/// \li \c H5I_ATTR
-/// \li or \c H5I_BADID, if no valid type can be determined or the
-/// input object id is invalid.
+// Function: getHDFObjType (static)
+///\brief Given an id, returns the type of the object.
+///\return a valid HDF object type, which may be one of the following:
+/// \li \c H5I_FILE
+/// \li \c H5I_GROUP
+/// \li \c H5I_DATATYPE
+/// \li \c H5I_DATASPACE
+/// \li \c H5I_DATASET
+/// \li \c H5I_ATTR
+/// \li or \c H5I_BADID, if no valid type can be determined or the
+/// input object id is invalid.
// Programmer Binh-Minh Ribler - Jul, 2005
//--------------------------------------------------------------------------
H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id)
{
if (obj_id <= 0)
- return H5I_BADID; // invalid
+ return H5I_BADID; // invalid
H5I_type_t id_type = H5Iget_type(obj_id);
if (id_type <= H5I_BADID || id_type >= H5I_NTYPES)
- return H5I_BADID; // invalid
+ return H5I_BADID; // invalid
else
- return id_type; // valid type
+ return id_type; // valid type
}
//--------------------------------------------------------------------------
-// Function: getHDFObjType
-///\brief Returns the type of the object. It is an overloaded function
-/// of the above function.
-///\return a valid HDF object type, which may be one of the following:
-/// \li \c H5I_FILE
-/// \li \c H5I_GROUP
-/// \li \c H5I_DATATYPE
-/// \li \c H5I_DATASPACE
-/// \li \c H5I_DATASET
-/// \li \c H5I_ATTR
-/// \li or \c H5I_BADID, if no valid type can be determined or the
-/// input object id is invalid.
+// Function: getHDFObjType
+///\brief Returns the type of the object. It is an overloaded function
+/// of the above function.
+///\return a valid HDF object type, which may be one of the following:
+/// \li \c H5I_FILE
+/// \li \c H5I_GROUP
+/// \li \c H5I_DATATYPE
+/// \li \c H5I_DATASPACE
+/// \li \c H5I_DATASET
+/// \li \c H5I_ATTR
+/// \li or \c H5I_BADID, if no valid type can be determined or the
+/// input object id is invalid.
// Programmer Binh-Minh Ribler - Mar, 2014
//--------------------------------------------------------------------------
H5I_type_t IdComponent::getHDFObjType() const
@@ -164,60 +164,60 @@ H5I_type_t IdComponent::getHDFObjType() const
}
//--------------------------------------------------------------------------
-// Function: IdComponent::operator=
-///\brief Assignment operator.
-///\param rhs - IN: Reference to the existing object
-///\return Reference to IdComponent instance
-///\exception H5::IdComponentException when attempt to close the HDF5
-/// object fails
+// Function: IdComponent::operator=
+///\brief Assignment operator.
+///\param rhs - IN: Reference to the existing object
+///\return Reference to IdComponent instance
+///\exception H5::IdComponentException when attempt to close the HDF5
+/// object fails
// Description
-// First, close the current valid id of this object. Then
-// copy the id from rhs to this object, and increment the
-// reference counter of the id to indicate that another object
-// is referencing that id.
+// First, close the current valid id of this object. Then
+// copy the id from rhs to this object, and increment the
+// reference counter of the id to indicate that another object
+// is referencing that id.
// Modification
-// 2010/5/9 - BMR
-// Removed close() and incRefCount() because setId/p_setId takes
-// care of close() and setId takes care incRefCount().
-// Programmer Binh-Minh Ribler - 2000
+// 2010/5/9 - BMR
+// Removed close() and incRefCount() because setId/p_setId takes
+// care of close() and setId takes care incRefCount().
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
IdComponent& IdComponent::operator=( const IdComponent& rhs )
{
if (this != &rhs)
{
- // handling references to this id
- try {
- setId(rhs.getId());
- // Note: a = b, so there are two objects with the same hdf5 id
- // that's why incRefCount is needed, and it is called by setId
- }
- catch (Exception& close_error) {
- throw FileIException(inMemFunc("operator="), close_error.getDetailMsg());
- }
+ // handling references to this id
+ try {
+ setId(rhs.getId());
+ // Note: a = b, so there are two objects with the same hdf5 id
+ // that's why incRefCount is needed, and it is called by setId
+ }
+ catch (Exception& close_error) {
+ throw FileIException(inMemFunc("operator="), close_error.getDetailMsg());
+ }
}
return *this;
}
//--------------------------------------------------------------------------
-// Function: IdComponent::setId
-///\brief Sets the identifier of this object to a new value.
-///\param new_id - IN: New identifier to be set to
-///\exception H5::IdComponentException when the attempt to close the HDF5
-/// object fails
+// Function: IdComponent::setId
+///\brief Sets the identifier of this object to a new value.
+///\param new_id - IN: New identifier to be set to
+///\exception H5::IdComponentException when the attempt to close the HDF5
+/// object fails
// Description:
-// p_setId ensures that the current valid id of this object is
-// properly closed before resetting the object's id to the new id.
-// Programmer Binh-Minh Ribler - 2000
+// p_setId ensures that the current valid id of this object is
+// properly closed before resetting the object's id to the new id.
+// Programmer Binh-Minh Ribler - 2000
// Modification
-// 2008/7/23 - BMR
-// Changed all subclasses' setId to p_setId and put back setId
-// here. p_setId is used in the library where the id provided
-// by a C API passed on to user's application in the form of a
-// C++ API object, which will be destroyed properly, and so
-// p_setId does not call incRefCount. On the other hand, the
-// public version setId is used by other applications, in which
-// the id passed to setId is that of another C++ API object, so
-// setId must call incRefCount.
+// 2008/7/23 - BMR
+// Changed all subclasses' setId to p_setId and put back setId
+// here. p_setId is used in the library where the id provided
+// by a C API passed on to user's application in the form of a
+// C++ API object, which will be destroyed properly, and so
+// p_setId does not call incRefCount. On the other hand, the
+// public version setId is used by other applications, in which
+// the id passed to setId is that of another C++ API object, so
+// setId must call incRefCount.
//--------------------------------------------------------------------------
void IdComponent::setId(const hid_t new_id)
{
@@ -229,9 +229,9 @@ void IdComponent::setId(const hid_t new_id)
}
//--------------------------------------------------------------------------
-// Function: IdComponent destructor
-///\brief Noop destructor.
-// Programmer Binh-Minh Ribler - 2000
+// Function: IdComponent destructor
+///\brief Noop destructor.
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
IdComponent::~IdComponent() {}
@@ -242,16 +242,16 @@ IdComponent::~IdComponent() {}
#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
-// Function: IdComponent::inMemFunc
-///\brief Makes and returns string "<class-name>::<func_name>"
-///\param func_name - Name of the function where failure occurs
+// Function: IdComponent::inMemFunc
+///\brief Makes and returns string "<class-name>::<func_name>"
+///\param func_name - Name of the function where failure occurs
// Description
-/// Concatenates the class name of this object with the
-/// passed-in function name to create a string that indicates
-/// where the failure occurs. The class-name is provided by
-/// fromClass(). This string will be used by a base class when
-/// an exception is thrown.
-// Programmer Binh-Minh Ribler - Aug 6, 2005
+/// Concatenates the class name of this object with the
+/// passed-in function name to create a string that indicates
+/// where the failure occurs. The class-name is provided by
+/// fromClass(). This string will be used by a base class when
+/// an exception is thrown.
+// Programmer Binh-Minh Ribler - Aug 6, 2005
//--------------------------------------------------------------------------
H5std_string IdComponent::inMemFunc(const char* func_name) const
{
@@ -262,9 +262,9 @@ H5std_string IdComponent::inMemFunc(const char* func_name) const
}
//--------------------------------------------------------------------------
-// Function: IdComponent default constructor - private
-///\brief Default constructor.
-// Programmer Binh-Minh Ribler - 2000
+// Function: IdComponent default constructor - private
+///\brief Default constructor.
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
IdComponent::IdComponent()
{
@@ -278,14 +278,14 @@ IdComponent::IdComponent()
}
//--------------------------------------------------------------------------
-// Function: IdComponent::p_get_file_name (protected)
-// Purpose: Gets the name of the file, in which this object belongs.
-// Exception: H5::IdComponentException
+// Function: IdComponent::p_get_file_name (protected)
+// Purpose: Gets the name of the file, in which this object belongs.
+// Exception: H5::IdComponentException
// Description:
-// This function is protected so that the user applications can
-// only have access to its code via allowable classes, namely,
-// Attribute and H5Location subclasses.
-// Programmer Binh-Minh Ribler - Jul, 2004
+// This function is protected so that the user applications can
+// only have access to its code via allowable classes, namely,
+// Attribute and H5Location subclasses.
+// Programmer Binh-Minh Ribler - Jul, 2004
//--------------------------------------------------------------------------
H5std_string IdComponent::p_get_file_name() const
{
@@ -324,22 +324,22 @@ H5std_string IdComponent::p_get_file_name() const
//
//--------------------------------------------------------------------------
-// Function: p_valid_id
-// Purpose: Verifies that the given id is a valid id so it can be passed
-// into an H5I C function.
-// Return true if id is valid, false, otherwise
-// Programmer Binh-Minh Ribler - May, 2005
+// Function: p_valid_id
+// Purpose: Verifies that the given id is a valid id so it can be passed
+// into an H5I C function.
+// Return true if id is valid, false, otherwise
+// Programmer Binh-Minh Ribler - May, 2005
//--------------------------------------------------------------------------
bool IdComponent::p_valid_id(const hid_t obj_id)
{
if (obj_id <= 0)
- return false;
+ return false;
H5I_type_t id_type = H5Iget_type(obj_id);
if (id_type <= H5I_BADID || id_type >= H5I_NTYPES)
- return false;
+ return false;
else
- return true;
+ return true;
}
// Notes about IdComponent::id