HDF5Serie

Project Page
/home/user/MBSimWindows/hdf5serie/hdf5serie/hdf5serie/simpledataset.h
00001 /* Copyright (C) 2009 Markus Friedrich
00002  *
00003  * This library is free software; you can redistribute it and/or 
00004  * modify it under the terms of the GNU Lesser General Public 
00005  * License as published by the Free Software Foundation; either 
00006  * version 2.1 of the License, or (at your option) any later version. 
00007  *  
00008  * This library is distributed in the hope that it will be useful, 
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00011  * Lesser General Public License for more details. 
00012  *  
00013  * You should have received a copy of the GNU Lesser General Public 
00014  * License along with this library; if not, write to the Free Software 
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016  *
00017  * Contact:
00018  *   friedrich.at.gc@googlemail.com
00019  *
00020  */
00021 
00022 #ifndef _HDF5SERIE_SIMPLEDATASET_H_
00023 #define _HDF5SERIE_SIMPLEDATASET_H_
00024 
00025 #include <H5Cpp.h>
00026 #include <vector>
00027 #include <string>
00028 #include <hdf5serie/toh5type.h>
00029 #include <hdf5serie/simpleattribute.h>
00030 #include <assert.h>
00031 
00032 namespace H5 {
00033 
00059   template<class T>
00060   class SimpleDataSet : public DataSet {
00061     private:
00062       DataSpace dataSpace;
00063       DataType memDataType;
00064     public:
00066       SimpleDataSet();
00067 
00069       SimpleDataSet(const SimpleDataSet<T>& dataset);
00070 
00075       SimpleDataSet(const CommonFG& parent, const std::string& name, bool create=false);
00076 
00081       SimpleDataSet(const CommonFG& parent, const std::string& name, const T& data);
00082       
00087       void create(const CommonFG& parent, const std::string& name);
00088 
00093       void open(const CommonFG& parent, const std::string& name);
00094 
00099       void write(const T& data);
00100 
00105       T read();
00106 
00111       void write(const CommonFG& parent, const std::string& name, const T& data);
00112 
00117       T read(const CommonFG& parent, const std::string& name);
00118 
00123       void setDescription(const std::string& description);
00124 
00129       std::string getDescription();
00130 
00135       static T getData(const CommonFG& parent, const std::string& name);
00136   };
00137 
00138   // a partial specialisation of class SimpleDataSet<T> for T=std::vector<T>
00139   template<class T>
00140   class SimpleDataSet<std::vector<T> > : public DataSet {
00141     private:
00142       DataType memDataType;
00143     public:
00144       SimpleDataSet();
00145       SimpleDataSet(const SimpleDataSet<std::vector<T> >& dataset);
00146       SimpleDataSet(const CommonFG& parent, const std::string& name, bool create=false);
00147       SimpleDataSet(const CommonFG& parent, const std::string& name, const std::vector<T>& data);
00148       void create(const CommonFG& parent, const std::string& name);
00149       void open(const CommonFG& parent, const std::string& name);
00150       void write(const std::vector<T>& data);
00151       std::vector<T> read();
00152       void write(const CommonFG& parent, const std::string& name, const std::vector<T>& data);
00153       std::vector<T> read(const CommonFG& parent, const std::string& name);
00154       void setDescription(const std::string& description);
00155       std::string getDescription();
00156       static std::vector<T>  getData(const CommonFG& parent, const std::string& name);
00157   };
00158 
00159   // a partial specialisation of class SimpleDataSet<T> for T=std::vector<std::vector<T> >
00160   template<class T>
00161   class SimpleDataSet<std::vector<std::vector<T> > > : public DataSet {
00162     private:
00163       DataType memDataType;
00164     public:
00165       SimpleDataSet();
00166       SimpleDataSet(const SimpleDataSet<std::vector<std::vector<T> > >& dataset);
00167       SimpleDataSet(const CommonFG& parent, const std::string& name, bool create=false);
00168       SimpleDataSet(const CommonFG& parent, const std::string& name, const std::vector<std::vector<T> >& data);
00169       void create(const CommonFG& parent, const std::string& name);
00170       void open(const CommonFG& parent, const std::string& name);
00171       void write(const std::vector<std::vector<T> >& data);
00172       std::vector<std::vector<T> > read();
00173       void write(const CommonFG& parent, const std::string& name, const std::vector<std::vector<T> >& data);
00174       std::vector<std::vector<T> > read(const CommonFG& parent, const std::string& name);
00175       void setDescription(const std::string& description);
00176       std::string getDescription();
00177       static std::vector<std::vector<T> > getData(const CommonFG& parent, const std::string& name);
00178   };
00179 
00180 }
00181 
00182 #endif