Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Interfacedeklaration, brauche Hilfe! (https://www.delphipraxis.net/81061-interfacedeklaration-brauche-hilfe.html)

hennes80 20. Nov 2006 09:38


Interfacedeklaration, brauche Hilfe!
 
Hallo ich habe ein Problem bei der Deklaration von folgenden Interface:
Delphi-Quellcode:
 TSession = class(TTypedComObject, ISession)
  private
    FSession     :TSession;
    FstrType     :string;
    //FFolders     :TFolders;
    FParent : TApp;
    strSessionID :string;
    MyToolbox : TToolbox;
    MyWininet : TWininet;
    MyURLInfo : TURLInfo;
  protected
    function Logoff: HResult; stdcall;
    function Logon(Username, Password: OleVariant): HResult; stdcall;
    function setIP(Value: OleVariant): HResult; stdcall;
    constructor Create;
    destructor Destroy;
    {ISession-Methoden hier deklarieren}
  public
    //TODO: properties implementieren, methoden implementieren(GetDefaultFolder)

    //property Folders: TFolders read FFolders write FFolders;
    property Parent: TApp read FParent write FParent;
    property Session: TSession read FSession write FSession;
    property _type: string read FstrType write FstrType;
  end;

  TApp = class(TTypedComObject, IApp)
  private
    FApplication :TApp;
    FSession     :TSession;
    FName        :string;
    FVersion     :string;
  protected
   {IApp-Methoden hier deklarieren}
  public
    property Application: TApp read FApplication write FApplication;
    property Session   : TSession read FSession write FSession;
    property Name      : string read FName write FName;
    property Version  : string read FVersion write FVersion;
  end;
Die Zeile " FParent : TApp;" schmeisst die Compilermeldung "undefinierter Bezeichner", da TApp erst später deklariert wird. Wie kann ich das umgehen, OHNE TApp voher zu definieren?(Da TApp ebenfalls TSession nutzt, bleibt das Problem bestehen). Vielen Dank schonmal.

[edit=SirThornberry]Delphi-Tags gesetzt - Mfg, SirThornberry[/edit]

Wormid 20. Nov 2006 09:53

Re: Interfacedeklaration, brauche Hilfe!
 
Moinsen,

versuch es mal so...

Delphi-Quellcode:
type
  TApp = class;

  TSession = class(TTypedComObject, ISession)
  private
    FSession: TSession;
    FParent: TApp;
    ...
  end;

   TApp = class(TTypedComObject, IApp)
   private
     ...
   end;

hennes80 20. Nov 2006 09:59

Re: Interfacedeklaration, brauche Hilfe!
 
Vielen Dank, scheint zu funktionieren

Der_Unwissende 20. Nov 2006 11:19

Re: Interfacedeklaration, brauche Hilfe!
 
Zitat:

Zitat von hennes80
Vielen Dank, scheint zu funktionieren

HI,
wird zwar funktionieren, aber ist imho eine unschöne Lösung. Das Problem dass du hier hast ist die gegenseitige Abhängigkeit von TApp und TSession. Da ist es dann aber gerade sauber, wenn du hier die wirklich benötigte Funktionalität in einem Interface festlegst und dann sowas hast wie:

Delphi-Quellcode:
TSession = class(TTypedComObject, ISession)
  private
    FSession: ISession;
    FParent: IApp;
....

TApp = class(TTypedComObject, IApp)
  private
    FApplication :IApp;
    FSession     :ISession;
Dann kannst du auch mit einem TApp und einer beliebigen ISession arbeiten.

Gruß Der Unwissende


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:05 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz