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_ERRORSTACK_H 00018 #define DAL_ERRORSTACK_H 00019 00020 #include <hdf5.h> 00021 #include <string> 00022 #include <vector> 00023 #include <sstream> 00024 00025 /* 00026 * See http://www.hdfgroup.org/HDF5/doc/UG/13_ErrorHandling.html 00027 * and http://www.hdfgroup.org/HDF5/doc/RM/RM_H5E.html 00028 */ 00029 00030 namespace dal { 00031 00043 class ScopedErrorStack { 00044 public: 00045 ScopedErrorStack(); 00046 ~ScopedErrorStack(); 00047 private: 00048 const hid_t olderrorstack; 00049 }; 00050 00059 class DisableErrorPrinting { 00060 public: 00061 DisableErrorPrinting(); 00062 ~DisableErrorPrinting(); 00063 private: 00064 H5E_auto2_t oldhandler; 00065 void *oldclientdata; 00066 }; 00067 00071 struct HDF5StackLine { 00072 unsigned n; 00073 00074 hid_t cls_id; 00075 hid_t maj_num; 00076 hid_t min_num; 00077 00078 unsigned line; 00079 std::string func_name; 00080 std::string file_name; 00081 00082 std::string desc; 00083 00084 std::string cls; 00085 std::string maj; 00086 std::string min; 00087 00091 std::string shortDesc() const; 00092 00096 std::string longDesc() const; 00097 }; 00098 00099 00103 class HDF5ErrorStack { 00104 public: 00109 HDF5ErrorStack(); 00110 00114 static void clear(); 00115 00119 std::vector<struct HDF5StackLine> stack() const; 00120 00121 private: 00122 static herr_t walker(unsigned n, const H5E_error2_t *err_desc, void *clientdata); 00123 00124 std::vector<struct HDF5StackLine> _stack; 00125 }; 00126 00127 } 00128 00129 #endif