Line | |
---|
1 | unit UDataModel;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, SpecializedList;
|
---|
9 |
|
---|
10 | type
|
---|
11 | TDataType = (dtInteger, dtString, dtText, dtFloat, dtBoolean, dtReference,
|
---|
12 | dtDate, dtTime, dtDateTime);
|
---|
13 |
|
---|
14 | TDataModelItem = class
|
---|
15 | Name: string;
|
---|
16 | Caption: string;
|
---|
17 | DataType: TDataType;
|
---|
18 | end;
|
---|
19 |
|
---|
20 | { TDateModelItems }
|
---|
21 |
|
---|
22 | TDataModelItems = class(TListObject)
|
---|
23 | function AddItem(Caption, Name: string; DataType: TDataType): TDataModelItem;
|
---|
24 | end;
|
---|
25 |
|
---|
26 | { TDataModel }
|
---|
27 |
|
---|
28 | TDataModel = class
|
---|
29 | Name: string;
|
---|
30 | Caption: string;
|
---|
31 | Items: TDataModelItems;
|
---|
32 | constructor Create;
|
---|
33 | destructor Destroy; override;
|
---|
34 | end;
|
---|
35 |
|
---|
36 | implementation
|
---|
37 |
|
---|
38 | { TDataModel }
|
---|
39 |
|
---|
40 | constructor TDataModel.Create;
|
---|
41 | begin
|
---|
42 | Items := TDataModelItems.Create;
|
---|
43 | end;
|
---|
44 |
|
---|
45 | destructor TDataModel.Destroy;
|
---|
46 | begin
|
---|
47 | Items.Free;
|
---|
48 | inherited Destroy;
|
---|
49 | end;
|
---|
50 |
|
---|
51 | { TDateModelItems }
|
---|
52 |
|
---|
53 | function TDataModelItems.AddItem(Caption, Name: string; DataType: TDataType): TDataModelItem;
|
---|
54 | begin
|
---|
55 | Result := TDataModelItem.Create;
|
---|
56 | Result.Name := Name;
|
---|
57 | Result.Caption := Caption;
|
---|
58 | Result.DataType := DataType;
|
---|
59 | Add(Result);
|
---|
60 | end;
|
---|
61 |
|
---|
62 | end.
|
---|
63 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.