Changeset 6 for trunk/UDatabase.pas
- Timestamp:
- Jan 20, 2015, 12:31:24 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UDatabase.pas
r4 r6 10 10 type 11 11 TTable = class; 12 TDatabaseEngine = class; 12 13 13 14 TFieldType = (ftString, ftInteger, ftDateTime, ftBoolean, ftFloat, ftImage, … … 109 110 Tables: TTables; 110 111 ConnectionString: string; 112 Engine: TDatabaseEngine; 111 113 constructor Create; 112 114 destructor Destroy; override; … … 115 117 end; 116 118 119 TDatabases = class(TObjectList) 120 121 end; 122 123 TDatabaseClass = class of TDatabase; 124 125 { TDataType } 126 127 TDataType = class 128 Name: string; 129 FieldType: TFieldType; 130 end; 131 132 TDataTypes = class(TObjectList) 133 function RegisterType(Name: string; FieldType: TFieldType): TDataType; 134 end; 135 136 { TDatabaseEngine } 137 138 TDatabaseEngine = class 139 Name: string; 140 DataTypes: TDataTypes; 141 DatabaseClass: TDatabaseClass; 142 constructor Create; 143 destructor Destroy; override; 144 end; 145 146 { TDatabaseEngines } 147 148 TDatabaseEngines = class(TObjectList) 149 function RegisterEngine(Name: string; DatabaseClass: TDatabaseClass): TDatabaseEngine; 150 function FindByName(Name: string): TDatabaseEngine; 151 end; 152 117 153 118 154 implementation … … 120 156 uses 121 157 UDataTypes; 158 159 { TDatabaseEngines } 160 161 function TDatabaseEngines.RegisterEngine(Name: string; 162 DatabaseClass: TDatabaseClass): TDatabaseEngine; 163 begin 164 Result := TDatabaseEngine.Create; 165 Result.Name := Name; 166 Result.DatabaseClass := DatabaseClass; 167 Add(Result); 168 end; 169 170 function TDatabaseEngines.FindByName(Name: string): TDatabaseEngine; 171 var 172 I: Integer; 173 begin 174 I := 0; 175 while (I < Count) and (TDatabaseEngine(Items[I]).Name <> Name) do Inc(I); 176 if I < Count then Result := TDatabaseEngine(Items[I]) 177 else Result := nil; 178 end; 179 180 { TDataTypes } 181 182 function TDataTypes.RegisterType(Name: string; FieldType: TFieldType): TDataType; 183 begin 184 Result := TDataType.Create; 185 Result.Name := Name; 186 Result.FieldType := FieldType; 187 Add(Result); 188 end; 189 190 { TDatabaseEngine } 191 192 constructor TDatabaseEngine.Create; 193 begin 194 DataTypes := TDataTypes.Create; 195 end; 196 197 destructor TDatabaseEngine.Destroy; 198 begin 199 DataTypes.Free; 200 inherited Destroy; 201 end; 122 202 123 203 { TValues }
Note:
See TracChangeset
for help on using the changeset viewer.