|
@@ -26,7 +26,7 @@ TYpe
|
|
TClassOption = (caCreateClass,caConstructor,caDestructor,caCreateList,caListAddMethod,caListItemsProperty);
|
|
TClassOption = (caCreateClass,caConstructor,caDestructor,caCreateList,caListAddMethod,caListItemsProperty);
|
|
TClassOptions = Set of TClassOption;
|
|
TClassOptions = Set of TClassOption;
|
|
TVisitorOption = (voRead,voReadList,voCreate,voDelete,voUpdate,
|
|
TVisitorOption = (voRead,voReadList,voCreate,voDelete,voUpdate,
|
|
- voCommonSetupParams,voSingleSaveVisitor);
|
|
|
|
|
|
+ voCommonSetupParams,voSingleSaveVisitor,voRegisterVisitors);
|
|
TVisitorOptions = set of TVisitorOption;
|
|
TVisitorOptions = set of TVisitorOption;
|
|
|
|
|
|
{ TTiOPFCodeOptions }
|
|
{ TTiOPFCodeOptions }
|
|
@@ -76,6 +76,8 @@ TYpe
|
|
// Auxiliary routines
|
|
// Auxiliary routines
|
|
procedure WriteFieldAssign(Strings: TStrings; F: TFieldPropDef);
|
|
procedure WriteFieldAssign(Strings: TStrings; F: TFieldPropDef);
|
|
procedure WriteAssignToParam(Strings: TStrings; F: TFieldPropDef);
|
|
procedure WriteAssignToParam(Strings: TStrings; F: TFieldPropDef);
|
|
|
|
+ procedure WriteRegisterVisitorLine(Strings: TStrings;
|
|
|
|
+ const V: TVisitorOption; const ObjectClassName: String);
|
|
procedure WriteSetSQL(Strings: TStrings; const ASQL: String);
|
|
procedure WriteSetSQL(Strings: TStrings; const ASQL: String);
|
|
procedure WriteSQLConstants(Strings: TStrings);
|
|
procedure WriteSQLConstants(Strings: TStrings);
|
|
Procedure WriteTerminateVisitor(Strings : TStrings; V : TVisitorOption; const ObjectClassName: String);
|
|
Procedure WriteTerminateVisitor(Strings : TStrings; V : TVisitorOption; const ObjectClassName: String);
|
|
@@ -90,6 +92,7 @@ TYpe
|
|
procedure WriteReadVisitor(Strings: TStrings; const ObjectClassName: String );
|
|
procedure WriteReadVisitor(Strings: TStrings; const ObjectClassName: String );
|
|
procedure WriteVisitorDeclaration(Strings: TStrings; V: TVisitorOption; const ObjectClassName: String);
|
|
procedure WriteVisitorDeclaration(Strings: TStrings; V: TVisitorOption; const ObjectClassName: String);
|
|
procedure WriteVisitorImplementation(Strings: TStrings; V: TVisitorOption; const ObjectClassName: String);
|
|
procedure WriteVisitorImplementation(Strings: TStrings; V: TVisitorOption; const ObjectClassName: String);
|
|
|
|
+ procedure WriteVisitorRegistration(Strings: TStrings; const ObjectClassName: String);
|
|
Protected
|
|
Protected
|
|
// Not to be overridden.
|
|
// Not to be overridden.
|
|
procedure WriteListAddObject(Strings: TStrings; const ListClassName, ObjectClassName: String);
|
|
procedure WriteListAddObject(Strings: TStrings; const ListClassName, ObjectClassName: String);
|
|
@@ -370,6 +373,8 @@ begin
|
|
If (Result<>'') then
|
|
If (Result<>'') then
|
|
Result:=Result+', ';
|
|
Result:=Result+', ';
|
|
Result:=Result+'tiVisitor, tiVisitorDB, tiObject';
|
|
Result:=Result+'tiVisitor, tiVisitorDB, tiObject';
|
|
|
|
+ If (voRegisterVisitors in tiOPFoptions.VisitorOptions) then
|
|
|
|
+ Result:=Result+', tiOPFManager';
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TTiOPFCodeGenerator.DoGenerateInterface(Strings: TStrings);
|
|
procedure TTiOPFCodeGenerator.DoGenerateInterface(Strings: TStrings);
|
|
@@ -400,6 +405,12 @@ begin
|
|
DecIndent;
|
|
DecIndent;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
+ If voRegisterVisitors in tiOPFoptions.VisitorOptions then
|
|
|
|
+ begin
|
|
|
|
+ AddLn(Strings);
|
|
|
|
+ AddLn(Strings,'Procedure Register'+tiOPFoptions.ObjectClassName+'Visitors;');
|
|
|
|
+ AddLn(Strings);
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -526,7 +537,7 @@ procedure TTiOPFCodeGenerator.WriteSQLConstants(Strings : TStrings);
|
|
|
|
|
|
Const
|
|
Const
|
|
VisSQL : Array [TVisitorOption] of string
|
|
VisSQL : Array [TVisitorOption] of string
|
|
- = ('Read','ReadList','Create','Delete','Update','','');
|
|
|
|
|
|
+ = ('Read','ReadList','Create','Delete','Update','','','');
|
|
|
|
|
|
Var
|
|
Var
|
|
OCN,S : String;
|
|
OCN,S : String;
|
|
@@ -596,6 +607,8 @@ begin
|
|
For V:=Low(TVisitorOption) to High(TVisitorOption) do
|
|
For V:=Low(TVisitorOption) to High(TVisitorOption) do
|
|
If V in VisitorOptions then
|
|
If V in VisitorOptions then
|
|
WriteVisitorImplementation(Strings,V,ObjectClassName);
|
|
WriteVisitorImplementation(Strings,V,ObjectClassName);
|
|
|
|
+ If (voRegisterVisitors in TiOPFOptions.VisitorOptions) then
|
|
|
|
+ WriteVisitorRegistration(Strings,ObjectClassName);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -619,6 +632,7 @@ begin
|
|
WriteTerminateVisitor(Strings,V,ObjectClassName);
|
|
WriteTerminateVisitor(Strings,V,ObjectClassName);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+
|
|
Function TTiOPFCodeGenerator.BeginInit(Strings : TStrings; const AClass : String) : String;
|
|
Function TTiOPFCodeGenerator.BeginInit(Strings : TStrings; const AClass : String) : String;
|
|
|
|
|
|
begin
|
|
begin
|
|
@@ -674,6 +688,54 @@ begin
|
|
IncIndent;
|
|
IncIndent;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+{ ---------------------------------------------------------------------
|
|
|
|
+ Visitor registration
|
|
|
|
+ ---------------------------------------------------------------------}
|
|
|
|
+
|
|
|
|
+procedure TTiOPFCodeGenerator.WriteRegisterVisitorLine(Strings : TStrings; Const V: TVisitorOption; Const ObjectClassName : String);
|
|
|
|
+
|
|
|
|
+Var
|
|
|
|
+ C : String;
|
|
|
|
+ S : String;
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ C:=VisitorClassName(v,ObjectClassName);
|
|
|
|
+ Case V of
|
|
|
|
+ voRead : S:='Read';
|
|
|
|
+ voReadList : S:='ReadList';
|
|
|
|
+ voCreate : S:='Create';
|
|
|
|
+ voDelete : S:='Delete';
|
|
|
|
+ voUpdate : S:='Update';
|
|
|
|
+ end;
|
|
|
|
+ S:=ObjectClassName+S;
|
|
|
|
+ S:=Format('GTIOPFManager.RegisterVisitor(''%s'',%s);',[S,C]);
|
|
|
|
+ AddLn(Strings,S);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TTiOPFCodeGenerator.WriteVisitorRegistration(Strings : TStrings; Const ObjectClassName : String);
|
|
|
|
+
|
|
|
|
+Const
|
|
|
|
+ RealVis = [voRead,voReadList,voCreate,voDelete,voUpdate];
|
|
|
|
+
|
|
|
|
+Var
|
|
|
|
+ v : TVisitorOption;
|
|
|
|
+ S : String;
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ Addln(Strings);
|
|
|
|
+ S:='Procedure Register'+ObjectClassName+'Visitors;';
|
|
|
|
+ BeginMethod(Strings,S);
|
|
|
|
+ AddLn(Strings,'begin');
|
|
|
|
+ IncIndent;
|
|
|
|
+ For v:=Low(TVisitorOption) to High(TVisitorOption) do
|
|
|
|
+ begin
|
|
|
|
+ If (V in RealVis) and (V in TiOPFOptions.VisitorOptions) then
|
|
|
|
+ WriteRegisterVisitorLine(Strings,V,ObjectClassName);
|
|
|
|
+ end;
|
|
|
|
+ DecIndent;
|
|
|
|
+ EndMethod(Strings,S);
|
|
|
|
+end;
|
|
|
|
+
|
|
{ ---------------------------------------------------------------------
|
|
{ ---------------------------------------------------------------------
|
|
Read Visitor
|
|
Read Visitor
|
|
---------------------------------------------------------------------}
|
|
---------------------------------------------------------------------}
|