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 #include "fimex/coordSys/Projection.h"
00038
00039 namespace MetNoFimex
00040 {
00041
00042 struct CDMImpl;
00043
00054 class CDM
00055 {
00056 public:
00057 typedef std::vector<CDMAttribute> AttrVec;
00058 typedef std::map<std::string, AttrVec> StrAttrVecMap;
00059 typedef std::vector<CDMDimension> DimVec;
00060 typedef std::vector<CDMVariable> VarVec;
00061 CDM();
00062 CDM(const CDM& rhs);
00063 virtual ~CDM();
00064 CDM& operator=(const CDM& rhs);
00071 void addVariable(const CDMVariable& var) throw(CDMException);
00078 CDMVariable& getVariable(const std::string& varName) throw(CDMException);
00087 const CDMVariable& getVariable(const std::string& varName) const throw(CDMException);
00093 bool hasVariable(const std::string& varName) const;
00101 std::vector<std::string> findVariables(const std::string& attrName, const std::string& attrValueRegExp) const;
00111 std::vector<std::string> findVariables(const std::map<std::string, std::string>& findAttributes, const std::vector<std::string>& findDimensions) const;
00121 bool renameVariable(const std::string& oldName, const std::string& newName);
00129 bool checkVariableAttribute(const std::string& varName, const std::string& attribute, const boost::regex& attrValue) const;
00135 void removeVariable(const std::string& variableName);
00136
00143 void addDimension(const CDMDimension& dim) throw(CDMException);
00148 bool hasDimension(const std::string& dimName) const;
00149
00156 CDMDimension& getDimension(const std::string& dimName) throw(CDMException);
00157 const CDMDimension& getDimension(const std::string& dimName) const throw(CDMException);
00158
00164 bool testDimensionInUse(const std::string& name) const;
00165
00174 bool renameDimension(const std::string& oldName, const std::string& newName) throw(CDMException);
00175
00184 bool removeDimension(const std::string& name) throw(CDMException);
00185
00190 const CDMDimension* getUnlimitedDim() const;
00195 bool hasUnlimitedDim(const CDMVariable& var) const;
00196
00204 void addAttribute(const std::string& varName, const CDMAttribute& attr) throw(CDMException);
00212 void addOrReplaceAttribute(const std::string& varName, const CDMAttribute& attr) throw(CDMException);
00219 void removeAttribute(const std::string& varName, const std::string& attrName);
00220
00221
00223 void toXMLStream(std::ostream& os) const;
00225 const static std::string& globalAttributeNS() {const static std::string global("_GLOBAL"); return global;}
00226
00228 const DimVec& getDimensions() const;
00230 const VarVec& getVariables() const;
00235 const StrAttrVecMap& getAttributes() const;
00240 std::vector<CDMAttribute> getAttributes(const std::string& varName) const;
00241
00242
00250 CDMAttribute& getAttribute(const std::string& varName, const std::string& attrName) throw(CDMException);
00257 const CDMAttribute& getAttribute(const std::string& varName, const std::string& attrName) const throw(CDMException);
00269 bool getAttribute(const std::string& varName, const std::string& attrName, CDMAttribute& retAttribute) const;
00275 double getFillValue(const std::string& varName) const;
00280 std::string getUnits(const std::string& varName) const;
00291 void generateProjectionCoordinates(const std::string& projectionVariable, const std::string& xDim, const std::string& yDim, const std::string& lonDim, const std::string& latDim) throw(CDMException);
00303 DEPRECATED(bool getProjectionAndAxesUnits(std::string& projectionName, std::string& xAxis, std::string& yAxis, std::string& xAxisUnits, std::string& yAxisUnits) const throw(CDMException));
00304
00305
00313 DEPRECATED(AttrVec getProjection(std::string varName) const);
00322 boost::shared_ptr<const Projection> getProjectionOf(std::string varName) const;
00323
00332 std::string getHorizontalXAxis(std::string varName) const;
00341 std::string getHorizontalYAxis(std::string varName) const;
00352 bool getLatitudeLongitude(std::string varName, std::string& latitude, std::string& longitude) const;
00361 std::string getTimeAxis(std::string varName) const;
00370 std::string getVerticalAxis(std::string varName) const;
00371
00372 private:
00373 CDMImpl* pimpl_;
00374 };
00375
00376 }
00377
00378 #endif