{*******************************************************}
{                                                       }
{       Tocsg.Obj                                       }
{                                                       }
{       Copyright (C) 2022 kkuzil                       }
{                                                       }
{*******************************************************}

unit Tocsg.Obj;

interface

uses
  Winapi.Windows, System.SysUtils;

type
  TTgObject = class(TObject)
  protected
    nLastError_: Integer;
    procedure _Trace(const sLog: String; nLevel: Integer = 0); overload;
    procedure _Trace(const sFormat: String; const aArgs: array of const; nLevel: Integer = 0); overload;
  public
    Constructor Create; virtual;
    property LastError: Integer read nLastError_;
  end;

  TTgEvtWorkBegin = procedure(aSender: TTgObject; llMax: LONGLONG) of object;
  TTgEvtWorkEnd = procedure(aSender: TTgObject; llPos, llMax: LONGLONG) of object;
  TTgEvtWork = procedure(aSender: TTgObject; llPos: LONGLONG) of object;

implementation

uses
  Tocsg.Trace;

{ TTgObject }

Constructor TTgObject.Create;
begin
  Inherited Create;
  nLastError_ := 0;
end;

procedure TTgObject._Trace(const sLog: String; nLevel: Integer = 0);
begin
{$IFDEF TRACE_OBJ}
  TTgTrace.T(Format('%s >> %s', [ClassName, sLog]), nLevel);
{$ENDIF}
end;

procedure TTgObject._Trace(const sFormat: String; const aArgs: array of const; nLevel: Integer = 0);
begin
{$IFDEF TRACE_OBJ}
  TTgTrace.T(Format('%s >> %s', [ClassName, sFormat]), aArgs, nLevel);
{$ENDIF}
end;

end.
