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 {
00038
00042 class Data
00043 {
00044 public:
00045 virtual ~Data() = 0;
00046
00048 virtual size_t size() const = 0;
00050 virtual int bytes_for_one() const = 0;
00051 virtual void* getDataPtr() = 0;
00053 virtual void toStream(std::ostream&, std::string separator = "") const = 0;
00054
00056 virtual const boost::shared_array<char> asConstChar() const = 0;
00058 virtual boost::shared_array<char> asChar() = 0;
00060 virtual const boost::shared_array<short> asConstShort() const = 0;
00062 virtual boost::shared_array<short> asShort() = 0;
00064 virtual const boost::shared_array<int> asConstInt() const = 0;
00066 virtual boost::shared_array<int> asInt() = 0;
00068 virtual const boost::shared_array<float> asConstFloat() const = 0;
00070 virtual boost::shared_array<float> asFloat() = 0;
00072 virtual const boost::shared_array<double> asConstDouble() const = 0;
00074 virtual boost::shared_array<double> asDouble() = 0;
00076 virtual std::string asString(std::string separator = "") const = 0;
00077
00079 virtual void setValue(long pos, double val) = 0;
00087 virtual void setValues(size_t startPos, const Data& data, size_t first = 0, size_t last = -1) throw(CDMException) = 0;
00102 virtual boost::shared_ptr<Data> slice(std::vector<size_t> orgDimSize, std::vector<size_t> startDims, std::vector<size_t> outputDimSize) throw(CDMException) = 0;
00106 virtual boost::shared_ptr<Data> convertDataType(double oldFill, double oldScale, double oldOffset, CDMDataType newType, double newFill, double newScale, double newOffset) throw(CDMException) = 0;
00110 virtual CDMDataType getDataType() const = 0;
00111 };
00112
00120 boost::shared_ptr<Data> createData(CDMDataType datatype, size_t length) throw(CDMException);
00121
00130 boost::shared_ptr<Data> createDataSlice(CDMDataType datatype, const Data& data, size_t dataStartPos, size_t dataSize) throw(CDMException);
00131
00132 }
00133
00134 #endif