Componentes.Terceros.RemObj.../official/5.0.23.613/RemObjects SDK for Delphi/Samples/Variants/VariantsLibrary_Intf.pas

325 lines
9.3 KiB
ObjectPascal
Raw Normal View History

unit VariantsLibrary_Intf;
{----------------------------------------------------------------------------}
{ This unit was automatically generated by the RemObjects SDK after reading }
{ the RODL file associated with this project . }
{ }
{ Do not modify this unit manually, or your changes will be lost when this }
{ unit is regenerated the next time you compile the project. }
{----------------------------------------------------------------------------}
interface
uses
{vcl:} Classes, TypInfo,
{RemObjects:} uROClasses, uROClient, uROTypes, uROClientIntf;
const
{ Library ID }
LibraryUID = '{997272DF-9CE1-42FC-A341-669D18AE18ED}';
{ Service Interface ID's }
IVariantsService_IID : TGUID = '{509D1C6D-51DF-4269-A160-DB5B5B671874}';
{ Event ID's }
type
{ Forward declarations }
IVariantsService = interface;
TVariantArray = class;
TComplexObject = class;
{ TComplexObject }
TComplexObject = class(TROComplexType)
private
fIntegerId: Integer;
fVariantValue: Variant;
public
procedure Assign(iSource: TPersistent); override;
published
property IntegerId:Integer read fIntegerId write fIntegerId;
property VariantValue:Variant read fVariantValue write fVariantValue;
end;
{ TComplexObjectCollection }
TComplexObjectCollection = class(TROCollection)
protected
constructor Create(aItemClass: TCollectionItemClass); overload;
function GetItems(Index: integer): TComplexObject;
procedure SetItems(Index: integer; const Value: TComplexObject);
public
constructor Create; overload;
function Add: TComplexObject; reintroduce;
property Items[Index: integer]:TComplexObject read GetItems write SetItems; default;
end;
{ TVariantArray }
TVariantArray = class(TROArray)
private
fCount: Integer;
fItems : array of Variant;
protected
procedure Grow; virtual;
function GetItems(Index: integer): Variant;
procedure SetItems(Index: integer; const Value: Variant);
function GetCount: integer; override;
public
class function GetItemType: PTypeInfo; override;
class function GetItemSize: integer; override;
function GetItemRef(Index: integer): pointer; override;
procedure Clear; override;
procedure Delete(Index: integer); override;
procedure Resize(ElementCount: integer); override;
procedure Assign(iSource:TPersistent); override;
function Add(const Value:Variant): integer;
property Count : integer read GetCount;
property Items[Index: integer]:Variant read GetItems write SetItems; default;
end;
{ IVariantsService }
IVariantsService = interface
['{509D1C6D-51DF-4269-A160-DB5B5B671874}']
procedure EchoVariant(const InputVariant: Variant; out OutputVariant: Variant);
procedure EchoComplexObject(const InComplexObject: TComplexObject; out OutComplexObject: TComplexObject);
procedure EchoVariantArray(const InArray: TVariantArray; out OutArray: TVariantArray);
end;
{ CoVariantsService }
CoVariantsService = class
class function Create(const aMessage: IROMessage; aTransportChannel: IROTransportChannel): IVariantsService;
end;
{ TVariantsService_Proxy }
TVariantsService_Proxy = class(TROProxy, IVariantsService)
protected
function __GetInterfaceName:string; override;
procedure EchoVariant(const InputVariant: Variant; out OutputVariant: Variant);
procedure EchoComplexObject(const InComplexObject: TComplexObject; out OutComplexObject: TComplexObject);
procedure EchoVariantArray(const InArray: TVariantArray; out OutArray: TVariantArray);
end;
implementation
uses
{vcl:} SysUtils,
{RemObjects:} uROEventRepository, uRORes;
{ TVariantArray }
procedure TVariantArray.Assign(iSource: TPersistent);
var lSource:TVariantArray;
i:integer;
begin
if (iSource is TVariantArray) then begin
lSource := TVariantArray(iSource);
Clear();
Resize(lSource.Count);
for i := 0 to Count-1 do begin
Items[i] := lSource.Items[i];
end;
end
else begin
inherited Assign(iSource);
end;
end;
class function TVariantArray.GetItemType: PTypeInfo;
begin
result := TypeInfo(Variant);
end;
class function TVariantArray.GetItemSize: integer;
begin
result := SizeOf(Variant);
end;
function TVariantArray.GetItems(Index: integer): Variant;
begin
if (Index < 0) or (Index >= Count) then RaiseError(err_ArrayIndexOutOfBounds,[Index]);
result := fItems[Index];
end;
function TVariantArray.GetItemRef(Index: integer): pointer;
begin
if (Index < 0) or (Index >= Count) then RaiseError(err_ArrayIndexOutOfBounds,[Index]);
result := @fItems[Index];
end;
procedure TVariantArray.Clear;
begin
SetLength(fItems, 0);
FCount := 0;
end;
procedure TVariantArray.Delete(Index: integer);
var i: integer;
begin
if (Index>=Count) then RaiseError(err_InvalidIndex, [Index]);
if (Index<Count-1) then
for i := Index to Count-2 do fItems[i] := fItems[i+1];
SetLength(fItems, Count-1);
Dec(FCount);
end;
procedure TVariantArray.SetItems(Index: integer; const Value: Variant);
begin
if (Index < 0) or (Index >= Count) then RaiseError(err_ArrayIndexOutOfBounds,[Index]);
fItems[Index] := Value;
end;
procedure TVariantArray.Resize(ElementCount: integer);
begin
SetLength(fItems, ElementCount);
FCount := ElementCount;
end;
function TVariantArray.GetCount: integer;
begin
result := FCount;
end;
procedure TVariantArray.Grow;
var
Delta, Capacity: Integer;
begin
Capacity := Length(fItems);
if Capacity > 64 then
Delta := Capacity div 4
else
if Capacity > 8 then
Delta := 16
else
Delta := 4;
SetLength(fItems, Capacity + Delta);
end;
function TVariantArray.Add(const Value: Variant): integer;
begin
Result := Count;
if Length(fItems) = Result then
Grow;
fItems[result] := Value;
Inc(fCount);
end;
{ TComplexObject }
procedure TComplexObject.Assign(iSource: TPersistent);
var lSource:TComplexObject;
begin
inherited Assign(iSource);
if (iSource is TComplexObject) then begin
lSource := TComplexObject(iSource);
IntegerId := lSource.IntegerId;
VariantValue := lSource.VariantValue;
end;
end;
{ TComplexObjectCollection }
constructor TComplexObjectCollection.Create;
begin
inherited Create(TComplexObject);
end;
constructor TComplexObjectCollection.Create(aItemClass: TCollectionItemClass);
begin
inherited Create(aItemClass);
end;
function TComplexObjectCollection.Add: TComplexObject;
begin
result := TComplexObject(inherited Add);
end;
function TComplexObjectCollection.GetItems(Index: integer): TComplexObject;
begin
result := TComplexObject(inherited Items[Index]);
end;
procedure TComplexObjectCollection.SetItems(Index: integer; const Value: TComplexObject);
begin
TComplexObject(inherited Items[Index]).Assign(Value);
end;
{ CoVariantsService }
class function CoVariantsService.Create(const aMessage: IROMessage; aTransportChannel: IROTransportChannel): IVariantsService;
begin
result := TVariantsService_Proxy.Create(aMessage, aTransportChannel);
end;
{ TVariantsService_Proxy }
function TVariantsService_Proxy.__GetInterfaceName:string;
begin
result := 'VariantsService';
end;
procedure TVariantsService_Proxy.EchoVariant(const InputVariant: Variant; out OutputVariant: Variant);
begin
try
__Message.InitializeRequestMessage(__TransportChannel, 'VariantsLibrary', __InterfaceName, 'EchoVariant');
__Message.Write('InputVariant', TypeInfo(Variant), InputVariant, []);
__Message.Finalize;
__TransportChannel.Dispatch(__Message);
__Message.Read('OutputVariant', TypeInfo(Variant), OutputVariant, []);
finally
__Message.FreeStream;
end
end;
procedure TVariantsService_Proxy.EchoComplexObject(const InComplexObject: TComplexObject; out OutComplexObject: TComplexObject);
begin
try
OutComplexObject := nil;
__Message.InitializeRequestMessage(__TransportChannel, 'VariantsLibrary', __InterfaceName, 'EchoComplexObject');
__Message.Write('InComplexObject', TypeInfo(VariantsLibrary_Intf.TComplexObject), InComplexObject, []);
__Message.Finalize;
__TransportChannel.Dispatch(__Message);
__Message.Read('OutComplexObject', TypeInfo(VariantsLibrary_Intf.TComplexObject), OutComplexObject, []);
finally
__Message.FreeStream;
end
end;
procedure TVariantsService_Proxy.EchoVariantArray(const InArray: TVariantArray; out OutArray: TVariantArray);
begin
try
OutArray := nil;
__Message.InitializeRequestMessage(__TransportChannel, 'VariantsLibrary', __InterfaceName, 'EchoVariantArray');
__Message.Write('InArray', TypeInfo(VariantsLibrary_Intf.TVariantArray), InArray, []);
__Message.Finalize;
__TransportChannel.Dispatch(__Message);
__Message.Read('OutArray', TypeInfo(VariantsLibrary_Intf.TVariantArray), OutArray, []);
finally
__Message.FreeStream;
end
end;
initialization
RegisterROClass(TComplexObject);
RegisterROClass(TVariantArray);
RegisterProxyClass(IVariantsService_IID, TVariantsService_Proxy);
finalization
UnregisterROClass(TComplexObject);
UnregisterROClass(TVariantArray);
UnregisterProxyClass(IVariantsService_IID);
end.