src/CDM.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 CDM_H_
00025 #define CDM_H_
00026 
00027 #include <map>
00028 #include <vector>
00029 #include <string>
00030 #include <ostream>
00031 #include <boost/regex.hpp>
00032 #include "CDMAttribute.h"
00033 #include "CDMVariable.h"
00034 #include "CDMDimension.h"
00035 #include "CDMException.h"
00036 
00037 namespace MetNoFimex
00038 {
00039 const int EARTH_RADIUS_M = 6371000;
00040 
00047 class CDM
00048 {
00049 public:
00050         typedef std::map<std::string, CDMAttribute> StrAttrMap;
00051         typedef std::map<std::string, StrAttrMap> StrStrAttrMap;
00052         typedef std::map<std::string, CDMDimension> StrDimMap;
00053         typedef std::map<std::string, CDMVariable> StrVarMap;
00054         CDM();
00055         virtual ~CDM();
00062         void addVariable(const CDMVariable& var) throw(CDMException);
00069         CDMVariable& getVariable(const std::string& varName) throw(CDMException);
00078         const CDMVariable& getVariable(const std::string& varName) const throw(CDMException);
00086         std::vector<std::string> findVariables(const std::string& attrName, const std::string& attrValueRegExp) const;
00096         std::vector<std::string> findVariables(const std::map<std::string, std::string>& findAttributes, const std::vector<std::string>& findDimensions) const;
00104         bool checkVariableAttribute(const std::string& varName, const std::string& attribute, const boost::regex& attrValue) const;
00110         void removeVariable(const std::string& variableName);
00111 
00118         void addDimension(const CDMDimension& dim) throw(CDMException);
00125         CDMDimension& getDimension(const std::string& dimName) throw(CDMException);
00126         const CDMDimension& getDimension(const std::string& dimName) const throw(CDMException);
00127 
00128         
00133         const CDMDimension* getUnlimitedDim() const;
00138         bool hasUnlimitedDim(const CDMVariable& var) const;
00139         
00147         void addAttribute(const std::string& varName, const CDMAttribute& attr) throw(CDMException);
00155         void addOrReplaceAttribute(const std::string& varName, const CDMAttribute& attr) throw(CDMException);
00162         void removeAttribute(const std::string& varName, const std::string& attrName);
00163         
00164         
00166         void toXMLStream(std::ostream& os) const;
00168         const static std::string& globalAttributeNS() {const static std::string global("_GLOBAL"); return global;}
00169         
00171         const StrDimMap& getDimensions() const {return dimensions;}
00173         const StrVarMap& getVariables() const {return variables;}
00178         const StrStrAttrMap& getAttributes() const {return attributes;}
00183         std::vector<CDMAttribute> getAttributes(const std::string& varName) const;
00184 
00185         
00192         CDMAttribute& getAttribute(const std::string& varName, const std::string& attrName) throw(CDMException);
00198         const CDMAttribute& getAttribute(const std::string& varName, const std::string& attrName) const throw(CDMException);
00204         double getFillValue(const std::string& varName) const;
00205 
00216                 void generateProjectionCoordinates(const std::string& projectionVariable, const std::string& xDim, const std::string& yDim, const std::string& lonDim, const std::string& latDim) throw(CDMException);
00228         bool getProjectionAndAxesUnits(std::string& projectionName, std::string& xAxis, std::string& yAxis, std::string& xAxisUnits, std::string& yAxisUnits) const throw(CDMException);
00229 
00230 
00231 private:
00232         StrStrAttrMap attributes;
00233         StrVarMap variables;
00234         StrDimMap dimensions;
00235 };
00236 
00237 }
00238 
00239 #endif /*CDM_H_*/

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