Last change
on this file was 84, checked in by george, 14 years ago |
- Modified: Thanks to compiler directives and simple macros specialized types was moved to one unit per base generic class. Directive $DEFINE is used to specify generic class template parameters which will be included to code. This approach enable to define more specialized types per unit.
|
File size:
825 bytes
|
Line | |
---|
1 | {$IFDEF INTERFACE}
|
---|
2 |
|
---|
3 | // TGRange<TRangeItem> = class
|
---|
4 | TGRange = class
|
---|
5 | private
|
---|
6 | procedure SetDistance(const AValue: TRangeItem);
|
---|
7 | function GetDistance: TRangeItem;
|
---|
8 | public
|
---|
9 | A: TRangeItem;
|
---|
10 | B: TRangeItem;
|
---|
11 | procedure SetRange(NewA, NewB: TRangeItem);
|
---|
12 | property Distance: TRangeItem read GetDistance write SetDistance;
|
---|
13 | end;
|
---|
14 |
|
---|
15 | {$UNDEF INTERFACE}
|
---|
16 | {$ENDIF}
|
---|
17 |
|
---|
18 | {$IFDEF IMPLEMENTATION}
|
---|
19 |
|
---|
20 | { TGRange }
|
---|
21 |
|
---|
22 | procedure TGRange.SetDistance(const AValue: TRangeItem);
|
---|
23 | begin
|
---|
24 | B := A + AValue;
|
---|
25 | end;
|
---|
26 |
|
---|
27 | function TGRange.GetDistance: TRangeItem;
|
---|
28 | begin
|
---|
29 | Result := B - A;
|
---|
30 | end;
|
---|
31 |
|
---|
32 | procedure TGRange.SetRange(NewA, NewB: TRangeItem);
|
---|
33 | begin
|
---|
34 | if NewA > NewB then begin
|
---|
35 | A := NewB;
|
---|
36 | B := NewA;
|
---|
37 | end else begin
|
---|
38 | A := NewA;
|
---|
39 | B := NewB;
|
---|
40 | end;
|
---|
41 | end;
|
---|
42 |
|
---|
43 | {$UNDEF IMPLEMENTATION}
|
---|
44 | {$ENDIF}
|
---|
Note:
See
TracBrowser
for help on using the repository browser.