-class Array2dFileLabel
-{
-private:
- void init (void);
-
-public:
- kfloat64 calc_time;
- kuint16 label_type;
- kuint16 year;
- kuint16 month;
- kuint16 day;
- kuint16 hour;
- kuint16 minute;
- kuint16 second;
- string label_str;
-
- static const int L_EMPTY = 0;
- static const int L_HISTORY = 1;
- static const int L_USER = 2;
-
- Array2dFileLabel();
-
- Array2dFileLabel(const char* const str, double ctime = 0.);
-
- Array2dFileLabel(const int type, const char* const str, double ctime = 0.);
-
- ~Array2dFileLabel();
-
- string getLabelString (void) const
- { return label_str; }
-
- kfloat64 getCalcTime (void) const
- { return calc_time; }
-
- kfloat64 getLabelType (void) const
- { return label_type; }
-
- string& setLabelString (const char* const str)
- { label_str = str; return (label_str); }
-
- string& setLabelString (const string& str)
- { label_str = str; return (label_str); }
-
- void getDateString (string& str) const;
-};
-
-
-template<class T>
-class Array2dFile
-{
-private:
- void init (void);
- kuint16 signature;
- kuint16 num_labels;
- kuint16 headersize;
- string filename;
- int file_id;
- iostream *io;
- bool bHeaderWritten;
- bool bDataWritten;
-
- bool headerWrite (void);
-
- bool headerRead (void);
-
- bool arrayDataRead (void);
-
- bool labelSeek (unsigned int label_num);
-
- kuint16 mPixelSize;
- kuint16 axis_increment_known;
- kfloat64 mIncX, mIncY;
- kuint16 axis_extent_known;
- kfloat64 mMinX, mMaxX, mMinY, mMaxY;
- kfloat64 mOffsetPV, mScalePV;
- kuint16 mPixelType;
- kuint32 mNX;
- kuint32 mNY;
-
-public:
-
- Array2d<T> *array;
-
- static const int INT8 = 1;
- static const int UINT8 = 2;
- static const int INT16 = 3;
- static const int UINT16 = 4;
- static const int INT32 = 5;
- static const int UINT32 = 6;
- static const int FLOAT32 = 7;
- static const int FLOAT64 = 8;
-
- Array2dFile (unsigned int nx, unsigned int ny);
- Array2dFile (const char* const filename);
- Array2dFile (const char* const filename, unsigned int nx, unsigned int ny);
- ~Array2dFile ();
-
- unsigned int getNumLabels (void) const
- { return num_labels; }
-
- bool labelRead (Array2dFileLabel& label, unsigned int label_num);
-
- void labelAdd (const Array2dFileLabel& label);
-
- void labelAdd (const char* const label_str, double calc_time=0.);
-
- void labelAdd (int type, const char* const label_str, double calc_time=0.);
-
- void labelsCopy (Array2dFile& file, const char* const idStr = NULL);
-
- void fileClose (void);
-
- void setPixelType (int type)
- { mPixelType = type; }
-
- kuint32 nx (void) const
- { return mNX; }
-
- kuint32 ny (void) const
- { return mNY; }
-
- void setAxisIncrement (double mIncX, double mIncY);
-
- void setAxisExtent (double mMinX, double mMaxX, double mMinY, double mMaxY);
-
- void getPixelValueRange (T& pvmin, T& pvmax) const;
-
- void doPixelOffsetScale (double offset, double scale);
-
- T** getArray (void) const
- { return (array == NULL ? NULL : array->getArray()); }
-
- bool arrayDataWrite (void);
-
- void arrayDataClear (void);
-
- bool fileRead (void);
-
- bool fileCreate (void);
-
- const string& GetFilename (void) const
- { return filename; }
-};
-
-
-template<class T>
-Array2dFile<T>::Array2dFile (unsigned int x, unsigned int y)
-{
- init();
- mNX = x;
- mNY = y;
- array = new Array2d<T> (mNX, mNY);
-}
-
-template<class T>
-Array2dFile<T>::Array2dFile (const char * const str, unsigned int x, unsigned int y)
- : filename(str)
-{
- init();
- mNX = x;
- mNY = y;
- array = new Array2d<T> (mNX, mNY);
-}
-
-template<class T>
-Array2dFile<T>::Array2dFile (const char * const str)
- : filename(str)
-{
- init();
-}
-
-template<class T>
-void
-Array2dFile<T>::init (void)
-{
- mPixelSize = sizeof(T);
- signature = ('I' * 256 + 'F');
- file_id = -1;
- mNX = 0;
- mNY = 0;
- headersize = 0;
- num_labels = 0;
- axis_increment_known = false;
- axis_extent_known = false;
- mIncX = mMinY = 0;
- mMinX = mMaxX = mMinY = mMaxY = 0;
- mOffsetPV = 0;
- mScalePV = 1;
- array = NULL;
- io = NULL;
-
-#if 0
- const type_info& t_id = typeid(T);
- cout << t_id.name() << endl;
- const type_info& comp_id = typeid(T);
-
- if (t_id == comp_id)
- mPixelType = FLOAT64;
- else if (t_id == typeid(kfloat32))
- mPixelType = FLOAT32;
- else if (t_id == typeid(kint32))
- mPixelType = INT32;
- else if (t_id == typeid(kuint32))
- mPixelType = UINT32;
- else if (t_id == typeid(kint16))
- mPixelType = INT16;
- else if (t_id == typeid(kuint16))
- mPixelType = UINT16;
- else if (t_id == typeid(kint8))
- mPixelType = INT8;
- else if (t_id == typeid(kuint8))
- mPixelType = UINT8;
- else