Main Page | Class Hierarchy | Compound List | File List | Compound Members

BxArray.h

00001 // ##################################################################
00002 // Binx
00003 // $Id: BxArray_8h-source.html,v 1.1.1.1 2006/04/19 14:19:02 edikt2 Exp $
00004 //
00005 // Base class for all three array types.
00006 // ##################################################################
00007 /*
00008 
00009 //  edikt::BinX
00010 //  www.edikt.org
00011 //  support@edikt.org
00012 
00013 // Copyright (c) 2004 The University of Edinburgh.
00014 
00015 */
00016 
00017 #ifndef __BxArray__
00018 #define __BxArray__
00019 
00020 #include "BxDataObject.h"
00021 #include "BxArrayBuffer.h"
00022 #include "BxDimension.h"
00023 
00051 class DECLSPEC BxArray : public BxDataObject
00052 {
00053 protected:
00054     long    arrayOffset_;   //<absolute offset of the array in the binary file
00055     int     dimensions_;  //<number of dimensions in this array
00056     BxDimension ** dims_;   //<collection of dimension descriptions, one per dimension
00057     BxDataObject * elementType_;  //<type of element contained in the array
00058     BxArrayBuffer * arraybuf_;    //<array buffer window
00059 
00060     void deleteDims();    //delete all dims_ instances and the list itself
00061     void allocateBuffer(); //allocate array buffer for the dimension elements
00062     char * toArrayHeader(bool); //used by toString and toStream
00063     void toStreamOfDimensions(int dim, FILE* stream);
00064     void toStreamOfDimensionsBinary(int, FILE*);
00065     void toStreamOfDimensionsBinary(int, FILE*, BxByteOrder);
00066 
00067 public:
00068     BxArray();
00069     BxArray(int dim);
00070     BxArray(const BxArray& copy);
00071     virtual ~BxArray();
00072 
00073     virtual char* className() const { return "BxArray"; }
00074     virtual BxArray* clone() const;
00075     int count(); //Returns the number of elements for all dimension
00076     virtual void resize();  //calculate the size of the array including blockSize
00077     virtual void setByteOrder(BxByteOrder bo);
00078     virtual char * toString(bool xml);
00079     virtual bool toStream(FILE*);
00080     virtual bool toStreamBinary(FILE*);
00081 
00082         // Write out the binary data with the specified byte order
00083     virtual bool toStreamBinary(FILE*, BxByteOrder);
00084     virtual void readFromBuffer(const byte * buf);
00085     virtual bool readFromFile();
00086 
00087     int getDimensions() const { return dimensions_; }   //how many dimensions
00088     int getIndexFrom(int dim) const;
00089     int getIndexTo(int dim) const;
00090     int getCount(int dim) const;                        //records per dimension
00091     char * getDimName(int dim) const;
00092     int getElementSize() const;    //datatype of element
00093     BxDataObject * getElementType() const { return elementType_; }
00094 
00095     BxDataObject * get(int d1, int d2); //two-dimensional
00096     BxDataObject * get(int d1, int d2, int d3);  //three-dimensional
00097     BxDataObject * get(int d1, int d2, int d3, int d4); //four-D
00098     BxDataObject * getMore(int d1, ...);
00099     virtual BxDataObject * get(int index);    //one-dimensional access
00100     virtual BxDataObject * getNext();   //flat visit of cells
00101 
00102     void setElementType(BxDataObject * elemObj);
00103     void setDimensions(int dims);
00104     bool setDimension(int, BxDimension *);
00105     void setIndexFrom(int dim, int from);
00106     void setIndexTo(int dim, int to);
00107     void setCount(int dim, int count);
00108 
00109     void addDimension(BxDimension *);
00110     void addDimensionInFront(BxDimension *);
00111     bool addElement(BxDataObject *); //append an element to the array data
00112 
00113     void toFirst();  //move pointer to 0 for getNext()
00114 
00115     void writeDimensions(int n, bool checkIndex, FILE * stream);
00116     void flushBuffer();
00117 };
00118 
00119 #endif
00120 

Generated on Fri May 6 13:36:17 2005 for edikt::BinX by doxygen 1.3.3