Ignore:
Timestamp:
May 10, 2012, 1:18:25 PM (12 years ago)
Author:
chronos
Message:
  • Modified: PersistentData Memory backend partial implementation.
  • Modified: Some persistent type system modifications.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • PersistentData/UPDClient.pas

    r361 r362  
    1515
    1616  TPDClient = class;
     17  TPDType = class;
    1718
    1819  TOrderDirection = (odNone, odAscending, odDescending);
     
    3132    constructor Create;
    3233    destructor Destroy; override;
     34    procedure Assign(Source: TObjectProxy);
     35  end;
     36
     37  TOperation = (opUndefined, opDefined, opEqual, opNotEqual,
     38    opLess, opMore, opLessOrEqual, opMoreOrEqual);
     39
     40  TCondition = class
     41    Column: string;
     42    Operation: TOperation;
     43    Value: string;
    3344  end;
    3445
     
    5667  end;
    5768
     69  TPDTypeProperty = class
     70    Name: string;
     71    DbType: TPDType;
     72    Unique: Boolean;
     73    Index: Boolean;
     74  end;
     75
     76  { TPDTypePropertyList }
     77
     78  TPDTypePropertyList = class(TListObject)
     79    Client: TPDClient;
     80    procedure AddSimple(Name: string; TypeName: string; Unique: Boolean = False;
     81      Index: Boolean = False);
     82  end;
     83
    5884  { TPDType }
    5985
    6086  TPDType = class
    61     Client: TPDClient;
     87  private
     88    FClient: TPDClient;
     89    procedure SetClient(AValue: TPDClient);
     90  public
    6291    Name: string;
    6392    DbType: string;
    64     Properties: TDictionaryStringString;
     93    Properties: TPDTypePropertyList;
    6594    function IsDefined: Boolean;
    6695    procedure Define;
     
    6897    constructor Create;
    6998    destructor Destroy; override;
     99    property Client: TPDClient read FClient write SetClient;
    70100  end;
    71101
     
    103133    procedure TypeUndefine(AType: TPDType); virtual; abstract;
    104134    procedure CheckTypes;
    105     function TypeExists(Name: string): Boolean; virtual; abstract;
    106135    constructor Create(AOwner: TComponent); override;
    107136    destructor Destroy; override;
     
    120149  TPDClientClass = class of TPDClient;
    121150
     151  resourcestring
     152    SClientNotSet = 'Client not set';
     153    SNotSupported = 'Not supported';
     154    SVersionMismatch = 'Version mismatch, client: %0:s, server: %1:s. Please upgrade database.';
     155    SCantLoadObjectWithoutId = 'Can''t load object without id';
     156
     157
    122158implementation
    123159
    124 resourcestring
    125   SClientNotSet = 'Client not set';
    126   SNotSupported = 'Not supported';
    127   SVersionMismatch = 'Version mismatch, client: %0:s, server: %1:s. Please upgrade database.';
     160{ TPDTypePropertyList }
     161
     162procedure TPDTypePropertyList.AddSimple(Name: string; TypeName: string;
     163  Unique: Boolean; Index: Boolean);
     164var
     165  NewProperty: TPDTypeProperty;
     166begin
     167  NewProperty := TPDTypeProperty(AddNew(TPDTypeProperty.Create));
     168  NewProperty.Name := Name;
     169  NewProperty.DbType := Client.Types.SearchByName(TypeName);
     170  NewProperty.Unique := Unique;
     171  NewProperty.Index := Index;
     172end;
    128173
    129174
     
    148193end;
    149194
     195procedure TPDType.SetClient(AValue: TPDClient);
     196begin
     197  if FClient = AValue then Exit;
     198  FClient := AValue;
     199  Properties.Client := AValue;
     200end;
     201
    150202function TPDType.IsDefined: Boolean;
    151203begin
     
    168220constructor TPDType.Create;
    169221begin
    170   Properties := TDictionaryStringString.Create;
     222  Properties := TPDTypePropertyList.Create;
    171223end;
    172224
     
    206258  Properties.Free;
    207259  inherited Destroy;
     260end;
     261
     262procedure TObjectProxy.Assign(Source: TObjectProxy);
     263begin
     264  Path := Source.Path;
     265  Client := Source.Client;
     266  ObjectName := Source.ObjectName;
     267  Id := Source.Id;
     268  Properties.Assign(Source.Properties);
    208269end;
    209270
     
    293354    NewType.Client := Self;
    294355    NewType.Name := SystemVersionObject;
    295     NewType.Properties.Add('Version', 'String');
    296     NewType.Properties.Add('Time', 'DateTime');
     356    NewType.Properties.AddSimple('Version', 'String');
     357    NewType.Properties.AddSimple('Time', 'DateTime');
    297358    NewType.Define;
    298359
     
    380441procedure TPDClient.Uninstall;
    381442begin
    382 
     443  //Types.Uninstall;
    383444end;
    384445
Note: See TracChangeset for help on using the changeset viewer.