// Borland C++ Builder
// Copyright (c) 1995, 2005 by Borland Software Corporation
// All rights reserved

// (DO NOT EDIT: machine generated header) 'Fibsqlmonitor.pas' rev: 10.00

#ifndef FibsqlmonitorHPP
#define FibsqlmonitorHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx      // Zero-length empty class member functions
#pragma pack(push,8)
#include <System.hpp>	// Pascal unit
#include <Sysinit.hpp>	// Pascal unit
#include <Sysutils.hpp>	// Pascal unit
#include <Windows.hpp>	// Pascal unit
#include <Messages.hpp>	// Pascal unit
#include <Classes.hpp>	// Pascal unit
#include <Fibquery.hpp>	// Pascal unit
#include <Ibase.hpp>	// Pascal unit
#include <Fibdataset.hpp>	// Pascal unit
#include <Fibdatabase.hpp>	// Pascal unit
#include <Ib_services.hpp>	// Pascal unit

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

namespace Fibsqlmonitor
{
//-- type declarations -------------------------------------------------------
#pragma option push -b-
enum TFIBTraceFlag { tfQPrepare, tfQExecute, tfQFetch, tfConnect, tfTransact, tfService, tfMisc };
#pragma option pop

typedef Set<TFIBTraceFlag, tfQPrepare, tfMisc>  TFIBTraceFlags;

typedef void __fastcall (__closure *TSQLEvent)(AnsiString EventText, System::TDateTime EventTime);

class DELPHICLASS TFIBCustomSQLMonitor;
class PASCALIMPLEMENTATION TFIBCustomSQLMonitor : public Classes::TComponent 
{
	typedef Classes::TComponent inherited;
	
private:
	HWND FHWnd;
	TSQLEvent FOnSQLEvent;
	TFIBTraceFlags FTraceFlags;
	bool FActive;
	void __fastcall MonitorWndProc(Messages::TMessage &Message);
	void __fastcall SetActive(const bool Value);
	void __fastcall SetTraceFlags(TFIBTraceFlags aTraceFlags);
	
protected:
	__property TSQLEvent OnSQL = {read=FOnSQLEvent, write=FOnSQLEvent};
	__property TFIBTraceFlags TraceFlags = {read=FTraceFlags, write=SetTraceFlags, nodefault};
	__property bool Active = {read=FActive, write=SetActive, default=1};
	
public:
	__fastcall virtual TFIBCustomSQLMonitor(Classes::TComponent* AOwner);
	__fastcall virtual ~TFIBCustomSQLMonitor(void);
	void __fastcall Release(void);
	__property HWND Handle = {read=FHWnd, nodefault};
};


class DELPHICLASS TFIBSQLMonitor;
class PASCALIMPLEMENTATION TFIBSQLMonitor : public TFIBCustomSQLMonitor 
{
	typedef TFIBCustomSQLMonitor inherited;
	
__published:
	__property OnSQL ;
	__property TraceFlags ;
	__property Active  = {default=1};
public:
	#pragma option push -w-inl
	/* TFIBCustomSQLMonitor.Create */ inline __fastcall virtual TFIBSQLMonitor(Classes::TComponent* AOwner) : TFIBCustomSQLMonitor(AOwner) { }
	#pragma option pop
	#pragma option push -w-inl
	/* TFIBCustomSQLMonitor.Destroy */ inline __fastcall virtual ~TFIBSQLMonitor(void) { }
	#pragma option pop
	
};


#pragma option push -b-
enum TSavePointOperation { soSet, soRollBack, soRelease };
#pragma option pop

class DELPHICLASS TFIBSQLMonitorHook;
class PASCALIMPLEMENTATION TFIBSQLMonitorHook : public System::TObject 
{
	typedef System::TObject inherited;
	
private:
	bool FActive;
	bool vEventsCreated;
	void __fastcall CreateEvents(void);
	
protected:
	void __fastcall WriteSQLData(const AnsiString Text, TFIBTraceFlag DataType);
	
public:
	__fastcall TFIBSQLMonitorHook(void);
	__fastcall virtual ~TFIBSQLMonitorHook(void);
	void __fastcall TerminateWriteThread(void);
	Byte __fastcall SQLString(int k);
	void __fastcall RegisterMonitor(TFIBCustomSQLMonitor* SQLMonitor);
	void __fastcall UnregisterMonitor(TFIBCustomSQLMonitor* SQLMonitor);
	void __fastcall ReleaseMonitor(TFIBCustomSQLMonitor* Arg);
	virtual void __fastcall SQLPrepare(Fibquery::TFIBQuery* qry);
	virtual void __fastcall SQLExecute(Fibquery::TFIBQuery* qry);
	virtual void __fastcall SQLFetch(Fibquery::TFIBQuery* qry);
	virtual void __fastcall DBConnect(Fibdatabase::TFIBDatabase* db);
	virtual void __fastcall DBDisconnect(Fibdatabase::TFIBDatabase* db);
	virtual void __fastcall TRStart(Fibdatabase::TFIBTransaction* tr);
	virtual void __fastcall TRCommit(Fibdatabase::TFIBTransaction* tr);
	virtual void __fastcall TRSavepoint(Fibdatabase::TFIBTransaction* tr, const AnsiString SavePointName, TSavePointOperation Operation);
	virtual void __fastcall TRCommitRetaining(Fibdatabase::TFIBTransaction* tr);
	virtual void __fastcall TRRollback(Fibdatabase::TFIBTransaction* tr);
	virtual void __fastcall TRRollbackRetaining(Fibdatabase::TFIBTransaction* tr);
	virtual void __fastcall ServiceAttach(Ib_services::TpFIBCustomService* service);
	virtual void __fastcall ServiceDetach(Ib_services::TpFIBCustomService* service);
	virtual void __fastcall ServiceQuery(Ib_services::TpFIBCustomService* service);
	virtual void __fastcall ServiceStart(Ib_services::TpFIBCustomService* service);
	void __fastcall SendMisc(AnsiString Msg);
	bool __fastcall GetEnabled(void);
	int __fastcall GetMonitorCount(void);
	void __fastcall SetEnabled(const bool Value);
	__property bool Enabled = {read=GetEnabled, write=SetEnabled, default=1};
};


//-- var, const, procedure ---------------------------------------------------
static const Word WM_MIN_FIBSQL_MONITOR = 0x400;
static const Word WM_MAX_FIBSQL_MONITOR = 0x600;
static const Word WM_FIBSQL_SQL_EVENT = 0x401;
static const Word CM_RELEASE = 0xb021;
extern PACKAGE TFIBSQLMonitorHook* __fastcall MonitorHook(void);
extern PACKAGE void __fastcall EnableMonitoring(void);
extern PACKAGE void __fastcall DisableMonitoring(void);
extern PACKAGE bool __fastcall MonitoringEnabled(void);

}	/* namespace Fibsqlmonitor */
using namespace Fibsqlmonitor;
#pragma pack(pop)
#pragma option pop

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