* Added support for TCustomDaemonApplication descendents (enabling streaming)

git-svn-id: trunk@6288 -
This commit is contained in:
michael 2007-02-01 21:34:07 +00:00
parent f9eefa118c
commit 1d049300fd

View File

@ -340,6 +340,7 @@ Type
// Customizable behaviour // Customizable behaviour
procedure CreateDaemonController(Var AController : TDaemonController); virtual; procedure CreateDaemonController(Var AController : TDaemonController); virtual;
Procedure CreateServiceMapper(Var AMapper : TCustomDaemonMapper); virtual; Procedure CreateServiceMapper(Var AMapper : TCustomDaemonMapper); virtual;
Procedure CreateDaemonInstance(Var ADaemon : TCustomDaemon; DaemonDef : TDaemonDef); virtual;
Procedure RemoveController(AController : TDaemonController); virtual; Procedure RemoveController(AController : TDaemonController); virtual;
procedure SetupLogger; procedure SetupLogger;
procedure StopLogger; procedure StopLogger;
@ -359,15 +360,16 @@ Type
Property GuiHandle : THandle Read FGUIHandle Write FGUIHandle; Property GuiHandle : THandle Read FGUIHandle Write FGUIHandle;
Property RunMode : TDaemonRunMode Read FRunMode; Property RunMode : TDaemonRunMode Read FRunMode;
end; end;
TCustomDaemonApplicationClass = Class of TCustomDaemonApplication;
TDaemonApplication = Class(TCustomDaemonApplication) TDaemonApplication = Class(TCustomDaemonApplication);
end;
EDaemon = Class(Exception); EDaemon = Class(Exception);
Function Application : TCustomDaemonApplication; Function Application : TCustomDaemonApplication;
Procedure RegisterDaemonMapper(AMapperClass : TCustomDaemonMapperClass); Procedure RegisterDaemonMapper(AMapperClass : TCustomDaemonMapperClass);
Procedure RegisterDaemonClass(AClass : TCustomDaemonClass); Procedure RegisterDaemonClass(AClass : TCustomDaemonClass);
Procedure RegisterDaemonApplicationClass(AClass : TCustomDaemonApplicationClass);
Procedure DaemonError(Msg : String); Procedure DaemonError(Msg : String);
Procedure DaemonError(Fmt : String; Args : Array of const); Procedure DaemonError(Fmt : String; Args : Array of const);
@ -386,7 +388,8 @@ Resourcestring
SErrNoDaemonForStatus = '%s: No daemon for status report'; SErrNoDaemonForStatus = '%s: No daemon for status report';
SErrNoDaemonDefForStatus = '%s: No daemon definition for status report'; SErrNoDaemonDefForStatus = '%s: No daemon definition for status report';
SErrWindowClass = 'Could not register window class'; SErrWindowClass = 'Could not register window class';
SErrApplicationAlreadyCreated = 'An application instance of class %s was already created.';
{ $define svcdebug} { $define svcdebug}
{$ifdef svcdebug} {$ifdef svcdebug}
@ -407,11 +410,12 @@ implementation
{$i daemonapp.inc} {$i daemonapp.inc}
Var Var
AppInstance : TCustomDaemonApplication; AppInstance : TCustomDaemonApplication;
MapperClass : TCustomDaemonMapperClass; MapperClass : TCustomDaemonMapperClass;
DesignMapper : TCustomDaemonMapper; DesignMapper : TCustomDaemonMapper;
DaemonClasses : TStringList; DaemonClasses : TStringList;
AppClass : TCustomDaemonApplicationClass;
{$ifdef svcdebug} {$ifdef svcdebug}
Var Var
FL : Text; FL : Text;
@ -450,6 +454,14 @@ begin
end; end;
{$endif svcdebug} {$endif svcdebug}
Procedure RegisterDaemonApplicationClass(AClass : TCustomDaemonApplicationClass);
begin
If (AppInstance<>Nil) then
DaemonError(SErrApplicationAlreadyCreated,[AppInstance.ClassName]);
AppClass:=AClass;
end;
Procedure RegisterDaemonClass(AClass : TCustomDaemonClass); Procedure RegisterDaemonClass(AClass : TCustomDaemonClass);
Var Var
@ -472,7 +484,9 @@ end;
Procedure CreateDaemonApplication; Procedure CreateDaemonApplication;
begin begin
AppInstance:=TDaemonApplication.Create(Nil); If (AppClass=Nil) then
AppClass:=TCustomDaemonApplication;
AppInstance:=AppClass.Create(Nil);
end; end;
Procedure DoneDaemonApplication; Procedure DoneDaemonApplication;
@ -877,6 +891,11 @@ begin
inherited ShowException(E) inherited ShowException(E)
end; end;
Procedure TCustomDaemonApplication.CreateDaemonInstance(Var ADaemon : TCustomDaemon; DaemonDef : TDaemonDef);
begin
ADaemon:=DaemonDef.DaemonClass.CreateNew(Self,0);
end;
function TCustomDaemonApplication.CreateDaemon(DaemonDef: TDaemonDef): TCustomDaemon; function TCustomDaemonApplication.CreateDaemon(DaemonDef: TDaemonDef): TCustomDaemon;
@ -884,7 +903,7 @@ Var
C : TDaemonController; C : TDaemonController;
begin begin
Result:=DaemonDef.DaemonClass.CreateNew(Self,0); CreateDaemonInstance(Result,DaemonDef);
CreateDaemonController(C); CreateDaemonController(C);
C.FDaemon:=Result; C.FDaemon:=Result;
Result.FController:=C; Result.FController:=C;