diff --git a/src/opt/hdf5/include/cnorxz_hdf5.cc.h b/src/opt/hdf5/include/cnorxz_hdf5.cc.h new file mode 100644 index 0000000..b4d78b9 --- /dev/null +++ b/src/opt/hdf5/include/cnorxz_hdf5.cc.h @@ -0,0 +1,4 @@ + +#include "h5_types.cc.h" +#include "h5_group.cc.h" +#include "h5_table.cc.h" diff --git a/src/opt/hdf5/include/cnorxz_hdf5.h b/src/opt/hdf5/include/cnorxz_hdf5.h index b4de2fc..113ee7c 100644 --- a/src/opt/hdf5/include/cnorxz_hdf5.h +++ b/src/opt/hdf5/include/cnorxz_hdf5.h @@ -2,3 +2,7 @@ #include "h5_content_base.h" #include "h5_file.h" #include "h5_group.h" +#include "h5_table.h" +#include "h5_types.h" + +#include "cnorxz_hdf5.cc.h" diff --git a/src/opt/hdf5/include/h5_table.cc.h b/src/opt/hdf5/include/h5_table.cc.h index 7f82327..c148ad1 100644 --- a/src/opt/hdf5/include/h5_table.cc.h +++ b/src/opt/hdf5/include/h5_table.cc.h @@ -9,14 +9,16 @@ namespace CNORXZ { namespace hdf5 { + template template - decltype(auto) iterRecords(F&& f) const + decltype(auto) STable::iterRecords(F&& f) const { - + CXZ_ERROR("not implemented"); + return f(0); } template - STabel::STabel(const String& name, const ContentBase* _parent, const RangePtr& fields) : + STable::STable(const String& name, const ContentBase* _parent, const RangePtr& fields) : Table(name, _parent) { constexpr SizeT N = sizeof...(Ts); @@ -27,35 +29,36 @@ namespace CNORXZ CXZ_ASSERT(mFields->size() == sizeof...(Ts), "expected tuple of size = " << mFields->size() << ", got: " << sizeof...(Ts)); + Tuple x; if(mRecords == nullptr) { auto mOffsets = MArray( mFields, iter<0,N> - ( [&](auto i) { return &std::get(t) - &t; }, + ( [&](auto i) { return &std::get(x) - &x; }, [](const auto&... e) { return Vector({e...}); }) ); auto mSizes = MArray( mFields, iter<0,N> - ( [&](auto i) { return sizeof(std::get(t)); }, + ( [&](auto i) { return sizeof(std::get(x)); }, [](const auto&... e) { return Vector({e...}); }) ); auto mTypes = MArray( mFields, iter<0,N> - ( [&](auto i) { return getTypeId(std::get(t)); }, + ( [&](auto i) { return getTypeId(std::get(x)); }, [](const auto&... e) { return Vector({e...}); }) ); } else { iter<0,N>( [&](auto i) { CXZ_ASSERT - ( &std::get(t) - &t == mOffsets.data()[i], - "wrong offset for field " << i << ": " << &std::get(t) - &t + ( &std::get(x) - &x == mOffsets.data()[i], + "wrong offset for field " << i << ": " << &std::get(x) - &x << " vs " << mOffsets.data()[i] ); }, NoF{} ); iter<0,N>( [&](auto i) { CXZ_ASSERT - ( sizeof(std::get(t)) == mSizes.data()[i], - "wrong size for field " << i << ": " << sizeof(std::get(t)) + ( sizeof(std::get(x)) == mSizes.data()[i], + "wrong size for field " << i << ": " << sizeof(std::get(x)) << " vs " << mSizes.data()[i] ); }, NoF{} ); iter<0,N>( [&](auto i) { CXZ_ASSERT - ( getTypeId(std::get(t)) == mTypes.data()[i], - "wrong type for field " << i << ": " << getTypeId(std::get(t)) + ( getTypeId(std::get(x)) == mTypes.data()[i], + "wrong type for field " << i << ": " << getTypeId(std::get(x)) << " vs " << mTypes.data()[i] ); }, NoF{} ); } } template - STabel& STabel::appendRecord(const Tuple& t) + STable& STable::appendRecord(const Tuple& t) { RangePtr appr = CRangeFactory(1).create(); if(mRecords == nullptr){ diff --git a/src/opt/hdf5/include/h5_table.h b/src/opt/hdf5/include/h5_table.h index e105974..cb113dc 100644 --- a/src/opt/hdf5/include/h5_table.h +++ b/src/opt/hdf5/include/h5_table.h @@ -37,14 +37,14 @@ namespace CNORXZ }; template - class STabel : public Table + class STable : public Table { public: - DEFAULT_MEMBERS(STabel); - STabel(const String& name, const ContentBase* _parent, const RangePtr& fields); + DEFAULT_MEMBERS(STable); + STable(const String& name, const ContentBase* _parent, const RangePtr& fields); - Table& appendRecord(const Tuple& t); - Table& appendRecord(const MArray>& t); + STable& appendRecord(const Tuple& t); + STable& appendRecord(const MArray>& t); template decltype(auto) iterRecords(F&& f) const; diff --git a/src/opt/hdf5/include/h5_types.cc.h b/src/opt/hdf5/include/h5_types.cc.h index ca02f4b..81784f1 100644 --- a/src/opt/hdf5/include/h5_types.cc.h +++ b/src/opt/hdf5/include/h5_types.cc.h @@ -6,22 +6,38 @@ namespace CNORXZ { namespace hdf5 { - template - inline hid_t TypeId>::get(Arr x) + template + inline hid_t TypeId::get() { - static hid_t arrtype = H5Tarray_create2(getTypeId(x[0]), 1, N); + return 0; + } + + inline hid_t TypeId::get() + { + return H5T_NATIVE_ULONG; + } + + inline hid_t TypeId::get() + { + return H5T_NATIVE_INT; + } + + inline hid_t TypeId::get() + { + return H5T_NATIVE_DOUBLE; + } + + template + inline hid_t TypeId>::get() + { + static hid_t arrtype = H5Tarray_create2(TypeId::get(), 1, N); return arrtype; } template hid_t getTypeId(T x) { - if constexpr (TypeIsNative::value){ - return NativeTypeId::value; - } - else { - return TypeId::get(x); - } + return TypeId::get(); } } diff --git a/src/opt/hdf5/include/h5_types.h b/src/opt/hdf5/include/h5_types.h index 14b69cf..7ecc4bf 100644 --- a/src/opt/hdf5/include/h5_types.h +++ b/src/opt/hdf5/include/h5_types.h @@ -6,44 +6,22 @@ namespace CNORXZ { namespace hdf5 { - /******************** - * TypeIsNative * - ********************/ - - template - struct TypeIsNative { static constexpr bool value = false; }; - - template <> - struct TypeIsNative { static constexpr bool value = true; }; - - template - struct TypeIsNative { static constexpr bool value = true; }; - - template - struct TypeIsNative { static constexpr bool value = true; }; - - /******************** - * NativeTypeId * - ********************/ - - template - struct NativeTypeId { static constexpr hid_t value = 0; }; - - template <> - struct NativeTypeId { static constexpr hid_t value = H5T_NATIVE_ULONG; }; - - template <> - struct NativeTypeId { static constexpr hid_t value = H5T_NATIVE_INT; }; - - template <> - struct NativeTypeId { static constexpr hid_t value = H5T_NATIVE_DOUBLE; }; /************** * TypeId * **************/ template - struct TypeId { static inline hid_t get() { return 0; } }; + struct TypeId { static inline hid_t get(); }; + + template <> + struct TypeId { static inline hid_t get(); }; + + template <> + struct TypeId { static inline hid_t get(); }; + + template <> + struct TypeId { static inline hid_t get(); }; template struct TypeId> { static inline hid_t get(); }; diff --git a/src/opt/hdf5/lib/h5_table.cc b/src/opt/hdf5/lib/h5_table.cc index c60262c..8ecd4dd 100644 --- a/src/opt/hdf5/lib/h5_table.cc +++ b/src/opt/hdf5/lib/h5_table.cc @@ -9,7 +9,7 @@ namespace CNORXZ Table::Table(const String& name, const ContentBase* _parent) : ContentBase(name, _parent) { - if(H5Lexists_by_name(mParent->id(), mName.c_str(), H5P_DEFAULT)){ + if(H5Lexists(mParent->id(), mName.c_str(), H5P_DEFAULT)){ hsize_t nfields = 0; hsize_t nrecords = 0; H5TBget_table_info(mParent->id(), mName.c_str(), &nfields, &nrecords);