-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the complex trait class to the STL directory
Udpate #414
- Loading branch information
1 parent
6240cb4
commit 13dccb8
Showing
16 changed files
with
555 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// (c) Copyright 2019 DESY,ESS | ||
// (c) Copyright 2019 Eugen Wintersberger <[email protected]> | ||
// | ||
// This file is part of h5cpp. | ||
// | ||
|
@@ -19,42 +19,12 @@ | |
// Boston, MA 02110-1301 USA | ||
// =========================================================================== | ||
// | ||
// Author: Eugen Wintersberger <eugen.wintersberger@desy.de> | ||
// Author: Eugen Wintersberger <eugen.wintersberger@gmail.com> | ||
// Created on: Sep 1, 2019 | ||
// | ||
#pragma once | ||
|
||
#include <h5cpp/memory/memory_adapter.hpp> | ||
|
||
namespace hdf5 { | ||
namespace memory { | ||
|
||
|
||
//template<> | ||
//class MemoryAdapter<int> | ||
//{ | ||
// public: | ||
// using DataspaceType = dataspace::Scalar; | ||
// using DatatypeType = datatype::Integer; | ||
// | ||
// | ||
// static int create(const datatype::Datatype & = datatype::Datatype(), | ||
// const dataspace::Dataspace & = dataspace::Dataspace()) | ||
// { | ||
// return int(); | ||
// } | ||
// | ||
// DataspaceType dataspace() const | ||
// { | ||
// return dataspace::Scalar(); | ||
// } | ||
// | ||
// DatatypeType datatype() const | ||
// { | ||
// return datatype::Integer(ObjectHandle(H5Tcopy(H5T_NATIVE_INT32))); | ||
// } | ||
//}; | ||
|
||
|
||
} | ||
} | ||
#include <h5cpp/stl/vector_memory_adapter.hpp> | ||
#include <h5cpp/stl/complex_memory_adapter.hpp> | ||
#include <h5cpp/stl/complex_datatype_trait.hpp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
set(dir ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
set(SOURCES ) | ||
|
||
set(HEADERS | ||
${dir}/vector_memory_adapter.hpp | ||
${dir}/complex_memory_adapter.hpp | ||
) | ||
|
||
install(FILES ${HEADERS} | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/h5cpp/stl) | ||
|
||
set(h5cpp_headers ${h5cpp_headers} ${HEADERS} PARENT_SCOPE) | ||
set(h5cpp_sources ${h5cpp_sources} ${SOURCES} PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// | ||
// (c) Copyright 2019 Eugen Wintersberger <[email protected]> | ||
// | ||
// This file is part of h5cpp. | ||
// | ||
// This library is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU Lesser General Public License as published | ||
// by the Free Software Foundation; either version 2.1 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, but | ||
// WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY | ||
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | ||
// License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this library; if not, write to the | ||
// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor | ||
// Boston, MA 02110-1301 USA | ||
// =========================================================================== | ||
// | ||
// Author: Eugen Wintersberger <[email protected]> | ||
// Created on: Sep 1, 2019 | ||
// | ||
#pragma once | ||
|
||
#include <h5cpp/hdf5.hpp> | ||
#include <complex> | ||
|
||
namespace hdf5 { | ||
namespace datatype { | ||
|
||
|
||
/** | ||
* @brief datatype trait for complex numbers | ||
* | ||
* This trait creates a HDF5 datatype to store complex numbers. Complex | ||
* numbers are stored in a compound data type with to fields of name | ||
* | ||
* - real - storing the real part | ||
* - imag - storing the imaginary part | ||
* | ||
* \tparam T the base type for the C++ complex number type | ||
*/ | ||
template<typename T> | ||
class Trait<std::complex<T>> | ||
{ | ||
private: | ||
/** | ||
* internal data structure equivalent of a complex number class | ||
* - used to determine the memory layout. | ||
*/ | ||
struct complex_struct { | ||
T real; | ||
T imag; | ||
}; | ||
public: | ||
using Type = std::complex<T>; | ||
using TypeClass = Compound; | ||
|
||
/** | ||
* @brief create a compound type for complex numbers | ||
* | ||
* @return a compound data type for complex numbers | ||
*/ | ||
static TypeClass create(const Type& = Type()) | ||
{ | ||
auto base_type= Trait<T>::create(); | ||
auto complex = Compound::create(sizeof(complex_struct)); | ||
complex.insert("real", HOFFSET(complex_struct, real), base_type); | ||
complex.insert("imag", HOFFSET(complex_struct, imag), base_type); | ||
return complex; | ||
} | ||
|
||
}; | ||
|
||
|
||
} // end of namespace datatype | ||
} // end of namespace hdf5 |
Oops, something went wrong.