/*
 * HnBlockFile.hh
 *
 * DO NOT EDIT THIS FILE!
 *
 * This file is automatically generated by obj2ptr.
 * 2002/09/13 12:41:10
 */

#ifndef _HnBlockFile_hh
#define _HnBlockFile_hh

#ifndef _HNSRTIMP
#ifdef _MSC_VER
#define _HNSRTIMP _declspec(dllimport)
#else
#define _HNSRTIMP
#endif
#endif

#include "HnSRTree/HnPointer.hh"

#ifdef _MSC_VER
#include <sys/types.h>
#else
#include <unistd.h>
#endif
#include "HnSRTree/HnBlockStream.hh"

/*
 * HnBlockFile
 */

class _HNSRTIMP HnBlockFile: public HnPointer {
private:
    friend class HnBlockFileObj;
    HnBlockFile(const HnBlockFileObj *ptr) {
	HnPointer::assign((HnObject *)ptr);
    }
    HnBlockFileObj *getObject(void) const {
	return (HnBlockFileObj *)HnPointer::getObject();
    }
public:
    static const HnBlockFile null;
    HnBlockFile(void) {}
public:
    _HNSRTIMP friend HnBlockFile
    new_HnBlockFile(const char *fileName, int blockSize);
    _HNSRTIMP friend HnBlockFile
    new_HnBlockFile(const char *fileName, const char *mode);
    _HNSRTIMP friend HnBlockFile
    new_HnBlockFile(int blockSize);

    int getBlockSize(void);
    off_t getFileSize(void);

    /* super block (the first block is reserved for the super block) */
    int getSuperBlockCapacity(void) const;
    void readSuperBlock(HnBlockStream &blockStream);
    void writeSuperBlock(const HnBlockStream &blockStream);

    /* regular blocks */
    void readBlock(off_t offset, HnBlockStream &blockStream);
    void writeBlock(off_t offset, const HnBlockStream &blockStream);

    void close(void);

    HnBool dumpToFile(const char *fileName);
    HnBool dumpToFileStream(FILE *fp);
};

#include "HnSRTree/HnString.hh"

#define HnClass HnBlockFile
#include "HnSRTree/HnClassArray.hh"

#include "HnSRTree/HnBlockFileObj.hh"

inline int
HnBlockFile::getBlockSize(void)
{
    return getObject()->getBlockSize();
}

inline off_t
HnBlockFile::getFileSize(void)
{
    return getObject()->getFileSize();
}

inline int
HnBlockFile::getSuperBlockCapacity(void) const
{
    return getObject()->getSuperBlockCapacity();
}

inline void
HnBlockFile::readSuperBlock(HnBlockStream &blockStream)
{
    getObject()->readSuperBlock(blockStream);
}

inline void
HnBlockFile::writeSuperBlock(const HnBlockStream &blockStream)
{
    getObject()->writeSuperBlock(blockStream);
}

inline void
HnBlockFile::readBlock(off_t offset, HnBlockStream &blockStream)
{
    getObject()->readBlock(offset, blockStream);
}

inline void
HnBlockFile::writeBlock(off_t offset, const HnBlockStream &blockStream)
{
    getObject()->writeBlock(offset, blockStream);
}

inline void
HnBlockFile::close(void)
{
    getObject()->close();
}

inline HnBool
HnBlockFile::dumpToFile(const char *fileName)
{
    return getObject()->dumpToFile(fileName);
}

inline HnBool
HnBlockFile::dumpToFileStream(FILE *fp)
{
    return getObject()->dumpToFileStream(fp);
}


#endif /* _HnBlockFile_hh */
