src/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 "CDMDataType.h"
00033 #include "CDMException.h"
00034 #include "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;
00107         };
00108 
00116         boost::shared_ptr<Data> createData(CDMDataType datatype, size_t length) throw(CDMException);
00117 
00126         boost::shared_ptr<Data> createDataSlice(CDMDataType datatype, const Data& data, size_t dataStartPos, size_t dataSize) throw(CDMException);
00127 
00128 }
00129 
00130 #endif /*DATA_H_*/

Generated on Thu Jun 5 14:58:22 2008 for MI - Fimex by  doxygen 1.4.6