00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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 "fimex/CDMAttribute.h"
00033 #include "fimex/CDMVariable.h"
00034 #include "fimex/CDMDimension.h"
00035 #include "fimex/CDMException.h"
00036 #include "fimex/CDMconstants.h"
00037
00038 namespace MetNoFimex
00039 {
00040
00047 class CDM
00048 {
00049 public:
00050 typedef std::vector<CDMAttribute> AttrVec;
00051 typedef std::map<std::string, AttrVec> StrAttrVecMap;
00052 typedef std::vector<CDMDimension> DimVec;
00053 typedef std::vector<CDMVariable> VarVec;
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);
00084 bool hasVariable(const std::string& varName) const;
00092 std::vector<std::string> findVariables(const std::string& attrName, const std::string& attrValueRegExp) const;
00102 std::vector<std::string> findVariables(const std::map<std::string, std::string>& findAttributes, const std::vector<std::string>& findDimensions) const;
00110 bool checkVariableAttribute(const std::string& varName, const std::string& attribute, const boost::regex& attrValue) const;
00116 void removeVariable(const std::string& variableName);
00117
00124 void addDimension(const CDMDimension& dim) throw(CDMException);
00129 bool hasDimension(const std::string& dimName) const;
00130
00137 CDMDimension& getDimension(const std::string& dimName) throw(CDMException);
00138 const CDMDimension& getDimension(const std::string& dimName) const throw(CDMException);
00139
00140
00145 const CDMDimension* getUnlimitedDim() const;
00150 bool hasUnlimitedDim(const CDMVariable& var) const;
00151
00159 void addAttribute(const std::string& varName, const CDMAttribute& attr) throw(CDMException);
00167 void addOrReplaceAttribute(const std::string& varName, const CDMAttribute& attr) throw(CDMException);
00174 void removeAttribute(const std::string& varName, const std::string& attrName);
00175
00176
00178 void toXMLStream(std::ostream& os) const;
00180 const static std::string& globalAttributeNS() {const static std::string global("_GLOBAL"); return global;}
00181
00183 const DimVec& getDimensions() const {return dimensions;}
00185 const VarVec& getVariables() const {return variables;}
00190 const StrAttrVecMap& getAttributes() const {return attributes;}
00195 std::vector<CDMAttribute> getAttributes(const std::string& varName) const;
00196
00197
00205 CDMAttribute& getAttribute(const std::string& varName, const std::string& attrName) throw(CDMException);
00212 const CDMAttribute& getAttribute(const std::string& varName, const std::string& attrName) const throw(CDMException);
00224 bool getAttribute(const std::string& varName, const std::string& attrName, CDMAttribute& retAttribute) const;
00230 double getFillValue(const std::string& varName) const;
00231
00242 void generateProjectionCoordinates(const std::string& projectionVariable, const std::string& xDim, const std::string& yDim, const std::string& lonDim, const std::string& latDim) throw(CDMException);
00254 bool getProjectionAndAxesUnits(std::string& projectionName, std::string& xAxis, std::string& yAxis, std::string& xAxisUnits, std::string& yAxisUnits) const throw(CDMException);
00255
00256
00263 AttrVec getProjection(std::string varName) const;
00270 std::string getHorizontalXAxis(std::string varName) const;
00277 std::string getHorizontalYAxis(std::string varName) const;
00288 bool getLatitudeLongitude(std::string varName, std::string& latitude, std::string& longitude) const;
00295 std::string getTimeAxis(std::string varName) const;
00302 std::string getVerticalAxis(std::string varName) const;
00303
00304 private:
00305 StrAttrVecMap attributes;
00306 VarVec variables;
00307 DimVec dimensions;
00308 };
00309
00310 }
00311
00312 #endif