Componentes.Terceros.RemObj.../internal/5.0.23.613/1/RemObjects SDK for Delphi/Source/CodeGen2/uRODLImplConverter.pas
david 2824855ea7 - Modificación del paquete RemObjects_Core_D10 para que sea un paquete de runtime/designtime (antes era designtime sólo)
- Recompilación en Delphi10 de todos los paquetes de RO para generar las DCU's en Lib\D10
- Recompilación en Delphi10 de todos los paquetes de DA para generar las DCU's en Lib\D10

git-svn-id: https://192.168.0.254/svn/Componentes.Terceros.RemObjects@9 b6239004-a887-0f4b-9937-50029ccdca16
2007-09-10 14:06:19 +00:00

164 lines
5.3 KiB
ObjectPascal

unit uRODLImplConverter;
{----------------------------------------------------------------------------}
{ RemObjects SDK Library - CodeGen2 }
{ }
{ compiler: Delphi 5 and up, Kylix 2 and up }
{ platform: Win32, Linux }
{ }
{ (c)opyright RemObjects Software. all rights reserved. }
{ }
{ Using this code requires a valid license of the RemObjects SDK }
{ which can be obtained at http://www.remobjects.com. }
{----------------------------------------------------------------------------}
{$IFDEF LINUX}
{$I ../RemObjects.inc}
{$ELSE}
{$I ..\RemObjects.inc}
{$ENDIF LINUX}
interface
uses
uRODLTemplateBasedConverter, uRODL;
const
DEFAULT_IMPL_SERVICE_ANCESTOR = 'TRORemotable';
type
TRODLImplConverter = class (TRODLTemplateBasedConverter)
private
FService: TRODLService;
FAncestorService: TRODLService;
function GetAncestorUnitName: string;
property AncestorUnitName: string read GetAncestorUnitName;
protected
procedure IntConvert(const aLibrary : TRODLLIbrary; const aTargetEntity : string = ''); override;
procedure SetupServices(const aLibrary: TRODLLibrary; const aTargetEntity : string = ''); override;
procedure SetupRequiredUnits; override;
function ValidateTargetEntity(const aLibrary : TRODLLIbrary; const aTargetEntity : string) : boolean; override;
function GetServicesSectionClass: TServicesSectionClass; override;
public
constructor Create(const aLibrary: TRODLLibrary; const aTemplateFileName: string; const aUnitName: string; const aServerClassName: string; const aTargetEntity: string = ''; const aRequiredUnits: string = ''); reintroduce; virtual;
end;
implementation
uses
SysUtils, uRODLTemplateBasedConverterUtils, uROServer;
type
TImplServicesSection = class (TServicesSection)
protected
function GetAncestorName(const aService: TRODLBaseService): string; override;
end;
{ TRODLDelphiImplConverter }
constructor TRODLImplConverter.Create(const aLibrary: TRODLLibrary;
const aTemplateFileName: string; const aUnitName: string; const aServerClassName: string;
const aTargetEntity: string; const aRequiredUnits: string);
begin
// Call inherited with nil so that convert is not called, allowing us
// to setup the optional sections. Setting up the optional sections before
// calling the inherited Create is not an option, the section list would
// not have been created
inherited Create(nil, aTemplateFileName, aUnitName, aTargetEntity);
FServerClassName := aServerClassName;
FRequiredUnits := aRequiredUnits;
// Now that everything is done, call convert if need be.
if (aLibrary <> nil) then Convert(aLibrary, aTargetEntity);
end;
function TRODLImplConverter.GetAncestorUnitName: string;
begin
Result := '';
if Assigned(FService) then
begin
if FService.Ancestor <> '' then
begin
if Assigned(FAncestorService) and (FAncestorService.ImplUnit <> '') then
Result := FAncestorService.ImplUnit
else
Result := FService.Ancestor+'_Impl';
end;
end;
end;
function TRODLImplConverter.GetServicesSectionClass: TServicesSectionClass;
begin
Result := TImplServicesSection;
end;
procedure TRODLImplConverter.IntConvert(const aLibrary: TRODLLIbrary;
const aTargetEntity: string);
begin
if Assigned(fService) and Assigned(fService.Default) then
inherited IntConvert(aLibrary, aTargetEntity);
end;
procedure TRODLImplConverter.SetupRequiredUnits;
var
ancestorUnit: string;
begin
inherited SetupRequiredUnits;
ancestorUnit := AncestorUnitName;
if Pos(ancestorUnit, RequiredUnits) = 0 then
RequiredUnits := RequiredUnits + ',' + ancestorUnit;
end;
procedure TRODLImplConverter.SetupServices(const aLibrary: TRODLLibrary;
const aTargetEntity: string);
begin
inherited SetupServices(aLibrary, aTargetEntity);
// For the impl section, only one service is of interest, the one
// indicated to us
FOrderedServices.Clear;
FOrderedServices.AddObject(FService.Name, FService);
end;
function TRODLImplConverter.ValidateTargetEntity(
const aLibrary: TRODLLIbrary; const aTargetEntity: string): boolean;
var
i : integer;
begin
Result := FALSE;
for i := 0 to (aLibrary.ServiceCount-1) do
if (CompareText(aLibrary.Services[i].Info.Name, aTargetEntity)=0) then
begin
FService := aLibrary.Services[i]; // Will be used later
if FService.Ancestor <> '' then
FAncestorService := aLibrary.FindService(FService.Ancestor);
Result := TRUE;
Exit;
end;
end;
{ TImplServicesSection }
function TImplServicesSection.GetAncestorName(
const aService: TRODLBaseService): string;
begin
Result := inherited GetAncestorName(aService);
if Result = '' then
begin
if not (Parent as TRODLImplConverter).UseDefaultAncestor then
Result := (Parent as TRODLImplConverter).ServerClassName
else
Result := DEFAULT_IMPL_SERVICE_ANCESTOR;
end;
end;
end.