AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Mehrere Instanzen einer von TObject abgeleiteten Klasse
Thema durchsuchen
Ansicht
Themen-Optionen

Mehrere Instanzen einer von TObject abgeleiteten Klasse

Ein Thema von Alex2.2 · begonnen am 24. Jul 2006 · letzter Beitrag vom 24. Jul 2006
Antwort Antwort
Alex2.2

Registriert seit: 19. Mai 2006
17 Beiträge
 
#1

Mehrere Instanzen einer von TObject abgeleiteten Klasse

  Alt 24. Jul 2006, 13:14
Ich bin im Moment völlig ratlos. Ich arbeite an einem ASP.NET Projekt in dem mich mir eine Klasse für Benutzerrechte (für den Zugang zur Webseitenfuntionalität) gebaut habe. Diese ist von TObject abgeleitet und deren Interface ist wie folgt definiert:
Delphi-Quellcode:
 {$REGION 'RightsStructure'}


   type TServerActionValues = record
      all : Boolean;
      add : Boolean;
      edit: Boolean;
      editAccUser: Boolean;
      editAccVehicles: Boolean;
   end;
   type TOwnAccActionsValues = record
      all : Boolean;
      add : Boolean;
      edit: Boolean;
      editOwnPassword: Boolean;
      SetupUserRights: Boolean;
   end;
   type TOwnJouneyActionsValues = record
      all : Boolean;
      add : Boolean;
      edit: Boolean;
   end;

   type TOwnVehicleActionsValues = record
      all : Boolean;
      edit: Boolean;
   end;
   type TOwnAlarmActionsValues = record
      all : Boolean;
      add : Boolean;
      edit: Boolean;
   end;
   type TViewVehicleActionsValues = record
      all : Boolean;
      view : Boolean;
   end;
   type TViewJourneyActionsValues = record
      all : Boolean;
      view : Boolean;
      viewOwn : Boolean;
   end;
   type TViewDataActionsValues = record
      all : Boolean;
      viewVehicleSetup: Boolean;
      viewActuals : Boolean;
      viewHistory : Boolean;
      viewAlarms : Boolean;
   end;
   type TViewMapActionsValues = record
      all : Boolean;
      viewActuals : Boolean;
      viewHistory : Boolean;
      viewAlarms : Boolean;
      Zooming : Boolean;
      Tracing : Boolean;
   end;

 {$ENDREGION}


 {$REGION 'Constant Strings'}
   type TServerActions = record
      const all : String = 'ALL';
      const add : String = 'ADD';
      const edit: String = 'EDIT';
      const editAccUser: String = 'ACCUSEREDIT';
      const editAccVehicles: String = 'ACCVEHICLEEDIT';
   end;
   type TOwnAccActions = record
      const all : String = 'ALL';
      const add : String = 'ADD';
      const edit: String = 'EDIT';
      const editOwnPassword: String = 'OWNPW';
      const SetupUserRights: String = 'URSETUP';
   end;
   type TOwnJouneyActions = record
      const all : String = 'ALL';
      const add : String = 'ADD';
      const edit: String = 'EDIT';
   end;

   type TOwnVehicleActions = record
      const all : String = 'ALL';
      const edit: String = 'EDIT';
   end;
   type TOwnAlarmActions = record
      const all : String = 'ALL';
      const add : String = 'ADD';
      const edit: String = 'EDIT';
   end;
   type TViewVehicleActions = record
      const all : String = 'ALL';
      const view : String = 'VIEW';
   end;
   type TViewJourneyActions = record
      const all : String = 'ALL';
      const view : String = 'VIEW';
      const viewOwn : String = 'VIEWOWN';
   end;
   type TViewDataActions = record
      const all : String = 'ALL';
      const viewVehicleSetup: String = 'SETTINGS';
      const viewActuals : String = 'ACTUALS';
      const viewHistory : String = 'HISTORY';
      const viewAlarms : String = 'ALARMS';
   end;
   type TViewMapActions = record
      const all : String = 'ALL';
      const viewActuals : String = 'ACTUALS';
      const viewHistory : String = 'HISTORY';
      const viewAlarms : String = 'ALARMS';
      const Zooming : String = 'ZOOM';
      const Tracing : String = 'TRACE';
   end;
   type TUserActions = record
        ServerSetup : TServerActions;
        OwnAccSetup : TOwnAccActions;
        OwnJourneysSetup: TOwnJouneyActions;
        OwnVehicleSetup : TOwnVehicleActions;
        OwnAlarmsSetup : TOwnAlarmActions;
        OwnVehiclesView : TViewVehicleActions;
        OwnJourneysView : TViewJourneyActions;
        DataView : TViewDataActions;
        Maps : TViewMapActions;
   end;

   type TModuleStrings = Record
      const ServerSetup : String = 'SERVERSETUP';
      const OwnAccSetup : String = 'OWNACCOUNTSETUP';
      const OwnJourneysSetup : String = 'OWNJOURNEYSETUP';
      const OwnVehicleSetup : String = 'OWNVEHICLESETUP';
      const OwnAlarmsSetup : String = 'OWNALARMSSETUP';
      const OwnVehiclesView : String = 'OWNVEHICLESVIEW';
      const OwnJourneysView : String = 'OWNJOURNEYSVIEW';
      const DataView : String = 'DATAVIEW';
      const Maps : String = 'MAPSVIEW';
   end;

 {$ENDREGION}


   type TYN = Array[boolean] of String;
   type TUserRightsSetting = record
       Module : String;
       Action : String;
       Value : Boolean;
   end;

   type TUserRightsTable = record
     class var
     Changable : Boolean;
     StandardUser : Boolean;
     DataBaseID : Integer;
     ServerSetup : TServerActionValues;
     OwnAccSetup : TOwnAccActionsValues;
     OwnJourneysSetup : TOwnJouneyActionsValues;
     OwnVehicleSetup : TOwnVehicleActionsValues;
     OwnAlarmsSetup : TOwnAlarmActionsValues;
     OwnVehiclesView : TViewVehicleActionsValues;
     OwnJourneysView : TViewJourneyActionsValues;
     DataView : TViewDataActionsValues;
     Maps : TViewMapActionsValues;
   end;

 {$REGION 'Private Declarations'}

   private
      { Private Declarations }
      ModulesStr : TModuleStrings;
      ActionsStr : TUserActions;
      Rights : TUserRightsTable;
      function getChangable : boolean;
      function getStandardUser : boolean;
      procedure setChangable(value: Boolean);
      procedure setStandardUser(value : Boolean);
      function getDataBaseID : Integer;
      procedure setDataBaseID(DBID: Integer);
      function getRightItems : Integer;
      function getRightItem(itemid: integer):TUserRightsSetting;
      function getItemCount(item : Integer; var UserRightItem : TUserRightsSetting) :Integer;
  {$ENDREGION}
 {$REGION 'public Declarations'}
   public
      constructor Create;
      property Modules : TModuleStrings read ModulesStr;
      property Actions : TUserActions read ActionsStr;
      property DBID : Integer read getDataBaseID write setDataBaseID;
      property isChangable : Boolean read getChangable write setChangable;
      property isStandardUser : Boolean read getStandardUser write setStandardUser;
      property Items : Integer read getRightItems;
      property Item[itemid : integer] : TUserRightsSetting read getRightItem;
      procedure CopyRightsFrom(Input : TUserRightsTable);
      function getRightsTable : TUserRightsTable;
      property RightsTable : TUserRightsTable read getRightsTable write CopyRightsFrom;
      function getRightFor(currModule: String; currAction: String): Boolean;
      procedure setRightFor(currModule: String; currAction: String; currValue :Boolean);
      function getRightForAsYN(currModule: String; currAction: String): String;
      procedure setRightForAsYN(currModule: String; currAction: String; currValue :String);
      function getChangableAsYN : String;
      function getStandardUserAsYN : String;
      procedure setChangableAsYN(value: String);
      procedure setStandardUserAsYN(value : String);
  {$ENDREGION}
  end;
Mein Problem ist dabei nun, daß ich solange ich ein Object, das mit dieser Klasse instaziert wurde, allein verwende keine Probleme habe, wenn aber ein 2. Object instanziert wird, scheinen beide den selben Speicherraum zu verwenden. Da ich kein absoluter O-O Freak bin, bin ich sicher, daß ich irgendetwas nicht beachtet habe. Nur Was?
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#2

Re: Mehrere Instanzen einer von TObject abgeleiteten Klasse

  Alt 24. Jul 2006, 13:20
Wie intatntiierst du die Objekte?
Markus Kinzler
  Mit Zitat antworten Zitat
Alex2.2

Registriert seit: 19. Mai 2006
17 Beiträge
 
#3

Re: Mehrere Instanzen einer von TObject abgeleiteten Klasse

  Alt 24. Jul 2006, 13:31
In Der Klasse befindet sich der Konstruktor:
Delphi-Quellcode:
constructor TUserAccessRights.Create;
begin
  inherited Create;
  // TODO: Add any constructor code here
  Rights.Changable := true;
  Rights.StandardUser := false;
  Rights.DataBaseID := 0;

{$REGION 'SettingRightsInit'}

  with Rights.ServerSetup do begin
     all := true;
     add := true;
     edit := true;
     editAccUser := true;
     editAccVehicles := true;
  end;
  with Rights.OwnAccSetup do begin
     all :=true;
     add :=true;
     edit :=true;
     editOwnPassword :=true;
     SetupUserRights :=true;
  end;
  with Rights.OwnJourneysSetup do begin
     all :=true;
     add :=true;
     edit :=true;
  end;
  with Rights.OwnVehicleSetup do begin
     all :=true;
     edit :=true;
  end;
  with Rights.OwnAlarmsSetup do begin
     all :=true;
     add :=true;
     edit :=true;
  end;
{$ENDREGION}
{$REGION 'ViewRightsInit'}
  with Rights.OwnVehiclesView do begin
     all :=true;
     view :=true;
  end;
  with Rights.OwnJourneysView do begin
     all :=true;
     view :=true;
     viewOwn :=true;
  end;
  with Rights.DataView do begin
     all :=true;
     viewVehicleSetup :=true;
     viewActuals :=true;
     viewHistory :=true;
     viewAlarms :=true;
  end;
  with Rights.Maps do begin
     all :=true;
     viewActuals :=true;
     viewHistory :=true;
     viewAlarms :=true;
     Zooming :=true;
     Tracing :=true;
  end;

{$ENDREGION}
end;
und im Parent Object:
wird dann eben der Konstruktor aufgerufen, wie z.B:

Delphi-Quellcode:
function x : boolean
var:
OwnRights : TUserAccessRights;
begin
OwnRights:= TUserAccessRights.create;
...
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:12 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz