Changeset 395 for ModularSystem
- Timestamp:
- Jul 31, 2012, 3:58:07 PM (12 years ago)
- Location:
- ModularSystem
- Files:
-
- 5 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ModularSystem/UModularSystem.pas
r394 r395 10 10 type 11 11 TModuleManager = class; 12 13 TAPI = class 14 15 end; 12 16 13 17 { TModule } … … 17 21 FInstalled: Boolean; 18 22 Manager: TModuleManager; 23 procedure SetInstalled(AValue: Boolean); 19 24 public 20 25 Version: string; … … 25 30 Description: TStringList; 26 31 License: string; 32 API: TAPI; 33 MarkForInstall: Boolean; 27 34 procedure Install; virtual; 28 35 procedure Uninstall; virtual; … … 32 39 constructor Create; virtual; 33 40 destructor Destroy; override; 34 property Installed: Boolean read FInstalled ;41 property Installed: Boolean read FInstalled write SetInstalled; 35 42 end; 36 43 37 44 { TModuleManager } 38 45 39 TModuleManager = class 46 TModuleManager = class(TComponent) 47 private 48 FAPI: TAPI; 49 procedure SetAPI(AValue: TAPI); 50 public 40 51 Modules: TObjectList; // TObjectList<TModule> 41 52 function FindModuleByName(Name: string): TModule; … … 44 55 procedure EnumModulesInstall(Dependencies, ModuleList: TStringList); 45 56 procedure EnumModulesUninstall(ModuleName: string; ModuleList: TStringList); 46 procedure RegisterModule(Module: TModule); 47 constructor Create; 57 procedure RegisterModule(Module: TModule; MarkForInstall: Boolean = False); 58 procedure UnregisterModule(Module: TModule); 59 procedure InstallMarked; 60 procedure UninstallAll; 61 constructor Create(AOwner: TComponent); override; 48 62 destructor Destroy; override; 63 property API: TAPI read FAPI write SetAPI; 49 64 end; 50 65 … … 56 71 57 72 { TModuleManager } 73 74 procedure TModuleManager.SetAPI(AValue: TAPI); 75 var 76 I: Integer; 77 begin 78 if FAPI = AValue then Exit; 79 FAPI := AValue; 80 for I := 0 to Modules.Count - 1 do 81 TModule(Modules[I]).API := FAPI; 82 end; 58 83 59 84 function TModuleManager.FindModuleByName(Name: string): TModule; … … 122 147 end; 123 148 124 procedure TModuleManager.RegisterModule(Module: TModule); 149 procedure TModuleManager.RegisterModule(Module: TModule; 150 MarkForInstall: Boolean = False); 125 151 begin 126 152 Modules.Add(Module); 127 153 Module.Manager := Self; 128 end; 129 130 constructor TModuleManager.Create; 131 begin 132 Modules := TObjectList.Create 154 Module.API := API; 155 Module.MarkForInstall := MarkForInstall; 156 end; 157 158 procedure TModuleManager.UnregisterModule(Module: TModule); 159 begin 160 Modules.Remove(Module); 161 end; 162 163 procedure TModuleManager.InstallMarked; 164 var 165 I: Integer; 166 begin 167 for I := 0 to Modules.Count - 1 do 168 with TModule(Modules[I]) do 169 if not Installed and MarkForInstall then Install; 170 end; 171 172 procedure TModuleManager.UninstallAll; 173 var 174 I: Integer; 175 begin 176 for I := 0 to Modules.Count - 1 do 177 with TModule(Modules[I]) do 178 if Installed then Uninstall; 179 end; 180 181 constructor TModuleManager.Create(AOwner: TComponent); 182 begin 183 inherited; 184 Modules := TObjectList.Create; 133 185 end; 134 186 … … 140 192 141 193 { TModule } 194 195 procedure TModule.SetInstalled(AValue: Boolean); 196 begin 197 if FInstalled = AValue then Exit; 198 if AValue then Install else Uninstall; 199 end; 142 200 143 201 procedure TModule.Install; … … 180 238 destructor TModule.Destroy; 181 239 begin 240 Installed := False; 182 241 Description.Free; 183 242 Dependencies.Free;
Note:
See TracChangeset
for help on using the changeset viewer.