Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is for the Index option in TRemotable derivated classes?

When WSDL importer wizard generates the interfaces, all properties have the Index option, but reading the code and the InvokeRegistry unit, I can't found what is that for, anyone know if it is really necessary?

Like this

  Login = class(TRemotable)
  private
    [...] 
  published
    property User: string Index (IS_OPTN) read GetUser write SetUser stored User_Specified;
    [...]
  end;

I'm asking because I want to change this unit, adding some Interfaces to this classes, for integrate with MVP framework.

like image 722
Cesar Romero Avatar asked Dec 05 '25 08:12

Cesar Romero


2 Answers

IS_OPTN is passed to GetUser and SetUser via the 'Index' parameter when you access the user property.

The getters/setters probably look like this:

function GetUser(Index:Integer):String;
procedure SetUser(Index:Integer;const value:string);

So, think of it as this:

MyString := MyLogin.user;
// is translated to:
MyString := getUser(IS_OPTN);

and

MyLogin.user := 'me'; 
// is translated to:
SetUser(IS_OPTN,'me');
like image 172
Wouter van Nifterick Avatar answered Dec 07 '25 04:12

Wouter van Nifterick


I found a more detailed explanation for this question, When using Indexes, several properties can share the same access methods.

A good example, from Delphi 2009 Help:

type 
   TRectangle = class 
     private 
       FCoordinates: array[0..3] of Longint; 
       function GetCoordinate(Index: Integer): Longint; 
       procedure SetCoordinate(Index: Integer; Value: Longint); 
     public 
       property Left: Longint index 0 read GetCoordinate write SetCoordinate; 
       property Top: Longint index 1 read GetCoordinate write SetCoordinate; 
       property Right: Longint index 2 read GetCoordinate write SetCoordinate; 
       property Bottom: Longint index 3 read GetCoordinate write SetCoordinate; 
       property Coordinates[Index: Integer]: Longint read GetCoordinate write SetCoordinate; 
       ... 
   end;

Note, all properties shares the same method access.

like image 25
Cesar Romero Avatar answered Dec 07 '25 04:12

Cesar Romero



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!