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

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

#ifndef PfibsqllogHPP
#define PfibsqllogHPP

#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 <Windows.hpp>	// Pascal unit
#include <Messages.hpp>	// Pascal unit
#include <Sysutils.hpp>	// Pascal unit
#include <Classes.hpp>	// Pascal unit
#include <Ptestinfo.hpp>	// Pascal unit
#include <Pfibinterfaces.hpp>	// Pascal unit
#include <Fibdatabase.hpp>	// Pascal unit
#include <Pfibprops.hpp>	// Pascal unit
#include <Fib.hpp>	// Pascal unit
#include <Stdfuncs.hpp>	// Pascal unit
#include <Pfibquery.hpp>	// Pascal unit
#include <Fibquery.hpp>	// Pascal unit
#include <Pfibcachequeries.hpp>	// Pascal unit

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

namespace Pfibsqllog
{
//-- type declarations -------------------------------------------------------
#pragma option push -b-
enum TFIBStatisticsParam { fspExecuteCount, fspPrepareCount, fspSumTimeExecute, fspAvgTimeExecute, fspMaxTimeExecute, fspLastTimeExecute };
#pragma option pop

typedef Set<TFIBStatisticsParam, fspExecuteCount, fspLastTimeExecute>  TFIBStatisticsParams;

class DELPHICLASS TFIBSQLLogger;
typedef void __fastcall (__closure *TSQLLogEvent)(const AnsiString ObjectName, const AnsiString Operation, const AnsiString EventText, Pfibinterfaces::TLogFlag DataType, AnsiString cApplication, System::TDateTime EventTime);

class PASCALIMPLEMENTATION TFIBSQLLogger : public Classes::TComponent 
{
	typedef Classes::TComponent inherited;
	
private:
	Fibdatabase::TFIBTransaction* tr;
	Ptestinfo::TTestInfo* FAppStatInfo;
	AnsiString FApplicationID;
	Fibdatabase::TFIBDatabase* FDatabase;
	TFIBStatisticsParams FStatisticsParams;
	Pfibprops::TpFIBExistObject FExistStatTable;
	TSQLLogEvent FOnLogEvent;
	Pfibinterfaces::TLogFlags FLogFlags;
	Classes::TStrings* FLogList;
	AnsiString FLogFileName;
	bool FForceSaveToFile;
	bool FActiveLogging;
	Classes::TFileStream* FStream;
	void __fastcall SetActiveStatistics(bool Value);
	bool __fastcall GetActiveStatistics(void);
	void __fastcall SetActiveLogging(const bool Value);
	bool __fastcall GetActiveLogging(void);
	void __fastcall SetLogFileName(AnsiString FileName);
	void __fastcall SetStatParams(TFIBStatisticsParams Value);
	void __fastcall SetDatabase(System::TObject* DB);
	void __fastcall CheckDatabase(void);
	void __fastcall OnDisconnect(System::TObject* Sender);
	bool __fastcall GetFS(void);
	void __fastcall SetFS(const bool Value);
	Pfibinterfaces::TLogFlags __fastcall GetLogFlags(void);
	void __fastcall SetLogFlags(Pfibinterfaces::TLogFlags Value);
	AnsiString __fastcall GetLogFileName();
	Pfibinterfaces::_di_ISQLStatMaker __fastcall GetStatMaker();
	
protected:
	virtual void __fastcall Notification(Classes::TComponent* AComponent, Classes::TOperation Operation);
	void __fastcall WriteData(const AnsiString ObjectName, const AnsiString OperationName, const AnsiString EventText, Pfibinterfaces::TLogFlag DataType);
	
public:
	__fastcall virtual TFIBSQLLogger(Classes::TComponent* AOwner);
	__fastcall virtual ~TFIBSQLLogger(void);
	System::TObject* __fastcall GetInstance(void);
	void __fastcall Clear(void);
	void __fastcall SaveStatisticsToFile(const AnsiString FileName);
	void __fastcall SortStatisticsForPrint(const AnsiString VarName, bool Ascending);
	bool __fastcall ExistStatisticsTable(void);
	void __fastcall CreateStatisticsTable(void);
	void __fastcall SaveStatisticsToDB(int ForMaxExecTime = 0x0);
	void __fastcall SaveLog(void);
	__property Fibdatabase::TFIBDatabase* Database = {read=FDatabase};
	__property Pfibinterfaces::_di_ISQLStatMaker StatisticsMaker = {read=GetStatMaker};
	
__published:
	__property bool ActiveStatistics = {read=GetActiveStatistics, write=SetActiveStatistics, default=0};
	__property AnsiString LogFileName = {read=GetLogFileName, write=SetLogFileName};
	__property AnsiString ApplicationID = {read=FApplicationID, write=FApplicationID};
	__property TFIBStatisticsParams StatisticsParams = {read=FStatisticsParams, write=SetStatParams, default=63};
	__property Pfibinterfaces::TLogFlags LogFlags = {read=GetLogFlags, write=SetLogFlags, default=27};
	__property bool ForceSaveLog = {read=GetFS, write=SetFS, nodefault};
	__property bool ActiveLogging = {read=GetActiveLogging, write=SetActiveLogging, default=0};
private:
	void *__ISQLLogger;	/* Pfibinterfaces::ISQLLogger */
	void *__ISQLStatMaker;	/* Pfibinterfaces::ISQLStatMaker */
	
public:
	operator ISQLStatMaker*(void) { return (ISQLStatMaker*)&__ISQLStatMaker; }
	operator ISQLLogger*(void) { return (ISQLLogger*)&__ISQLLogger; }
	
};

typedef TFIBSQLLogger TpFIBStatistics;

//-- var, const, procedure ---------------------------------------------------

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

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