
/*-----------------------------------------------------------------------------------------------*/
/* jtables_io.h                                                                                  */
/* copyright (c) innovaphone 2021                                                                */
/*                                                                                               */
/* abstract IO interface to persistent storage                                                   */
/*-----------------------------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------------------------*/
/* IJTablesIo                                                                                    */
/*-----------------------------------------------------------------------------------------------*/

class IJTablesIo {
public:
    virtual void SetDatabase(class IDatabase * database) {};
    virtual class IJTableIo * CreateJTableIo(class UJTableIo * user, const char * name) = 0;
};

/*-----------------------------------------------------------------------------------------------*/
/* IJTableIo                                                                                     */
/*-----------------------------------------------------------------------------------------------*/

class IJTableIo {
public:
    virtual const char * GetName() = 0;
    virtual void Reset(class UJTableIoReset * user) = 0;
    virtual void Init(class UJTableIoInit * user, int idLevels, int indexLevels, int maxIdNodes, int maxIndexNodes) = 0;
    virtual void PutObject0Info(class json_io & json, word base, char * & tmp) = 0;
    virtual void WriteObject0(class UJTableIoWriteObject0 * user, const char * text) = 0;
    virtual void ReadObject0(class UJTableIoReadObject0 * user) = 0;
    virtual void GetObject0Info(class json_io & json, word base) = 0;
    virtual void WriteObject(class UJTableIoWriteObject * user, long64 id, long64 usn, bool start, bool end, int cl, const char * text, int len) = 0;
    virtual void ReadObject(class UJTableIoReadObject * user, long64 usn, int cl, long64 id, int len) = 0;
    virtual void WriteIndex(class UJTableIoWriteIndex * user, int cl, long64 id, int len, int index, const char * find, long64 usn) = 0;
    virtual void FindFirstIndex(class UJTableIoFindFirstIndex * user, int index, const char * find, bool right) = 0;
    virtual void FindNextIndex(class UJTableIoFindNextIndex * user, int index, const char * find, long64 usn, bool right) = 0;
    virtual void Transaction(class UJTableIoTransaction * user, bool on) = 0;
    virtual void WriteOp(class UJTableIoWriteOp * user, long64 usn, long64 id) = 0;
    virtual void GetObject(class UJTableIoGetObject * user, long64 ofs, bool start) = 0;
    virtual void HouseKeeping() = 0;

    virtual void DumpInfo() = 0;
};

class UJTableIo {
public:
    virtual char * BuildFind(int index, char * text) = 0;
};

/*-----------------------------------------------------------------------------------------------*/

class UJTableIoReset {
public:
    virtual void JTableIoResetResult() = 0;
};

class UJTableIoInit {
public:
    virtual void JTableIoInitResult(long64 usn, long64 id) = 0;
};

class UJTableIoWriteObject0 {
public:
    virtual void JTableIoWriteObject0Result(const char * error) = 0;
};

class UJTableIoReadObject0 {
public:
    virtual void JTableIoReadObject0Result(const char * error, char * text) = 0;
};

class UJTableIoWriteObject {
public:
    virtual void JTableIoWriteObjectResult(const char * error) = 0;
};

class UJTableIoReadObject {
public:
    virtual void JTableIoReadObjectResult(const char * error, int cl, long64 id, long64 usn, char * text) = 0;
};

class UJTableIoWriteIndex {
public:
    virtual void JTableIoWriteIndexResult(const char * error) = 0;
};

class UJTableIoFindFirstIndex {
public:
    virtual void JTableIoFindFirstIndexResult(const char * error, int cl, long64 id, int len, const char * find, long64 usn) = 0;
};

class UJTableIoFindNextIndex {
public:
    virtual void JTableIoFindNextIndexResult(const char * error, int cl, long64 id, int len, const char * find, long64 usn) = 0;
};

class UJTableIoTransaction {
public:
    virtual void JTableIoTransactionResult(const char * error, bool on) = 0;
};

class UJTableIoWriteOp {
public:
    virtual void JTableIoWriteOpResult(const char * error) = 0;
};

class UJTableIoGetObject {
public:
    virtual void JTableIoGetObjectResult(const char * error, int cl, long64 id, long64 usn, int len, char * buffer, long64 ofs, bool start) = 0;
};
