#ifndef __GRID1D_H__ #define __GRID1D_H__ // // class for 1D grid // #include #include "serializable.h" #include "util.h" #define GRID_1D_VERSION "RV-Grid1d-A" typedef double DataValType; class RpGrid1d : public RpSerializable { public: // constructors RpGrid1d(); RpGrid1d(int size); RpGrid1d(DataValType* data, int size); // makes a copy of data RpGrid1d(const char* buf); // instantiate with byte stream // add all points to grid RP_ERROR addAllPoints(DataValType* val, int nitems); // add one point to grid void addPoint(DataValType val); // return number of points in grid int numPoints() { return m_data.size(); }; int size() { return numPoints(); }; // return number of bytes needed for serialization int numBytes(); // return array of doubles - user must free memory // when not needed anymore DataValType* data(); // max num points that can be stored int capacity() { return m_data.capacity(); } // change the size of the grid after grid is constructed void resize(int npoints) { m_data.resize(npoints); } // serialize data // If no input parameters are provided, byte stream will be binary // without compression. // char * serialize(int& nbytes, RP_ENCODE_ALG eflag=RP_NO_ENCODING, RP_COMPRESSION cflag=RP_NO_COMPRESSION); RP_ERROR serialize(char * buf, int nbytes, RP_ENCODE_ALG eflag=RP_NO_ENCODING, RP_COMPRESSION cflag=RP_NO_COMPRESSION); RP_ERROR deserialize(const char* buf); void xmlString(std::string& str); void print(); // destructor virtual ~RpGrid1d() { }; // TODO //virtual int xmlPut() { }; //virtual int xmlGet() { }; private: vector m_data; // array of doubles }; #endif