-
Notifications
You must be signed in to change notification settings - Fork 2
/
uobjects.pas
109 lines (87 loc) · 2.42 KB
/
uobjects.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
unit uObjects;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
type
{ TTask }
TCommandKind = (ckSQL, ckPROGRAM, ckBUILTIN);
TTask = class(TCollectionItem)
private
FTaskID: integer;
FKind: TCommandKind;
FName: string;
FScript: string;
function GetKind: string;
procedure SetKind(AValue: string);
procedure SetName(AValue: string);
procedure SetScript(AValue: string);
published
property TaskID: integer read FTaskID write FTaskID;
property Name: string read FName write SetName;
property Script: string read FScript write SetScript;
property Kind: string read GetKind write SetKind;
end;
{ TChain }
TChain = class(TCollectionItem)
private
FChainID: integer;
FClientName: string;
FExclusive: boolean;
FLive: boolean;
FMaxInstances: integer;
FName: string;
FRunAt: string;
FSelfDestruct: boolean;
FTasks: TCollection;
procedure SetTasks(AValue: TCollection);
public
constructor Create(ACollection: TCollection); override;
published
property ChainID: integer read FChainID write FChainID;
property Tasks: TCollection read FTasks write SetTasks;
property Name: string read FName write FName;
property RunAt: string read FRunAt write FRunAt;
property MaxInstances: integer read FMaxInstances write FMaxInstances;
property Live: boolean read FLive write FLive;
property SelfDestruct: boolean read FSelfDestruct write FSelfDestruct;
property Exclusive: boolean read FExclusive write FExclusive;
property ClientName: string read FClientName write FClientName;
end;
const
BuiltinCommands: array of string = ('NoOp', 'Download', 'Log');
implementation
uses TypInfo;
{ TTask }
procedure TChain.SetTasks(AValue: TCollection);
begin
if FTasks=AValue then Exit;
FTasks:=AValue;
end;
constructor TChain.Create(ACollection: TCollection);
begin
inherited Create(ACollection);
FTasks := TCollection.Create(TTask);
end;
{ TCommand }
procedure TTask.SetName(AValue: string);
begin
if FName = AValue then
Exit;
FName := AValue;
end;
function TTask.GetKind: string;
begin
Result := Copy(GetEnumName(TypeInfo(TCommandKind), Ord(FKind)), 3, MaxInt);
end;
procedure TTask.SetKind(AValue: string);
begin
FKind := TCommandKind(GetEnumValue(TypeInfo(TCommandKind), 'ck' + AValue));
end;
procedure TTask.SetScript(AValue: string);
begin
if FScript = AValue then
Exit;
FScript := AValue;
end;
end.