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 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