src/NetCDF_CDMWriter.h

Go to the documentation of this file.
00001 /*
00002  * Fimex
00003  * 
00004  * (C) Copyright 2008, met.no
00005  *
00006  * Project Info:  https://wiki.met.no/fimex/start
00007  *
00008  * This library is free software; you can redistribute it and/or modify it
00009  * under the terms of the GNU Lesser General Public License as published by
00010  * the Free Software Foundation; either version 2.1 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00015  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00016  * License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
00021  * USA.
00022  */
00023 
00024 #ifndef NETCDF_CDMWRITER_H_
00025 #define NETCDF_CDMWRITER_H_
00026 
00027 #include "CDMWriter.h"
00028 #include "config.h"
00029 #include <map>
00030 #include <string>
00031 #include NETCDF_CPP_INCLUDE
00032 
00033 namespace MetNoFimex
00034 {
00035 class XMLDoc; // forward decl.
00036 
00037 class NetCDF_CDMWriter : public CDMWriter
00038 {
00039         typedef std::map<std::string, NcDim*> NcDimMap;
00040         typedef std::map<std::string, NcVar*> NcVarMap;
00041 
00042 public:
00043         NetCDF_CDMWriter(const boost::shared_ptr<CDMReader> cdmReader, const std::string& outputFile);
00049         NetCDF_CDMWriter(const boost::shared_ptr<CDMReader> cdmReader, const std::string& outputFile, const std::string& configFile);
00050         virtual ~NetCDF_CDMWriter();
00052         const std::string& getVariableName(const std::string& varName) const;
00054         const std::string& getDimensionName(const std::string& dimName) const;
00056         const std::string& getAttributeName(const std::string& varName, const std::string& attName) const;
00062         const CDMAttribute& getAttribute(const std::string& varName, const std::string& attName) const throw(CDMException);
00063 
00064 
00065 
00066 private:
00067         NcError ncErr;
00068         NcFile ncFile;
00069         void init() throw(CDMException);
00070         void initFillRenameDimension(const std::auto_ptr<XMLDoc>& doc) throw(CDMException);
00071         void initFillRenameVariable(const std::auto_ptr<XMLDoc>& doc) throw(CDMException);
00072         void initFillRenameAttribute(const std::auto_ptr<XMLDoc>& doc) throw(CDMException);
00073 
00074         NcDimMap defineDimensions();
00075         NcVarMap defineVariables(const NcDimMap& dimMap);
00076         void writeAttributes(const NcVarMap& varMap);
00077         void writeData(const NcVarMap& varMap);
00078         std::map<std::string, std::string> variableNameChanges;
00079         std::map<std::string, CDMDataType> variableTypeChanges;
00080         std::map<std::string, std::string> dimensionNameChanges;
00081         std::map<std::string, std::map<std::string, std::string> > attributeNameChanges;
00082         CDM::StrStrAttrMap attributes;
00083 };
00084 
00085 }
00086 
00087 #endif /*NETCDF_CDMWRITER_H_*/

Generated on Thu Jun 5 14:58:22 2008 for MI - Fimex by  doxygen 1.4.6