# MI - Fimex: include/fimex/CDMAttribute.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

# include/fimex/CDMAttribute.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 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 /* forward declaration */
    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     /* datatype and name must be set to call this init function */
    00083     void initDataByArray(const std::vector<std::string>& values);
    00084     /* init data arrays for all types */
    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 /*CDMATTRIBUTE_H_*/