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

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

# include/fimex/Data.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 DATA_H_
    00025 #define DATA_H_
    00026
    00027 #include <boost/shared_array.hpp>
    00028 #include <boost/shared_ptr.hpp>
    00029 #include <string>
    00030 #include <sstream>
    00031 #include <iostream>
    00032 #include "fimex/CDMDataType.h"
    00033 #include "fimex/CDMException.h"
    00034 #include "fimex/Utils.h"
    00035
    00036 namespace MetNoFimex
    00037 {
    00045         class Data
    00046         {
    00047         public:
    00048                 virtual ~Data() = 0;
    00049
    00051                 virtual size_t size() const = 0;
    00053                 virtual int bytes_for_one() const = 0;
    00054                 virtual void* getDataPtr() = 0;
    00056                 virtual void toStream(std::ostream&, std::string separator = "") const = 0;
    00057
    00059                 virtual const boost::shared_array<char> asConstChar() const = 0;
    00061                 virtual boost::shared_array<char> asChar() = 0;
    00063                 virtual const boost::shared_array<short> asConstShort() const = 0;
    00065                 virtual boost::shared_array<short> asShort() = 0;
    00067                 virtual const boost::shared_array<int> asConstInt() const = 0;
    00069                 virtual boost::shared_array<int> asInt() = 0;
    00071                 virtual const boost::shared_array<float> asConstFloat() const = 0;
    00073                 virtual boost::shared_array<float> asFloat() = 0;
    00075                 virtual const boost::shared_array<double> asConstDouble() const = 0;
    00077                 virtual boost::shared_array<double> asDouble() = 0;
    00079                 virtual std::string asString(std::string separator = "") const = 0;
    00080
    00082                 virtual void setValue(long pos, double val) = 0;
    00090                 virtual void setValues(size_t startPos, const Data& data, size_t first = 0, size_t end = -1) throw(CDMException) = 0;
    00095                 virtual void setAllValues(double val) = 0;
    00110                 virtual boost::shared_ptr<Data> slice(std::vector<size_t> orgDimSize, std::vector<size_t> startDims, std::vector<size_t> outputDimSize) throw(CDMException) = 0;
    00114                 virtual boost::shared_ptr<Data> convertDataType(double oldFill, double oldScale, double oldOffset, CDMDataType newType, double newFill, double newScale, double newOffset) throw(CDMException) = 0;
    00118                 virtual CDMDataType getDataType() const = 0;
    00119         };
    00120
    00129         boost::shared_ptr<Data> createData(CDMDataType datatype, size_t length, double val = 0) throw(CDMException);
    00130
    00139         boost::shared_ptr<Data> createDataSlice(CDMDataType datatype, const Data& data, size_t dataStartPos, size_t dataSize) throw(CDMException);
    00140
    00141 }
    00142
    00143 #endif /*DATA_H_*/