/*

	fileofdouble.h: sequential file of "double" items

	3.4.2001

	Copyright (C) 2001 by Josef Pelikan, MFF UK Prague
		http://sun3.ms.mff.cuni.cz/~pepca/

    VUCAKO Bench is Open Source software (see http://www.opensource.org/
    for description what Open Source is); you may distributed it and/or
    modify it under the terms of GNU General Public License as published
    by the Free Software Foundation; either version 2, or (at your option)
    any later version.

    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

    A copy of the GNU General Public License is available as
    `/usr/doc/copyright/GPL' in the Debian GNU/Linux distribution or on
    the World Wide Web at http://www.gnu.org/copyleft/gpl.html.  You can
    also obtain it by writing to the Free Software Foundation, Inc., 59
    Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef _FILEOFDOUBLE_H
#define _FILEOFDOUBLE_H

#define FileBuffer      2048
#ifndef MaxFileName
#  define MaxFileName    512
#endif

class FileOfDouble {

protected:

    char fn[MaxFileName];
    FILE *f;
    bool readWrite;

    double b[FileBuffer];
    int fPos;
    int used;
    int ptr;
    bool changed;

    void flushBuffer ();
    void readBuffer ();

public:

    FileOfDouble ( const char *fileName, bool RW =true );

    void rewrite ();

    void seek ( int pos );
    
    int tell () const;

    void put ( double d );

    double get ();

    void close ();

    ~FileOfDouble ();

    };

#endif
