Data Access Library (DAL)
|
00001 /* Copyright 2011-2012 ASTRON, Netherlands Institute for Radio Astronomy 00002 * This file is part of the Data Access Library (DAL). 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 3 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 #ifndef DAL_H5COMPLEX_H 00018 #define DAL_H5COMPLEX_H 00019 00020 #include <complex> 00021 #include <hdf5.h> 00022 #include "hid_gc.h" 00023 #include "../exceptions/exceptions.h" 00024 00025 namespace dal { 00026 00027 inline hid_gc h5complexType( hid_t halftype ) 00028 { 00029 // assume complex type is packed 00030 const size_t halfsize = H5Tget_size(halftype); 00031 00032 hid_gc complex_id(H5Tcreate(H5T_COMPOUND, 2 * halfsize), H5Tclose, "Could not create compound datatype for complex datatype"); 00033 00034 if (H5Tinsert(complex_id, "real", 0, halftype) < 0) 00035 throw HDF5Exception("Could not create real part of complex datatype"); 00036 00037 if (H5Tinsert(complex_id, "imag", halfsize, halftype) < 0) 00038 throw HDF5Exception("Could not create imaginary part of complex datatype"); 00039 00040 return complex_id; 00041 } 00042 00043 } 00044 00045 #endif 00046