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_fwd.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
00041 struct CDMImpl;
00042
00053 class CDM
00054 {
00055 public:
00056 typedef std::vector<CDMAttribute> AttrVec;
00057 typedef std::map<std::string, AttrVec> StrAttrVecMap;
00058 typedef std::vector<CDMDimension> DimVec;
00059 typedef std::vector<CDMVariable> VarVec;
00060 CDM();
00061 CDM(const CDM& rhs);
00062 virtual ~CDM();
00063 CDM& operator=(const CDM& rhs);
00070 void addVariable(const CDMVariable& var) throw(CDMException);
00077 CDMVariable& getVariable(const std::string& varName) throw(CDMException);
00086 const CDMVariable& getVariable(const std::string& varName) const throw(CDMException);
00092 bool hasVariable(const std::string& varName) const;
00100 std::vector<std::string> findVariables(const std::string& attrName, const std::string& attrValueRegExp) const;
00110 std::vector<std::string> findVariables(const std::map<std::string, std::string>& findAttributes, const std::vector<std::string>& findDimensions) const;
00120 bool renameVariable(const std::string& oldName, const std::string& newName);
00128 bool checkVariableAttribute(const std::string& varName, const std::string& attribute, const boost::regex& attrValue) const;
00134 void removeVariable(const std::string& variableName);
00135
00142 void addDimension(const CDMDimension& dim) throw(CDMException);
00147 bool hasDimension(const std::string& dimName) const;
00148
00155 CDMDimension& getDimension(const std::string& dimName) throw(CDMException);
00156 const CDMDimension& getDimension(const std::string& dimName) const throw(CDMException);
00157
00163 bool testDimensionInUse(const std::string& name) const;
00164
00173 bool renameDimension(const std::string& oldName, const std::string& newName) throw(CDMException);
00174
00183 bool removeDimension(const std::string& name) throw(CDMException);
00184
00189 const CDMDimension* getUnlimitedDim() const;
00194 bool hasUnlimitedDim(const CDMVariable& var) const;
00195
00203 void addAttribute(const std::string& varName, const CDMAttribute& attr) throw(CDMException);
00211 void addOrReplaceAttribute(const std::string& varName, const CDMAttribute& attr) throw(CDMException);
00218 void removeAttribute(const std::string& varName, const std::string& attrName);
00219
00220
00222 void toXMLStream(std::ostream& os) const;
00224 const static std::string& globalAttributeNS() {const static std::string global("_GLOBAL"); return global;}
00225
00227 const DimVec& getDimensions() const;
00229 const VarVec& getVariables() const;
00234 const StrAttrVecMap& getAttributes() const;
00239 std::vector<CDMAttribute> getAttributes(const std::string& varName) const;
00240
00241
00249 CDMAttribute& getAttribute(const std::string& varName, const std::string& attrName) throw(CDMException);
00256 const CDMAttribute& getAttribute(const std::string& varName, const std::string& attrName) const throw(CDMException);
00268 bool getAttribute(const std::string& varName, const std::string& attrName, CDMAttribute& retAttribute) const;
00274 double getFillValue(const std::string& varName) const;
00275
00286 void generateProjectionCoordinates(const std::string& projectionVariable, const std::string& xDim, const std::string& yDim, const std::string& lonDim, const std::string& latDim) throw(CDMException);
00298 DEPRECATED(bool getProjectionAndAxesUnits(std::string& projectionName, std::string& xAxis, std::string& yAxis, std::string& xAxisUnits, std::string& yAxisUnits) const throw(CDMException));
00299
00300
00307 DEPRECATED(AttrVec getProjection(std::string varName) const);
00316 std::string getHorizontalXAxis(std::string varName) const;
00325 std::string getHorizontalYAxis(std::string varName) const;
00336 bool getLatitudeLongitude(std::string varName, std::string& latitude, std::string& longitude) const;
00345 std::string getTimeAxis(std::string varName) const;
00354 std::string getVerticalAxis(std::string varName) const;
00355
00356 private:
00357 CDMImpl* pimpl_;
00358 };
00359
00360 }
00361
00362 #endif