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 CDMATTRIBUTE_H_
00025 #define CDMATTRIBUTE_H_
00026
00027 #include <string>
00028 #include <vector>
00029 #include <ostream>
00030 #include <boost/shared_ptr.hpp>
00031 #include "fimex/CDMDataType.h"
00032 #include "fimex/CDMNamedEntity.h"
00033 #include "fimex/CDMException.h"
00034 #include "fimex/deprecated.h"
00035
00036 namespace MetNoFimex
00037 {
00038
00039 class Data;
00040
00041 class CDMAttribute : public CDMNamedEntity
00042 {
00043
00044 public:
00045 CDMAttribute();
00047 explicit CDMAttribute(std::string name, std::string value);
00049 explicit CDMAttribute(std::string name, char value);
00051 explicit CDMAttribute(std::string name, int value);
00053 explicit CDMAttribute(std::string name, short value);
00055 explicit CDMAttribute(std::string name, float value);
00057 explicit CDMAttribute(std::string name, double value);
00059 explicit CDMAttribute(std::string name, CDMDataType datatype, boost::shared_ptr<Data> data);
00061 explicit CDMAttribute(const std::string& name, const std::string& datatype, const std::string& value) throw(CDMException);
00063 explicit CDMAttribute(const std::string& name, CDMDataType datatype, const std::vector<std::string>& values) throw(CDMException);
00064 virtual ~CDMAttribute();
00066 const std::string& getName() const {return name;}
00068 void setName(std::string newName) {name = newName;}
00070 const std::string getStringValue() const;
00072 const boost::shared_ptr<Data> getData() const {return data;}
00074 void setData(boost::shared_ptr<Data> data) {this->data = data;}
00076 const CDMDataType getDataType() const {return datatype;}
00077 void toXMLStream(std::ostream& out) const;
00078 private:
00079 std::string name;
00080 CDMDataType datatype;
00081 boost::shared_ptr<Data> data;
00082
00083 void initDataByArray(const std::vector<std::string>& values);
00084
00085 template<typename T>
00086 void initDataArray(const std::vector<std::string>& values);
00087 };
00088
00095 DEPRECATED(std::vector<CDMAttribute> projStringToAttributes(std::string projStr));
00103 DEPRECATED(std::string attributesToProjString(const std::vector<CDMAttribute>& attrs));
00104
00105
00106 }
00107
00108 #endif