// CodeGear C++Builder
// Copyright (c) 1995, 2021 by Embarcadero Technologies, Inc.
// All rights reserved

// (DO NOT EDIT: machine generated header) 'ABSDiskEngine.pas' rev: 35.00 (Windows)

#ifndef AbsdiskengineHPP
#define AbsdiskengineHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx      // Zero-length empty class member 
#pragma pack(push,8)
#include <System.hpp>
#include <SysInit.hpp>
#include <System.SysUtils.hpp>
#include <System.Classes.hpp>
#include <Winapi.Windows.hpp>
#include <System.Math.hpp>
#include <ABSExcept.hpp>
#include <ABSBase.hpp>
#include <ABSBaseEngine.hpp>
#include <ABSBTree.hpp>
#include <ABSMemory.hpp>
#include <ABSPage.hpp>
#include <ABSCompression.hpp>
#include <ABSExpressions.hpp>
#include <ABSSecurity.hpp>
#include <ABSCipher.hpp>
#include <ABSDecUtil.hpp>
#include <ABSConverts.hpp>
#include <ABSTypes.hpp>
#include <ABSConst.hpp>

//-- user supplied -----------------------------------------------------------

namespace Absdiskengine
{
//-- forward type declarations -----------------------------------------------
class DELPHICLASS TABSDiskDatabaseData;
class DELPHICLASS TABSSmallRecordPage;
class DELPHICLASS TABSDiskRecordManager;
class DELPHICLASS TABSSmallBlobPage;
class DELPHICLASS TABSDiskBlobManager;
class DELPHICLASS TABSDiskTableData;
class DELPHICLASS TABSDatabaseFile;
class DELPHICLASS TABSDatabaseFreeSpaceManager;
class DELPHICLASS TABSDTPCTableInfo;
class DELPHICLASS TABSDTPCSessionInfo;
class DELPHICLASS TABSDiskTablePagesCacheManager;
class DELPHICLASS TABSDiskPageManager;
class DELPHICLASS TABSInternalDBTransactedAccessFile;
class DELPHICLASS TABSInternalDBDirectAccessFile;
class DELPHICLASS TABSActiveSessionsFile;
class DELPHICLASS TABSTableListFile;
class DELPHICLASS TABSTableLocksFile;
class DELPHICLASS TABSSystemDirectory;
struct TABSTableLock;
class DELPHICLASS TABSTableLockList;
class DELPHICLASS TABSDatabaseTableLockManager;
//-- type declarations -------------------------------------------------------
#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSDiskDatabaseData : public Absbaseengine::TABSDatabaseData
{
	typedef Absbaseengine::TABSDatabaseData inherited;
	
private:
	TABSSystemDirectory* FSystemDir;
	TABSActiveSessionsFile* FActiveSessionsFile;
	TABSTableListFile* FTableListFile;
	Abssecurity::TABSPassword FPassword;
	int FMaxSessionCount;
	int FPageSize;
	int FPageCountInExtent;
	TABSDatabaseTableLockManager* FTableLockManager;
	bool FSingleUserConnected;
	void __fastcall OpenDatabase(Absbase::TABSBaseSession* Session, bool Exclusive, bool &RepairNeeded);
	void __fastcall CloseDatabase();
	Abssecurity::PABSPassword __fastcall GetPassword();
	bool __fastcall GetEncrypted();
	
protected:
	void __fastcall AddTable(int TableID, System::AnsiString TableName, int MetadataFilePageNo, int MostUpdatedFilePageNo, int LocksFilePageNo);
	void __fastcall RemoveTable(System::AnsiString TableName);
	void __fastcall OpenTable(System::AnsiString TableName, /* out */ int &TableID, /* out */ int &MetadataFilePageNo, /* out */ int &MostUpdatedFilePageNo, /* out */ int &LocksFilePageNo);
	void __fastcall RenameTable(System::AnsiString TableName, System::AnsiString NewTableName);
	
public:
	__fastcall TABSDiskDatabaseData();
	__fastcall virtual ~TABSDiskDatabaseData();
	virtual Absbaseengine::TABSTableData* __fastcall CreateTableData(Absbase::TABSCursor* Cursor);
	virtual void __fastcall CreateDatabase();
	virtual void __fastcall ConnectSession(Absbase::TABSBaseSession* Session);
	virtual void __fastcall DisconnectSession(Absbase::TABSBaseSession* Session);
	virtual void __fastcall FreeIfNoSessionsConnected();
	virtual void __fastcall GetTablesList(System::Classes::TStrings* List);
	void __fastcall TruncateDatabase();
	int __fastcall GetDBFileConnectionsCount();
	void __fastcall LockTables();
	void __fastcall UnlockTables();
	virtual void __fastcall Commit(int SessionID, bool DoFlushBuffers = true);
	virtual void __fastcall Rollback(int SessionID);
	virtual void __fastcall FlushBuffers();
	virtual int __fastcall GetNewObjectId();
	bool __fastcall GetSuppressDBHeaderErrors();
	void __fastcall SetSuppressDBHeaderErrors(bool Value);
	__property Abssecurity::PABSPassword Password = {read=GetPassword};
	__property bool Encrypted = {read=GetEncrypted, nodefault};
	__property int MaxSessionCount = {read=FMaxSessionCount, write=FMaxSessionCount, nodefault};
	__property int PageSize = {read=FPageSize, write=FPageSize, nodefault};
	__property int PageCountInExtent = {read=FPageCountInExtent, write=FPageCountInExtent, nodefault};
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSSmallRecordPage : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	Abspage::TABSPage* LPage;
	int FRecordBufferSize;
	int FMaxRecordsOnPage;
	int FRecordDataOffset;
	bool __fastcall FindUnusedRecordSlot(int &SlotNo);
	__int64 __fastcall GetRecordCount();
	
public:
	__fastcall TABSSmallRecordPage(Abspage::TABSPage* Page, int RecordBufferSize, int MaxRecordsOnPage);
	void __fastcall AddRecord(System::PByte RecordBuffer, Abstypes::TABSPageItemID &RecordID);
	bool __fastcall UpdateRecord(System::PByte RecordBuffer, const Abstypes::TABSPageItemID &RecordID);
	bool __fastcall DeleteRecord(const Abstypes::TABSPageItemID &RecordID);
	bool __fastcall GetRecordBuffer(const Abstypes::TABSPageItemID &RecordID, System::PByte RecordBuffer);
	void __fastcall GetFirstRecordID(Abstypes::TABSPageItemID &RecordID);
	void __fastcall GetLastRecordID(Abstypes::TABSPageItemID &RecordID);
	bool __fastcall GetNextRecordID(Abstypes::TABSPageItemID &RecordID);
	bool __fastcall GetPriorRecordID(Abstypes::TABSPageItemID &RecordID);
	void __fastcall GetRecordID(int RecNoOnPage, Abstypes::TABSPageItemID &RecordID);
	void __fastcall GetRecNoOnPage(const Abstypes::TABSPageItemID &RecordID, int &RecNoOnPage);
	__property __int64 RecordCount = {read=GetRecordCount};
public:
	/* TObject.Destroy */ inline __fastcall virtual ~TABSSmallRecordPage() { }
	
};

#pragma pack(pop)

class PASCALIMPLEMENTATION TABSDiskRecordManager : public Absbaseengine::TABSBaseRecordManager
{
	typedef Absbaseengine::TABSBaseRecordManager inherited;
	
	
private:
	typedef System::DynamicArray<__int64> _TABSDiskRecordManager__1;
	
	
private:
	Absbtree::TABSBTreeRecordPageIndex* FRecordPageIndex;
	Abspage::TABSPageManager* LPageManager;
	Absbaseengine::TABSBaseFieldManager* LFieldManager;
	TABSInternalDBTransactedAccessFile* LMostUpdatedFile;
	int FMaxRecordsOnPage;
	_TABSDiskRecordManager__1 FLastAutoIncValues;
	int FDiskRecordBufferSize;
	System::Byte *FTempDiskRecordBuffer;
	TABSDiskTableData* LTableData;
	bool __fastcall IsRecordPageValid(Abspage::TABSPage* Page);
	void __fastcall GetFirstRecord(int SessionID, Abstypes::TABSNavigationInfo &NavigationInfo);
	void __fastcall GetLastRecord(int SessionID, Abstypes::TABSNavigationInfo &NavigationInfo);
	void __fastcall GetNextRecord(int SessionID, Abstypes::TABSNavigationInfo &NavigationInfo);
	void __fastcall GetPriorRecord(int SessionID, Abstypes::TABSNavigationInfo &NavigationInfo);
	void __fastcall GetCurrentRecord(int SessionID, Abstypes::TABSNavigationInfo &NavigationInfo);
	
public:
	__fastcall TABSDiskRecordManager(Abspage::TABSPageManager* PageManager, Absbaseengine::TABSBaseFieldManager* FieldManager, TABSInternalDBTransactedAccessFile* MostUpdatedFile, TABSDiskTableData* TableData);
	__fastcall virtual ~TABSDiskRecordManager();
	void __fastcall Init(int RecordBufferSize, int DiskRecordBufferSize, int FieldCount);
	void __fastcall LoadMostUpdated(System::PByte Buf, int &Offset);
	void __fastcall SaveMostUpdated(System::PByte Buf, int &Offset);
	void __fastcall LoadMetadata(System::Classes::TStream* Stream);
	void __fastcall SaveMetadata(System::Classes::TStream* Stream);
	void __fastcall CreateRecordPageIndex();
	virtual void __fastcall Empty(int SessionID);
	void __fastcall Delete(int SessionID);
	virtual bool __fastcall AddRecord(int SessionID, System::PByte RecordBuffer, Abstypes::TABSPageItemID &RecordID);
	virtual bool __fastcall UpdateRecord(int SessionID, System::PByte RecordBuffer, const Abstypes::TABSPageItemID &RecordID);
	virtual bool __fastcall DeleteRecord(int SessionID, Abstypes::TABSPageItemID &RecordID);
	virtual void __fastcall GetRecordBuffer(int SessionID, Abstypes::TABSNavigationInfo &NavigationInfo);
	virtual int __fastcall CompareRecordID(const Abstypes::TABSPageItemID &RecordID1, const Abstypes::TABSPageItemID &RecordID2);
	virtual __int64 __fastcall GetApproximateRecNo(int SessionID, const Abstypes::TABSPageItemID &RecordID);
	void __fastcall SetRecNo(int SessionID, __int64 RecNo, Abstypes::TABSPageItemID &RecordID);
	void __fastcall GetRecNo(int SessionID, const Abstypes::TABSPageItemID &RecordID, __int64 &RecNo);
	void __fastcall RebuildRecordPageIndex(int SessionID);
	void __fastcall ValidateRecordPageIndex(int SessionID);
	__property Absbtree::TABSBTreeRecordPageIndex* RecordPageIndex = {read=FRecordPageIndex};
};


#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSSmallBlobPage : public System::TObject
{
	typedef System::TObject inherited;
	
protected:
	Abspage::TABSPage* LPage;
	void __fastcall SetBlobCount(int Value);
	int __fastcall GetBlobCount();
	Abstypes::PABSDiskBLOBHeader __fastcall BlobHeader(int Index);
	System::PByte __fastcall BlobData(int Index);
	System::Word __fastcall GetNewBlobID();
	
public:
	__fastcall TABSSmallBlobPage(Abspage::TABSPage* Page);
	void __fastcall AddBlob(Abstypes::PABSDiskBLOBCache BlobCache, Abstypes::TABSPageItemID &PageItemID);
	void __fastcall DeleteBlob(const Abstypes::TABSPageItemID &PageItemID, int &BlobSize);
	void __fastcall ReadBlob(Abstypes::PABSDiskBLOBCache BlobCache, const Abstypes::TABSPageItemID &PageItemID);
	__property int BlobCount = {read=GetBlobCount, write=SetBlobCount, nodefault};
public:
	/* TObject.Destroy */ inline __fastcall virtual ~TABSSmallBlobPage() { }
	
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSDiskBlobManager : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	Abspage::TABSPageManager* LPageManager;
	Absbaseengine::TABSBaseFieldManager* LFieldManager;
	Absbaseengine::TABSBaseRecordManager* LRecordManager;
	System::Classes::TList* FBlobCacheList;
	Absbtree::TABSBTreeBlobPageIndex* FBlobPageIndex;
	void __fastcall GetBlobInfo(System::PByte RecordBuffer, int FieldNo, Abstypes::TABSPageItemID &PageItemID, Abstypes::PABSDiskBLOBCache &BlobCache);
	void __fastcall SetBlobInfo(System::PByte RecordBuffer, int FieldNo, const Abstypes::TABSPageItemID &PageItemID);
	void __fastcall CreateBlobCache(System::PByte RecordBuffer, int FieldNo, Abstypes::PABSDiskBLOBCache &BlobCache);
	void __fastcall FreeBlobCache(System::PByte RecordBuffer, int FieldNo, bool ForceClear = false);
	void __fastcall StreamToBlobCache(Abscompression::TABSStream* Stream, Abstypes::PABSDiskBLOBCache BlobCache);
	void __fastcall BlobCacheToStream(Abstypes::PABSDiskBLOBCache BlobCache, System::Classes::TStream* Stream);
	void __fastcall ReadBlobHeader(int SessionID, const Abstypes::TABSPageItemID &PageItemID, Abstypes::TABSDiskBLOBHeader &BlobHeader, Abstypes::PABSDiskBLOBCache BlobCache);
	void __fastcall WriteBlobHeader(int SessionID, const Abstypes::TABSDiskBLOBHeader &BlobHeader, Abstypes::TABSPageItemID &PageItemID);
	void __fastcall ReadBlobData(int SessionID, const Abstypes::TABSPageItemID &PageItemID, const Abstypes::TABSDiskBLOBHeader &BlobHeader, Abstypes::TABSIntegerArray* BlobDataPageList, Abstypes::PABSDiskBLOBCache BlobCache);
	void __fastcall ReadBlobDataPageList(int SessionID, const Abstypes::TABSPageItemID &PageItemID, const Abstypes::TABSPageListLink &PageListLink, Abstypes::TABSIntegerArray* BlobDataPageList, Abstypes::TABSIntegerArray* BlobDataPageListPages);
	void __fastcall ReadLinkToBlobDataPageList(int SessionID, const Abstypes::TABSPageItemID &PageItemID, Abstypes::TABSPageListLink &PageListLink);
	void __fastcall ReadMultiPagesBlob(int SessionID, const Abstypes::TABSPageItemID &PageItemID, const Abstypes::TABSDiskBLOBHeader &BlobHeader, Abstypes::PABSDiskBLOBCache BlobCache);
	void __fastcall WriteBlobData(int SessionID, Abstypes::PABSDiskBLOBCache BlobCache, const Abstypes::TABSPageItemID &PageItemID, const Abstypes::TABSDiskBLOBHeader &BlobHeader, int &LastPageNo, System::Word &LastPageOffset, Abstypes::TABSIntegerArray* BlobDataPageList);
	void __fastcall WriteBlobDataPageList(int SessionID, const Abstypes::TABSPageItemID &PageItemID, const Abstypes::TABSDiskBLOBHeader &BlobHeader, int LastPageNo, System::Word LastPageOffset, Abstypes::TABSIntegerArray* BlobDataPageList, Abstypes::TABSPageListLink &PageListLink);
	void __fastcall WriteLinkToBlobDataPageList(int SessionID, const Abstypes::TABSPageItemID &PageItemID, const Abstypes::TABSPageListLink &PageListLink);
	void __fastcall WriteMultiPagesBlob(int SessionID, Abstypes::PABSDiskBLOBCache BlobCache, Abstypes::TABSPageItemID &PageItemID, const Abstypes::TABSDiskBLOBHeader &BlobHeader);
	void __fastcall InternalReadSmallBlob(int SessionID, Abstypes::PABSDiskBLOBCache BlobCache, const Abstypes::TABSPageItemID &PageItemID);
	void __fastcall InternalReadLargeBlob(int SessionID, Abstypes::PABSDiskBLOBCache BlobCache, const Abstypes::TABSPageItemID &PageItemID);
	bool __fastcall IsProbablyLargeBlob(int SessionID, const Abstypes::TABSPageItemID &PageItemID);
	void __fastcall InternalReadBlob(int SessionID, Abstypes::PABSDiskBLOBCache BlobCache, const Abstypes::TABSPageItemID &PageItemID);
	void __fastcall InternalWriteSmallBlob(int SessionID, Abstypes::PABSDiskBLOBCache BlobCache, Abstypes::TABSPageItemID &PageItemID);
	void __fastcall InternalWriteLargeBlob(int SessionID, Abstypes::PABSDiskBLOBCache BlobCache, Abstypes::TABSPageItemID &PageItemID);
	bool __fastcall IsSmallBlob(__int64 BlobSize);
	void __fastcall InternalWriteBlob(int SessionID, Abstypes::PABSDiskBLOBCache BlobCache, Abstypes::TABSPageItemID &PageItemID);
	void __fastcall InternalDeleteSmallBlob(int SessionID, Abstypes::TABSPageItemID &PageItemID);
	void __fastcall InternalDeleteLargeBlob(int SessionID, Abstypes::TABSPageItemID &PageItemID);
	void __fastcall InternalDeleteBlob(int SessionID, Abstypes::TABSPageItemID &PageItemID);
	
public:
	__fastcall TABSDiskBlobManager(Abspage::TABSPageManager* PageManager, Absbaseengine::TABSBaseFieldManager* FieldManager, Absbaseengine::TABSBaseRecordManager* RecordManager);
	__fastcall virtual ~TABSDiskBlobManager();
	void __fastcall LoadMetadata(System::Classes::TStream* Stream);
	void __fastcall SaveMetadata(System::Classes::TStream* Stream);
	void __fastcall CreateBlobPageIndex();
	void __fastcall Empty(int SessionID);
	void __fastcall Delete(int SessionID);
	void __fastcall ReadBlob(int SessionID, System::PByte RecordBuffer, int FieldNo);
	void __fastcall WriteBlob(int SessionID, System::PByte RecordBuffer, int FieldNo);
	void __fastcall WriteBlobs(int SessionID, System::PByte RecordBuffer);
	void __fastcall DeleteBlob(int SessionID, System::PByte RecordBuffer, int FieldNo);
	void __fastcall DeleteBlobs(int SessionID, System::PByte RecordBuffer);
	void __fastcall CopyBlobFromRecordBufferToStream(int SessionID, System::PByte RecordBuffer, int FieldNo, Abstypes::TABSBLOBDescriptor &BLOBDescriptor, System::Classes::TStream* Stream);
	void __fastcall CopyBlobFromStreamToRecordBuffer(System::PByte RecordBuffer, int FieldNo, Abscompression::TABSStream* Stream);
	void __fastcall ClearBlobInRecordBuffer(System::PByte RecordBuffer, int FieldNo, bool ForceClear = false);
	void __fastcall GetDirectBlobInfoFromRecordBuffer(int SessionID, System::PByte RecordBuffer, int FieldNo, Abstypes::TABSPartialTemporaryBLOBDescriptor &BLOBDescriptor, System::PByte &pBlobData);
	void __fastcall SetDirectBlobInfoFromRecordBuffer(int SessionID, System::PByte RecordBuffer, int FieldNo, Abstypes::TABSPartialTemporaryBLOBDescriptor &BLOBDescriptor, System::PByte &pBlobData);
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSDiskTableData : public Absbaseengine::TABSTableData
{
	typedef Absbaseengine::TABSTableData inherited;
	
private:
	int FTableID;
	TABSTableLocksFile* FTableLocksFile;
	TABSInternalDBTransactedAccessFile* FTableMetadataFile;
	TABSInternalDBTransactedAccessFile* FTableMostUpdatedFile;
	TABSDiskBlobManager* FBlobManager;
	Abspage::TABSPageManager* FTemporaryPageManager;
	bool FExclusive;
	bool FIsChangingTableList;
	int FLastUsedTableState;
	void __fastcall CreateTableFiles();
	void __fastcall DeleteTableFiles();
	void __fastcall OpenTableFiles(int MetadataFilePageNo, int MostUpdatedFilePageNo, int LocksFilePageNo);
	void __fastcall FreeTableFiles();
	void __fastcall LoadMetadataFile(int SessionID);
	void __fastcall SaveMetadataFile(int SessionID);
	void __fastcall CleanMostUpdated(int SessionID);
	void __fastcall SaveMostUpdated(int SessionID);
	
public:
	void __fastcall LoadMostUpdated(int SessionID);
	
private:
	int __fastcall GetDiskRecordBufferSize();
	void __fastcall RebuildRecordPageIndex(int SessionID);
	void __fastcall ValidateAndRepairMostUpdatedAndRecordPageIndex(Absbase::TABSCursor* Cursor);
	void __fastcall ValidateRecordPageIndex(Absbase::TABSCursor* Cursor);
	
protected:
	virtual __int64 __fastcall GetBitmapRecordCount(int SessionID);
	virtual __int64 __fastcall GetBitmapRecNoByRecordID(const Abstypes::TABSPageItemID &RecordID);
	virtual Abstypes::TABSPageItemID __fastcall GetRecordIDByBitmapRecNo(__int64 RecordNo);
	virtual void __fastcall CreateRecordManager();
	void __fastcall CreateBlobManager();
	virtual void __fastcall CreateFieldManager(Absbase::TABSFieldDefs* FieldDefs);
	virtual void __fastcall CreateIndexManager(Absbase::TABSIndexDefs* IndexDefs);
	virtual void __fastcall CreateConstraintManager(Absbase::TABSConstraintDefs* ConstraintDefs);
	
public:
	__fastcall TABSDiskTableData(Absbaseengine::TABSDatabaseData* aDatabaseData);
	__fastcall virtual ~TABSDiskTableData();
	void __fastcall FreeIfNoCursorsConnected();
	virtual void __fastcall ApplyChanges(int SessionID, bool InTransaction);
	virtual void __fastcall CancelChanges(int SessionID, bool InTransaction);
	virtual void __fastcall CreateTable(Absbase::TABSCursor* Cursor, Absbase::TABSFieldDefs* FieldDefs, Absbase::TABSIndexDefs* IndexDefs, Absbase::TABSConstraintDefs* ConstraintDefs);
	virtual void __fastcall DeleteTable(Absbase::TABSCursor* Cursor, bool DesignMode = false);
	virtual void __fastcall EmptyTable(Absbase::TABSCursor* Cursor);
	virtual void __fastcall RenameTable(System::UnicodeString NewTableName, Absbase::TABSCursor* Cursor);
	virtual void __fastcall OpenTable(Absbase::TABSCursor* Cursor);
	virtual void __fastcall CloseTable(Absbase::TABSCursor* Cursor);
	virtual void __fastcall RenameField(System::UnicodeString FieldName, System::UnicodeString NewFieldName);
	virtual void __fastcall AddIndex(Absbase::TABSIndexDef* IndexDef, Absbase::TABSCursor* Cursor);
	virtual void __fastcall DeleteIndex(int IndexID, Absbase::TABSCursor* Cursor);
	virtual void __fastcall WriteBLOBFieldToRecordBuffer(Absbase::TABSCursor* Cursor, int FieldNo, Abscompression::TABSStream* BLOBStream);
	virtual void __fastcall ClearBLOBFieldInRecordBuffer(System::PByte RecordBuffer, int FieldNo);
	void __fastcall ClearModifiedBLOBFieldsInRecordBuffer(System::PByte RecordBuffer);
	virtual Abscompression::TABSStream* __fastcall InternalCreateBlobStream(Absbase::TABSCursor* Cursor, bool ToInsert, int FieldNo, Abstypes::TABSBLOBOpenMode OpenMode);
	virtual void __fastcall GetDirectBlobData(Absbase::TABSCursor* Cursor, int FieldNo, System::PByte RecordBuffer, Abstypes::TABSPartialTemporaryBLOBDescriptor &BLOBDescriptor, System::PByte &pBlobData);
	virtual void __fastcall SetDirectBlobData(Absbase::TABSCursor* Cursor, int FieldNo, System::PByte RecordBuffer, Abstypes::TABSPartialTemporaryBLOBDescriptor &BLOBDescriptor, System::PByte &pBlobData);
	virtual void __fastcall FreeDirectBlobData(Absbase::TABSCursor* Cursor, int FieldNo, System::PByte RecordBuffer, Abstypes::TABSPartialTemporaryBLOBDescriptor &BLOBDescriptor, System::PByte &pBlobData);
	virtual bool __fastcall InsertRecord(Absbase::TABSCursor* &Cursor);
	virtual bool __fastcall DeleteRecord(Absbase::TABSCursor* Cursor);
	virtual bool __fastcall UpdateRecord(Absbase::TABSCursor* Cursor);
	virtual void __fastcall ClearBlobsCacheInRecordBuffer(System::PByte Buffer);
	virtual Abstypes::TABSGetRecordResult __fastcall GetRecordBuffer(Absbase::TABSCursor* Cursor, Abstypes::TABSGetRecordMode GetRecordMode);
	virtual bool __fastcall Locate(Absbase::TABSCursor* Cursor, Absexpressions::TABSExpression* SearchExpression);
	virtual bool __fastcall FindKey(Absbase::TABSCursor* Cursor, Abstypes::TABSSearchCondition SearchCondition);
	virtual void __fastcall SetRecNo(Absbase::TABSCursor* Cursor, __int64 RecNo);
	virtual __int64 __fastcall GetRecNo(Absbase::TABSCursor* Cursor);
	virtual __int64 __fastcall InternalGetRecordCount(Absbase::TABSCursor* Cursor);
	virtual void __fastcall InternalSetRecNo(Absbase::TABSCursor* Cursor, __int64 RecNo);
	virtual __int64 __fastcall InternalGetRecNo(Absbase::TABSCursor* Cursor);
	virtual __int64 __fastcall LastAutoincValue(int FieldNo, Absbase::TABSBaseSession* Session);
	virtual void __fastcall Rollback(int SessionID);
	bool __fastcall LockTable(int SessionID, Abstypes::TABSLockType LockType, int TryCount, int Delay, bool AllowXIRWAfterSIRW = true);
	bool __fastcall UnlockTable(int SessionID, Abstypes::TABSLockType LockType, bool IgnoreIfNoLock = false);
	bool __fastcall LockRecord(int SessionID, const Abstypes::TABSPageItemID &RecordID, int TryCount, int Delay);
	bool __fastcall UnlockRecord(int SessionID, const Abstypes::TABSPageItemID &RecordID);
	bool __fastcall IsRecordLocked(int SessionID, const Abstypes::TABSPageItemID &RecordID);
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSDatabaseFile : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	System::UnicodeString FFileName;
	Abstypes::TABSAccessMode FAccessMode;
	Abstypes::TABSShareMode FShareMode;
	unsigned FAttrFlags;
	NativeUInt FHandle;
	bool FIsOpened;
	int DesignOpenCount;
	bool FWasCriticalError;
	unsigned __fastcall AccessModeToWindowsMode(Abstypes::TABSAccessMode am);
	unsigned __fastcall ShareModeToWindowsMode(Abstypes::TABSShareMode sm);
	void __fastcall CheckOpened(System::AnsiString OperationName);
	void __fastcall CheckClosed(System::AnsiString OperationName);
	bool __fastcall InternalSeek(__int64 Offset);
	void __fastcall Seek(__int64 Offset, int ErrorCode = 0x0);
	void __fastcall SetPosition(__int64 Offset);
	__int64 __fastcall GetPosition();
	void __fastcall SetSize(__int64 NewSize);
	__int64 __fastcall GetSize();
	
public:
	__fastcall TABSDatabaseFile();
	__fastcall virtual ~TABSDatabaseFile();
	void __fastcall CreateAndOpenFile(System::UnicodeString FileName);
	void __fastcall DeleteFile(System::UnicodeString FileName);
	void __fastcall RenameFile(System::UnicodeString OldFileName, System::UnicodeString NewFileName);
	void __fastcall OpenFile(System::UnicodeString FileName, Abstypes::TABSAccessMode AccessMode, Abstypes::TABSShareMode ShareMode);
	void __fastcall CloseFile();
	void __fastcall OpenFileForDesignTime();
	void __fastcall CloseFileForDesignTime();
	bool __fastcall ReopenDatabaseFile();
	void __fastcall ReadBuffer(void *Buffer, const __int64 Count, const __int64 Position, int ErrorCode)/* overload */;
	bool __fastcall ReadBuffer(void *Buffer, const __int64 Count, const __int64 Position)/* overload */;
	void __fastcall WriteBuffer(const void *Buffer, const __int64 Count, const __int64 Position, int ErrorCode);
	void __fastcall FlushFileBuffers();
	bool __fastcall LockByte(__int64 Offset, int Count = 0x1);
	bool __fastcall UnlockByte(__int64 Offset, int Count = 0x1);
	bool __fastcall IsByteLocked(__int64 Offset);
	bool __fastcall IsRegionLocked(__int64 Offset, int Count);
	bool __fastcall FindSignature(__int64 &Offset);
	__property System::UnicodeString FileName = {read=FFileName};
	__property __int64 Size = {read=GetSize, write=SetSize};
	__property bool IsOpened = {read=FIsOpened, nodefault};
	__property __int64 Position = {read=GetPosition, write=SetPosition};
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSDatabaseFreeSpaceManager : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	TABSDiskPageManager* LPageManager;
	int FPageCountInExtent;
	int FPFSPage_PagesAddressed;
	int FEAMPage_ExtentsAddressed;
	int FEAMPage_PagesAddressed;
	int FLastUsedPageNo;
	int FTotalPageCount;
	bool FSuppressDBHeaderErrors;
	int __fastcall GetAddPagesStep();
	int __fastcall GetDelPagesStep();
	Abspage::TABSPage* __fastcall NewPage(int PageNo);
	Abspage::TABSPage* __fastcall ReadPage(int PageNo);
	void __fastcall WriteAndFreePage(Abspage::TABSPage* &Page);
	int __fastcall CorrectEamPageNo(int EamPageNo);
	int __fastcall UncorrectEamPageNo(int EamPageNo);
	int __fastcall EamPageNoForEamPagePosition(int EamPagePosition);
	int __fastcall EamPageNoToEamPagePosition(int EamPageNo);
	int __fastcall EamPageNoForPageNo(int PageNo);
	int __fastcall GetLastEamPagePosition();
	int __fastcall GetLastEamPageNo();
	int __fastcall GetLastPfsPagePosition();
	bool __fastcall PfsPositionsForExtentPosition(const int ExtentPosition, /* out */ int &PfsFirstPagePosition, /* out */ int &PfsLastPagePosition);
	int __fastcall PfsPageNoForPfsPagePosition(int PfsPagePosition);
	int __fastcall PfsPageNoForPageNo(int PageNo);
	bool __fastcall IsPagePfsOrEam(int PageNo);
	int __fastcall FindAndReusePage();
	int __fastcall FindLastUsedPageNo();
	void __fastcall SetPageUsage(int PageNo, bool UsedFlag);
	void __fastcall SetPageUsageToPFS(int PageNo, bool UsedFlag);
	void __fastcall SetPageUsageToEAM(int PageNo, bool UsedFlag);
	
public:
	bool __fastcall GetPageUsageFromPFS(int PageNo);
	
private:
	int __fastcall AddNewPageAndExtentFile();
	void __fastcall TruncateFile();
	void __fastcall ReReadPageCountVariables();
	void __fastcall ReWritePageCountVariables();
	
public:
	__fastcall TABSDatabaseFreeSpaceManager(TABSDiskPageManager* aPageManager);
	int __fastcall GetPage(int DesiredStartPageNo = 0xffffffff);
	void __fastcall FreePage(int PageNo);
	void __fastcall CheckPageNoForSystemPages(int PageNo);
	__property int AddPagesStep = {read=GetAddPagesStep, nodefault};
	__property int DelPagesStep = {read=GetDelPagesStep, nodefault};
	__property bool SuppressDBHeaderErrors = {read=FSuppressDBHeaderErrors, write=FSuppressDBHeaderErrors, nodefault};
public:
	/* TObject.Destroy */ inline __fastcall virtual ~TABSDatabaseFreeSpaceManager() { }
	
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSDTPCTableInfo : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	int TableID;
	int TableSLockCount;
	int TableRWLockCount;
	bool IsMostUpdatedLoaded;
	void __fastcall Clear();
	
public:
	int TableState;
	__fastcall TABSDTPCTableInfo(int aTableID);
	__fastcall virtual ~TABSDTPCTableInfo();
	void __fastcall TableIsSLocked();
	void __fastcall TableIsSUnlocked();
	void __fastcall TableIsRWLocked();
	void __fastcall TableIsRWUnlocked();
	bool __fastcall GetIsMostUpdatedLoaded();
	void __fastcall SetIsMostUpdatedLoaded(int aTableState);
	bool __fastcall IsTableLockedFromModification();
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSDTPCSessionInfo : public System::TObject
{
	typedef System::TObject inherited;
	
	
private:
	typedef System::DynamicArray<TABSDTPCTableInfo*> _TABSDTPCSessionInfo__1;
	
	
private:
	_TABSDTPCSessionInfo__1 FTableInfo;
	System::Classes::TList* FWorkTableIDs;
	
public:
	__fastcall TABSDTPCSessionInfo();
	__fastcall virtual ~TABSDTPCSessionInfo();
	TABSDTPCTableInfo* __fastcall GetTableInfo(int TableID);
	void __fastcall BeginWorkWithTable(int TableID);
	void __fastcall EndWorkWithTable(int TableID);
	bool __fastcall GetWorkTableState(int &WorkTableState);
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSDiskTablePagesCacheManager : public System::TObject
{
	typedef System::TObject inherited;
	
	
private:
	typedef System::DynamicArray<TABSDTPCSessionInfo*> _TABSDiskTablePagesCacheManager__1;
	
	
private:
	_TABSDiskTablePagesCacheManager__1 FSessionInfo;
	TABSDTPCSessionInfo* __fastcall GetSessionInfo(int SessionID);
	
public:
	__fastcall TABSDiskTablePagesCacheManager();
	__fastcall virtual ~TABSDiskTablePagesCacheManager();
	void __fastcall TableIsSLocked(int SessionID, int TableID);
	void __fastcall TableIsSUnlocked(int SessionID, int TableID);
	void __fastcall TableIsRWLocked(int SessionID, int TableID);
	void __fastcall TableIsRWUnlocked(int SessionID, int TableID);
	bool __fastcall GetIsMostUpdatedLoaded(int SessionID, int TableID);
	void __fastcall SetIsMostUpdatedLoaded(int SessionID, int TableID, int TableState);
	void __fastcall BeginWorkWithTable(int SessionID, int TableID);
	void __fastcall EndWorkWithTable(int SessionID, int TableID);
	bool __fastcall GetWorkTableState(int SessionID, int &WorkTableState);
};

#pragma pack(pop)

class PASCALIMPLEMENTATION TABSDiskPageManager : public Abspage::TABSPageManager
{
	typedef Abspage::TABSPageManager inherited;
	
private:
	TABSDatabaseFreeSpaceManager* FDatabaseFreeSpaceManager;
	TABSDatabaseFile* FDatabaseFile;
	Abstypes::TABSDBHeader FDBHeader;
	Abstypes::TABSCryptoHeader FCryptoHeader;
	Abssecurity::TABSPassword FPassword;
	Abstypes::TABSLockedBytes FLockedBytes;
	int FLockDBHeaderCount;
	bool FExclusive;
	TABSDiskTablePagesCacheManager* FTablePagesCacheManager;
	__int64 FOffsetToDBHeader;
	__int64 FOffsetToCryptoHeader;
	__int64 FOffsetToLockedBytes;
	__int64 FOffsetToLastObjectID;
	__int64 FOffsetToFirstPage;
	void __fastcall InitHeaders();
	void __fastcall LoadDBHeader();
	void __fastcall SaveDBHeader(bool PerformExternalAppUpdateCheck = true);
	Abstypes::PABSDBHeader __fastcall GetDbHeader();
	void __fastcall LoadCryptoHeader();
	void __fastcall SaveCryptoHeader();
	void __fastcall LoadLockedBytes();
	void __fastcall SaveLockedBytes();
	Abssecurity::PABSPassword __fastcall GetPassword();
	bool __fastcall GetEncrypted();
	bool __fastcall GetIsOpened();
	bool __fastcall IsFileReadOnly(System::UnicodeString DatabaseFileName, bool &MultiUser);
	__int64 __fastcall GetPageOffset(int PageNo);
	void __fastcall OpenFileForDesignTime();
	void __fastcall CloseFileForDesignTime();
	
protected:
	virtual int __fastcall GetPageCount();
	virtual bool __fastcall IsSafeNotToSyncPage(int SessionID, Abspage::TABSPage* Page);
	virtual void __fastcall UpdatePageTableState(int SessionID, Abspage::TABSPage* Page);
	
public:
	void __fastcall ReadPageRegion(void *Buffer, int PageNo, System::Word Offset, System::Word Count);
	void __fastcall WritePageRegion(const void *Buffer, int PageNo, System::Word Offset, System::Word Count);
	void __fastcall WriteEmptyPage(int PageNo);
	virtual void __fastcall InternalAddPage(Abspage::TABSPage* aPage);
	virtual void __fastcall InternalRemovePage(int PageNo);
	virtual bool __fastcall InternalReadPage(Abspage::TABSPage* aPage);
	virtual void __fastcall InternalWritePage(Abspage::TABSPage* aPage);
	int __fastcall InternalReadPageState(int PageNo);
	void __fastcall InternalWritePageState(int PageNo, int PageState);
	virtual Abspage::TABSPage* __fastcall GetPage(int SessionID, int PageNo, System::Word PageType, bool SynchronizeAllowed = true);
	virtual void __fastcall RemovePage(int SessionID, int PageNo);
	bool __fastcall LockFreeSpaceManager();
	bool __fastcall UnlockFreeSpaceManager();
	bool __fastcall LockTables();
	bool __fastcall UnlockTables();
	bool __fastcall LockDBHeader();
	bool __fastcall UnlockDBHeader();
	bool __fastcall LockLastObjectID();
	bool __fastcall UnlockLastObjectID();
	bool __fastcall LockPageByte(int PageNo, System::Word Offset);
	bool __fastcall UnlockPageByte(int PageNo, System::Word Offset);
	bool __fastcall IsPageByteLocked(int PageNo, System::Word Offset);
	bool __fastcall IsPageRegionLocked(int PageNo, System::Word Offset, System::Word Count);
	__fastcall TABSDiskPageManager();
	__fastcall virtual ~TABSDiskPageManager();
	void __fastcall CreateAndOpenDatabase(System::UnicodeString DatabaseFileName, const Abssecurity::TABSPassword &Password, System::Word PageSize = (System::Word)(0x1000), System::Word ExtentPageCount = (System::Word)(0x8));
	void __fastcall OpenDatabase(System::UnicodeString DatabaseFileName, const Abssecurity::TABSPassword &Password, bool &ReadOnly, bool &RepairNeeded, bool Exclusive, bool &aMultiUser);
	void __fastcall CloseDatabase();
	void __fastcall TruncateDatabase();
	void __fastcall ExtendFile(int PageCount);
	void __fastcall TruncateFile(int PageCount);
	int __fastcall GetNextObjectID(int TryCount = 0x5, int DelayMS = 0x64);
	void __fastcall InitObjectID(int TryCount = 0x5, int DelayMS = 0x64);
	virtual void __fastcall ApplyChanges(int SessionID);
	__property TABSDatabaseFile* DatabaseFile = {read=FDatabaseFile};
	__property Abstypes::PABSDBHeader DBHeader = {read=GetDbHeader};
	__property Abstypes::TABSLockedBytes LockedBytes = {read=FLockedBytes};
	__property Abssecurity::PABSPassword Password = {read=GetPassword};
	__property bool IsOpened = {read=GetIsOpened, nodefault};
	__property __int64 OffsetToFirstPage = {read=FOffsetToFirstPage};
	__property __int64 OffsetToLockedBytes = {read=FOffsetToLockedBytes};
	__property TABSDatabaseFreeSpaceManager* FreeSpaceManager = {read=FDatabaseFreeSpaceManager};
	__property TABSDiskTablePagesCacheManager* TablePagesCacheManager = {read=FTablePagesCacheManager};
	__property bool Exclusive = {read=FExclusive, nodefault};
	__property bool Encrypted = {read=GetEncrypted, nodefault};
};


#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSInternalDBTransactedAccessFile : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	TABSDiskPageManager* LPageManager;
	int FStartPageNo;
	System::Word FPageTypeID;
	void __fastcall SetStartPageNo(int StartPageNo);
	void __fastcall CheckFileOpened(System::AnsiString OperationName);
	int __fastcall GetPageCountForDataSize(int DataSize);
	void __fastcall GetPageNoAndOffsetForPosition(int Position, int &PagePosition, System::Word &Offset);
	int __fastcall GoToPage(int SessionID, int PagePosition);
	
public:
	void __fastcall InitFileHeader(int SessionID);
	__fastcall TABSInternalDBTransactedAccessFile(TABSDiskPageManager* PageManager, System::Word PageTypeID);
	__fastcall virtual ~TABSInternalDBTransactedAccessFile();
	void __fastcall CreateFile(int SessionID);
	void __fastcall DeleteFile(int SessionID, int StartPageNo = 0xffffffff);
	void __fastcall OpenFile(int StartPageNo);
	void __fastcall SetFileSize(int SessionID, int NewSize, int DecompressedSize, Abscompression::TABSCompressionAlgorithm CompressionAlgorithm);
	void __fastcall GetFileSize(int SessionID, int &Size, int &DecompressedSize, Abscompression::TABSCompressionAlgorithm &CompressionAlgorithm, bool &FileWasChanged, bool SyncronizeAllowed);
	int __fastcall GetSize(int SessionID);
	void __fastcall ReadFile(int SessionID, void *Buffer, const int Count, bool SynchronizeAllowed = true);
	void __fastcall WriteFile(int SessionID, const void *Buffer, const int Count, const Abscompression::TABSCompressionAlgorithm Algorithm = (Abscompression::TABSCompressionAlgorithm)(0x0), const int CompressionMode = 0x0);
	bool __fastcall LockFile();
	bool __fastcall UnlockFile();
	__property TABSDiskPageManager* PageManager = {read=LPageManager};
	__property int StartPageNo = {read=FStartPageNo, nodefault};
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSInternalDBDirectAccessFile : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	TABSDiskPageManager* LPageManager;
	int FStartPageNo;
	System::Word FPageTypeID;
	int FFileSize;
	Abstypes::TABSIntegerArray* FFilePages;
	void __fastcall SetStartPageNo(int StartPageNo);
	void __fastcall ReadPageHeader(int PageNo, Abstypes::TABSDiskPageHeader &PageHeader, bool SkipFirstByte = false);
	void __fastcall CheckFileOpened(System::AnsiString OperationName);
	int __fastcall GetPageCountForDataSize(int DataSize);
	void __fastcall GetPageNoAndOffsetForPosition(int Position, int &PagePosition, System::Word &Offset);
	void __fastcall ReadPageList();
	int __fastcall GoToPage(int PagePosition);
	void __fastcall InternalSeek(int FileOffset, /* out */ int &PageNo, /* out */ System::Word &PageOffset);
	
public:
	__fastcall TABSInternalDBDirectAccessFile(TABSDiskPageManager* PageManager, System::Word PageTypeID);
	__fastcall virtual ~TABSInternalDBDirectAccessFile();
	void __fastcall CreateFile(int Size);
	void __fastcall DeleteFile(int StartPageNo = 0xffffffff);
	void __fastcall OpenFile(int StartPageNo);
	int __fastcall GetSize();
	void __fastcall ReadBuffer(void *Buffer, const int Count, const int Position = 0xffffffff);
	void __fastcall WriteBuffer(const void *Buffer, const int Count, const int Position = 0xffffffff);
	bool __fastcall LockFile();
	bool __fastcall UnlockFile();
	bool __fastcall LockByte(int ByteNo);
	bool __fastcall UnlockByte(int ByteNo);
	bool __fastcall IsByteLocked(int ByteNo);
	bool __fastcall IsRegionLocked(int ByteNo, int ByteCount);
	__property TABSDiskPageManager* PageManager = {read=LPageManager};
	__property int StartPageNo = {read=FStartPageNo, nodefault};
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSActiveSessionsFile : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	TABSDiskPageManager* LPageManager;
	TABSInternalDBDirectAccessFile* FHandle;
	int FMaxSessionCount;
	int __fastcall GetStartPageNo();
	
public:
	__fastcall TABSActiveSessionsFile(Abspage::TABSPageManager* PageManager);
	__fastcall virtual ~TABSActiveSessionsFile();
	int __fastcall CreateFile(int aMaxSessionCount);
	void __fastcall OpenFile(int aStartPageNo);
	void __fastcall CloseFile();
	int __fastcall MultiUserConnect();
	void __fastcall MultiUserDisconnect(int SessionID);
	bool __fastcall SingleUserConnect();
	void __fastcall SingleUserDisconnect();
	int __fastcall GetDBFileConnectionsCount();
	__property int StartPageNo = {read=GetStartPageNo, nodefault};
	__property int MaxSessionCount = {read=FMaxSessionCount, nodefault};
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSTableListFile : public System::TObject
{
	typedef System::TObject inherited;
	
	
private:
	typedef System::DynamicArray<Abstypes::TABSTableListItem> _TABSTableListFile__1;
	
	
private:
	TABSDiskPageManager* LPageManager;
	TABSInternalDBTransactedAccessFile* FHandle;
	_TABSTableListFile__1 FTableList;
	int __fastcall GetStartPageNo();
	int __fastcall GetTableIndex(System::AnsiString TableName);
	
public:
	__fastcall TABSTableListFile(Abspage::TABSPageManager* PageManager);
	__fastcall virtual ~TABSTableListFile();
	int __fastcall CreateFile();
	void __fastcall OpenFile(int aStartPageNo);
	void __fastcall CloseFile();
	void __fastcall Load();
	void __fastcall Save();
	void __fastcall AddTable(int TableID, System::AnsiString TableName, int MetadataFilePageNo, int MostUpdatedFilePageNo, int LocksFilePageNo);
	void __fastcall RemoveTable(System::AnsiString TableName);
	void __fastcall OpenTable(System::AnsiString TableName, /* out */ int &TableID, /* out */ int &MetadataFilePageNo, /* out */ int &MostUpdatedFilePageNo, /* out */ int &LocksFilePageNo);
	void __fastcall RenameTable(System::AnsiString TableName, System::AnsiString NewTableName);
	bool __fastcall TableExists(System::AnsiString TableName);
	void __fastcall GetTablesList(System::Classes::TStrings* List);
	__property int StartPageNo = {read=GetStartPageNo, nodefault};
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSTableLocksFile : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	TABSDiskPageManager* LPageManager;
	TABSInternalDBDirectAccessFile* FHandle;
	int FMaxSessionCount;
	int __fastcall GetStartPageNo();
	int __fastcall GetTableLockByteNo(int SessionID, Abstypes::TABSLockType LockType);
	int __fastcall GetRecordLockByteNo(int SessionID);
	int __fastcall GetRecordLockRecordIDByteNo(int SessionID);
	
public:
	__fastcall TABSTableLocksFile(Abspage::TABSPageManager* PageManager);
	__fastcall virtual ~TABSTableLocksFile();
	int __fastcall CreateFile(int aMaxSessionCount);
	void __fastcall DeleteFile();
	void __fastcall OpenFile(int aStartPageNo);
	void __fastcall CloseFile();
	bool __fastcall LockTable(int SessionID, Abstypes::TABSLockType LockType);
	bool __fastcall UnlockTable(int SessionID, Abstypes::TABSLockType LockType);
	bool __fastcall IsTableLockedByAnyOtherSession(int SessionID, Abstypes::TABSLockType LockType);
	bool __fastcall IsTableLockAllowed(int SessionID, Abstypes::TABSLockType LockType, bool AllowXIRWAfterSIRW = true);
	bool __fastcall LockRecord(int SessionID, const Abstypes::TABSPageItemID &RecordID);
	bool __fastcall UnlockRecord(int SessionID, const Abstypes::TABSPageItemID &RecordID);
	bool __fastcall IsRecordLockedByAnyOtherSession(int SessionID, const Abstypes::TABSPageItemID &RecordID);
	bool __fastcall LockFile();
	bool __fastcall UnlockFile();
	__property int MaxSessionCount = {read=FMaxSessionCount, nodefault};
	__property int StartPageNo = {read=GetStartPageNo, nodefault};
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSSystemDirectory : public System::TObject
{
	typedef System::TObject inherited;
	
	
private:
	typedef System::DynamicArray<Abstypes::TABSSystemDirectoryListItem> _TABSSystemDirectory__1;
	
	
private:
	TABSDiskPageManager* LPageManager;
	TABSInternalDBTransactedAccessFile* FHandle;
	_TABSSystemDirectory__1 FFileList;
	
public:
	__fastcall TABSSystemDirectory(TABSDiskPageManager* PageManager);
	__fastcall virtual ~TABSSystemDirectory();
	void __fastcall CreateDirectory();
	void __fastcall LoadDirectory();
	void __fastcall SaveDirectory();
	void __fastcall CreateFile(Abstypes::TABSDBFileType FileType, int FirstPageNo);
	int __fastcall GetFileFirstPageNo(Abstypes::TABSDBFileType FileType);
	__property TABSDiskPageManager* PageManager = {read=LPageManager};
};

#pragma pack(pop)

struct DECLSPEC_DRECORD TABSTableLock
{
public:
	Abstypes::TABSLockType LockType;
	int LocksFilePageNo;
	int LockCount;
	bool HasPhysicalLock;
	bool IsXIRWAfterSIRWAllowed;
};


typedef TABSTableLock *PABSTableLock;

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSTableLockList : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	System::Classes::TList* FLockList;
	bool __fastcall FindLock(Abstypes::TABSLockType LockType, int LocksFilePageNo, int &ItemNo)/* overload */;
	bool __fastcall FindLock(Abstypes::TABSLockType LockType, int LocksFilePageNo, bool IsXIRWAfterSIRWAllowed, int &ItemNo)/* overload */;
	bool __fastcall IsLockStronger(Abstypes::TABSLockType LockType1, Abstypes::TABSLockType LockType2);
	
public:
	__fastcall TABSTableLockList();
	__fastcall virtual ~TABSTableLockList();
	void __fastcall AddLock(Abstypes::TABSLockType LockType, int LocksFilePageNo, bool HasPhysicalLock, bool IsXIRWAfterSIRWAllowed = true);
	void __fastcall RemoveLock(Abstypes::TABSLockType LockType, int LocksFilePageNo, bool &HasPhysicalLock, bool IgnoreCount);
	bool __fastcall LockExists(Abstypes::TABSLockType LockType, int LocksFilePageNo)/* overload */;
	bool __fastcall LockExists(Abstypes::TABSLockType LockType, int LocksFilePageNo, bool IsXIRWAfterSIRWAllowed)/* overload */;
	bool __fastcall StrongerLockExists(Abstypes::TABSLockType LockType, int LocksFilePageNo);
	void __fastcall SetPhysicalLock(int ItemNo);
	bool __fastcall IsWeakerNonPhysicalLock(int ItemNo, Abstypes::TABSLockType LockType);
};

#pragma pack(pop)

#pragma pack(push,4)
class PASCALIMPLEMENTATION TABSDatabaseTableLockManager : public System::TObject
{
	typedef System::TObject inherited;
	
private:
	System::Classes::TList* FSessionLockList;
	int FMaxSessionCount;
	_RTL_CRITICAL_SECTION FCSect;
	Abspage::TABSPageManager* LPageManager;
	void __fastcall Lock();
	void __fastcall Unlock();
	bool __fastcall AddSIRWLocksToULocks(int SessionID);
	bool __fastcall SetPhysicalLockForWeakerLocks(int SessionID, Abstypes::TABSLockType LockType, TABSTableLocksFile* TableLocksFile);
	
public:
	__fastcall TABSDatabaseTableLockManager(int MaxSessionCount, Abspage::TABSPageManager* PageManager);
	__fastcall virtual ~TABSDatabaseTableLockManager();
	bool __fastcall LockTable(int SessionID, Abstypes::TABSLockType LockType, TABSTableLocksFile* TableLocksFile, int aTryCount, int aDelayMS, bool NoThreadLock = false, bool AllowXIRWAfterSIRW = true);
	bool __fastcall UnlockTable(int SessionID, Abstypes::TABSLockType LockType, TABSTableLocksFile* TableLocksFile, bool IgnoreIfNoLock = false, bool IgnoreCount = false);
	bool __fastcall LockRecord(int SessionID, TABSTableLocksFile* TableLocksFile, const Abstypes::TABSPageItemID &RecordID, int aTryCount, int aDelayMS);
	bool __fastcall UnlockRecord(int SessionID, TABSTableLocksFile* TableLocksFile, const Abstypes::TABSPageItemID &RecordID);
	bool __fastcall IsRecordLocked(int SessionID, TABSTableLocksFile* TableLocksFile, const Abstypes::TABSPageItemID &RecordID);
	bool __fastcall AddRWLocksBeforeCommit(int SessionID);
	bool __fastcall ClearTransactionLocks(int SessionID);
};

#pragma pack(pop)

typedef bool __fastcall (__closure *TBooleanFunctionForTimeOutCall)(void);

//-- var, const, procedure ---------------------------------------------------
extern DELPHI_PACKAGE System::AnsiString __fastcall PageTypeToStr(System::Word PageType);
extern DELPHI_PACKAGE bool __fastcall TryUsingTimeOut(TBooleanFunctionForTimeOutCall Func, int TryCount, int DelayMS);
extern DELPHI_PACKAGE void __fastcall CheckPageType(System::Word FoundType, System::Word WantedType, int ErrorCode);
extern DELPHI_PACKAGE bool __fastcall ABSInternalEncryptBuffer(Abssecurity::TABSCryptoAlgorithm CryptoAlg, System::PByte inBuf, int Size, System::AnsiString Password);
extern DELPHI_PACKAGE bool __fastcall ABSInternalDecryptBuffer(Abssecurity::TABSCryptoAlgorithm CryptoAlg, System::PByte inBuf, int Size, System::AnsiString Password);
extern DELPHI_PACKAGE bool __fastcall IsOSCriticalError(void);
}	/* namespace Absdiskengine */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_ABSDISKENGINE)
using namespace Absdiskengine;
#endif
#pragma pack(pop)
#pragma option pop

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif	// AbsdiskengineHPP
