Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 558: move SOScaleType to ScaleOffset::ScaleType #559

Merged
merged 2 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions doc/source/api_reference/namespace_filter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,4 @@ Filter classes
.. doxygenclass:: hdf5::filter::ScaleOffset
:members:

.. doxygenenum:: hdf5::filter::SOScaleType

.. doxygenfunction:: hdf5::filter::operator<<(std::ostream &stream, const SOScaleType &scale_type)
.. doxygenfunction:: hdf5::filter::operator<<(std::ostream &stream, const ScaleOffset::ScaleType &scale_type)
4 changes: 0 additions & 4 deletions doc/source/api_reference/namespace_hdf5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ Classes
.. doxygenclass:: hdf5::ObjectHandle
:members:

.. doxygenenum:: hdf5::ObjectHandle::Policy

.. doxygenenum:: hdf5::ObjectHandle::Type

.. doxygenfunction:: hdf5::operator==(const ObjectHandle &,const ObjectHandle &)

.. doxygenfunction:: hdf5::operator!=(const ObjectHandle &,const ObjectHandle &)
Expand Down
6 changes: 6 additions & 0 deletions src/h5cpp/core/object_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ namespace hdf5
class DLL_EXPORT ObjectHandle
{
public:
//!
//! @brief type of the object handle
//!
enum class Type
{
Uninitialized,
Expand All @@ -84,6 +87,9 @@ class DLL_EXPORT ObjectHandle
ErrorStack
};

//!
//! @brief type of the ward policy
//!
enum class Policy
{
WithWard = 1,
Expand Down
16 changes: 8 additions & 8 deletions src/h5cpp/filter/scaleoffset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ namespace filter {

ScaleOffset::ScaleOffset():
Filter(H5Z_FILTER_SCALEOFFSET),
scale_type_(SOScaleType::FloatDScale),
scale_type_(ScaleOffset::ScaleType::FloatDScale),
scale_factor_(1)
{}

ScaleOffset::ScaleOffset(SOScaleType scale_type, int scale_factor):
ScaleOffset::ScaleOffset(ScaleOffset::ScaleType scale_type, int scale_factor):
Filter(H5Z_FILTER_SCALEOFFSET),
scale_type_(scale_type),
scale_factor_(scale_factor)
Expand All @@ -48,12 +48,12 @@ ScaleOffset::ScaleOffset(SOScaleType scale_type, int scale_factor):
ScaleOffset::~ScaleOffset()
{}

SOScaleType ScaleOffset::scale_type() const noexcept
ScaleOffset::ScaleType ScaleOffset::scale_type() const noexcept
{
return scale_type_;
}

void ScaleOffset::scale_type(SOScaleType scale_type)
void ScaleOffset::scale_type(ScaleOffset::ScaleType scale_type)
{
scale_type_ = scale_type;
}
Expand All @@ -77,11 +77,11 @@ void ScaleOffset::operator()(const property::DatasetCreationList &dcpl,
}
}

std::ostream &operator<<(std::ostream &stream, const SOScaleType &scale_type) {
std::ostream &operator<<(std::ostream &stream, const ScaleOffset::ScaleType &scale_type) {
switch (scale_type) {
case SOScaleType::FloatDScale: return stream << "FLOAT_DSCALE";
case SOScaleType::FloatEScale: return stream << "FLOAT_ESCALE";
case SOScaleType::Int: return stream << "INT";
case ScaleOffset::ScaleType::FloatDScale: return stream << "FLOAT_DSCALE";
case ScaleOffset::ScaleType::FloatEScale: return stream << "FLOAT_ESCALE";
case ScaleOffset::ScaleType::Int: return stream << "INT";
default:return stream;
}
}
Expand Down
37 changes: 19 additions & 18 deletions src/h5cpp/filter/scaleoffset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ namespace hdf5 {
namespace filter {


//!
//! @brief character set encoding
//!
//! Enumeration type determining the character encoding used by string types
//! and links.
//!
enum class SOScaleType: std::underlying_type<H5Z_SO_scale_type_t>::type {
FloatDScale = H5Z_SO_FLOAT_DSCALE, // Floating-point type, using variable MinBits method
FloatEScale = H5Z_SO_FLOAT_ESCALE, // Floating-point type, using fixed MinBits method
Int = H5Z_SO_INT // Integer type
};


#ifdef __clang__
Expand All @@ -52,24 +41,36 @@ enum class SOScaleType: std::underlying_type<H5Z_SO_scale_type_t>::type {
#endif
class DLL_EXPORT ScaleOffset : public Filter
{
private:
SOScaleType scale_type_;
int scale_factor_;
public:

//!
//! @brief character set encoding used by string types and links
//!
enum class ScaleType: std::underlying_type<H5Z_SO_scale_type_t>::type {
//! floating-point type, using variable MinBits method
FloatDScale = H5Z_SO_FLOAT_DSCALE,
//! floating-point type, using fixed MinBits method
FloatEScale = H5Z_SO_FLOAT_ESCALE,
//! integer type
Int = H5Z_SO_INT
};
ScaleOffset();
ScaleOffset(SOScaleType scale_type, int scale_factor);
ScaleOffset(ScaleOffset::ScaleType scale_type, int scale_factor);
~ScaleOffset() override;

SOScaleType scale_type() const noexcept;
ScaleOffset::ScaleType scale_type() const noexcept;

void scale_type(SOScaleType scale_type);
void scale_type(ScaleOffset::ScaleType scale_type);

int scale_factor() const noexcept;

void scale_factor(int scale_factor);

virtual void operator()(const property::DatasetCreationList &dcpl,
Availability flag=Availability::Mandatory) const override;
private:
ScaleOffset::ScaleType scale_type_;
int scale_factor_;

};
#ifdef __clang__
Expand All @@ -85,7 +86,7 @@ class DLL_EXPORT ScaleOffset : public Filter
//! @param scale_type reference to the scala type to write
//! @return modified output stream
//!
DLL_EXPORT std::ostream &operator<<(std::ostream &stream, const SOScaleType &scale_type);
DLL_EXPORT std::ostream &operator<<(std::ostream &stream, const ScaleOffset::ScaleType &scale_type);


} // namespace filter
Expand Down
14 changes: 7 additions & 7 deletions test/filter/scaleoffset_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ SCENARIO("ScalaOffset filter tests") {
REQUIRE(filter.is_encoding_enabled());
}
THEN("we can set the scale type to FLOAT_DSCALE") {
filter.scale_type(filter::SOScaleType::FloatDScale);
REQUIRE(filter.scale_type() == filter::SOScaleType::FloatDScale);
filter.scale_type(filter::ScaleOffset::ScaleType::FloatDScale);
REQUIRE(filter.scale_type() == filter::ScaleOffset::ScaleType::FloatDScale);
}
THEN("we can set the scale factor to FLOAT_ESCALE") {
filter.scale_type(filter::SOScaleType::FloatEScale);
REQUIRE(filter.scale_type() == filter::SOScaleType::FloatEScale);
filter.scale_type(filter::ScaleOffset::ScaleType::FloatEScale);
REQUIRE(filter.scale_type() == filter::ScaleOffset::ScaleType::FloatEScale);
}
THEN("we can set the scale factor to 4") {
filter.scale_factor(4);
Expand All @@ -53,9 +53,9 @@ SCENARIO("ScalaOffset filter tests") {
}

GIVEN("a filter constructed for integer") {
filter::ScaleOffset scaleoffset(filter::SOScaleType::Int, 2);
filter::ScaleOffset scaleoffset(filter::ScaleOffset::ScaleType::Int, 2);
THEN("the filter has the following properties") {
REQUIRE(scaleoffset.scale_type() == filter::SOScaleType::Int);
REQUIRE(scaleoffset.scale_type() == filter::ScaleOffset::ScaleType::Int);
REQUIRE(scaleoffset.scale_factor() == 2);
}
AND_GIVEN("a dataset creation property list") {
Expand Down Expand Up @@ -85,4 +85,4 @@ SCENARIO("ScalaOffset filter tests") {
}
}
}
}
}