Changeset 8 for trunk/UCore.pas


Ignore:
Timestamp:
Jan 23, 2015, 12:00:37 AM (10 years ago)
Author:
chronos
Message:
  • Modified: All data types have own table which is used to specify supported data types by database engines.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r7 r8  
    2424    Initialized: Boolean;
    2525    procedure InitEngines;
     26    procedure InitDataTypes;
    2627  public
    2728    Databases: TDatabases;
    2829    Engines: TDatabaseEngines;
     30    DataTypes: TDataTypes;
    2931    procedure LoadConfig;
    3032    procedure SaveConfig;
     
    3941
    4042uses
    41   UEngineXML, UEngineMySQL, UEngineSQLite, UFormTables, UFormConnect, UFormDatabases;
     43  UEngineXML, UEngineMySQL, UEngineSQLite, UFormTables, UFormConnect,
     44  UFormDatabases, UDataTypes;
    4245
    4346{$R *.lfm}
     
    4952  Databases := TDatabases.Create;
    5053  Engines := TDatabaseEngines.Create;
     54  DataTypes := TDataTypes.Create;
    5155end;
    5256
     
    5862procedure TCore.DataModuleDestroy(Sender: TObject);
    5963begin
     64  DataTypes.Free;
    6065  Engines.Free;
    6166  Databases.Free;
     
    6772begin
    6873  Engines.Clear;
    69 
    7074  NewEngine := Engines.RegisterEngine('XML file', TDatabaseXML);
    71   with NewEngine.DataTypes do begin
    72     RegisterType('String', ftString);
    73     RegisterType('Integer', ftInteger);
    74     RegisterType('Date and time', ftDateTime);
    75     RegisterType('Boolean', ftBoolean);
    76     RegisterType('Float', ftFloat);
    77   end;
     75  NewEngine.UseTypes(DataTypes, [ftString, ftInteger, ftDateTime, ftBoolean, ftFloat]);
    7876
    7977  NewEngine := Engines.RegisterEngine('MySQL', TDatabaseMySQL);
    80   with NewEngine.DataTypes do begin
    81     RegisterType('String', ftString);
    82     RegisterType('Integer', ftInteger);
    83     RegisterType('Date and time', ftDateTime);
    84     RegisterType('Boolean', ftBoolean);
    85     RegisterType('Float', ftFloat);
    86   end;
     78  NewEngine.UseTypes(DataTypes, [ftString, ftInteger, ftDateTime, ftBoolean, ftFloat]);
    8779
    8880  NewEngine := Engines.RegisterEngine('SQLite', TDatabaseSQLite);
    89   with NewEngine.DataTypes do begin
    90     RegisterType('String', ftString);
    91     RegisterType('Integer', ftInteger);
    92     RegisterType('Date and time', ftDateTime);
    93     RegisterType('Boolean', ftBoolean);
    94     RegisterType('Float', ftFloat);
     81  NewEngine.UseTypes(DataTypes, [ftString, ftInteger, ftDateTime, ftBoolean, ftFloat]);
     82end;
     83
     84procedure TCore.InitDataTypes;
     85begin
     86  DataTypes.Clear;
     87  with DataTypes do begin
     88    RegisterType('String', ftString, TFieldString);
     89    RegisterType('Integer', ftInteger, TFieldInteger);
     90    RegisterType('Date and time', ftDateTime, TFieldDateTime);
     91    RegisterType('Boolean', ftBoolean, TFieldBoolean);
     92    RegisterType('Float', ftFloat, TFieldFloat);
     93    RegisterType('MapPosition', ftMapPosition, TFieldMapPosition);
     94    RegisterType('Date', ftDate, TFieldDate);
     95    RegisterType('Time', ftTime, TFieldTime);
     96    RegisterType('Image', ftImage, TFieldImage);
    9597  end;
    9698end;
     
    130132begin
    131133  if not Initialized then begin
     134    InitDataTypes;
    132135    InitEngines;
    133136    FormConnect.Init;
Note: See TracChangeset for help on using the changeset viewer.