Ignore:
Timestamp:
Aug 7, 2012, 2:43:10 PM (12 years ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ModularSystem/UModularSystem.pas

    r397 r399  
    1111  TModuleManager = class;
    1212
    13   TAPI = class
     13  TAPI = class(TComponent)
    1414
    1515  end;
     
    1717  { TModule }
    1818
    19   TModule = class
     19  TModule = class(TComponent)
    2020  private
    2121    FInstalled: Boolean;
    2222    Manager: TModuleManager;
     23    FVersion: string;
     24    FIdentification: string;
     25    FTitle: string;
     26    FLicense: string;
     27    FAuthor: string;
     28    FDependencies: TStringList;
     29    FDescription: TStringList;
    2330    procedure SetInstalled(AValue: Boolean);
    2431  public
    25     Version: string;
    26     Name: string;
    27     Title: string;
    28     Dependencies: TStringList;
    29     Author: string;
    30     Description: TStringList;
    31     License: string;
    3232    API: TAPI;
    3333    MarkForInstall: Boolean;
     
    4040    destructor Destroy; override;
    4141    property Installed: Boolean read FInstalled write SetInstalled;
     42  published
     43    property Version: string read FVersion write FVersion;
     44    property Identification: string read FIdentification write FIdentification;
     45    property Title: string read FTitle write FTitle;
     46    property License: string read FLicense write FLicense;
     47    property Author: string read FAuthor write FAuthor;
     48    property Dependencies: TStringList read FDependencies write FDependencies;
     49    property Description: TStringList read FDescription write FDescription;
    4250  end;
    4351
     
    6472  end;
    6573
     74procedure Register;
     75
    6676
    6777implementation
     
    7080  SModuleNotFound = 'Module %s not found';
    7181
     82procedure Register;
     83begin
     84  RegisterComponents('ModularSystem', [TModuleManager, TModule]);
     85end;
     86
    7287{ TModuleManager }
    7388
     
    87102begin
    88103  I := 0;
    89   while (I < Modules.Count) and (TModule(Modules[I]).Name <> Name) do Inc(I);
     104  while (I < Modules.Count) and (TModule(Modules[I]).Identification <> Name) do Inc(I);
    90105  if I < Modules.Count then Result := TModule(Modules[I])
    91106    else Result := nil;
     
    101116    if Assigned(Module) then begin
    102117      if not Module.Installed then Module.Install;
    103     end else raise Exception.CreateFmt(SModuleNotFound, [Module.Name]);
     118    end else raise Exception.CreateFmt(SModuleNotFound, [Module.Identification]);
    104119  end;
    105120end;
     
    111126  for I := 0 to Modules.Count - 1 do
    112127  with TModule(Modules[I]) do begin
    113     if Dependencies.IndexOf(ModuleName) <> - 1 then Uninstall;
     128    if (Dependencies.IndexOf(ModuleName) <> - 1) and Installed then Uninstall;
    114129  end;
    115130end;
     
    124139    Module := FindModuleByName(Dependencies[I]);
    125140    if Assigned(Module) then begin
    126       if not Module.Installed and (ModuleList.IndexOf(Module.Name) = -1) then begin
    127         ModuleList.Add(Module.Name);
     141      if not Module.Installed and (ModuleList.IndexOf(Module.Identification) = -1) then begin
     142        ModuleList.Add(Module.Identification);
    128143        EnumModulesInstall(Module.Dependencies, ModuleList);
    129144      end;
    130     end else raise Exception.CreateFmt(SModuleNotFound, [Module.Name]);
     145    end else raise Exception.CreateFmt(SModuleNotFound, [Module.Identification]);
    131146  end;
    132147end;
     
    140155  with TModule(Modules[I]) do begin
    141156    if (Dependencies.IndexOf(ModuleName) <> -1) and Installed and
    142       (ModuleList.IndexOf(Name) = -1) then begin
    143       ModuleList.Add(Name);
    144       Self.EnumModulesUninstall(Name, ModuleList);
     157      (ModuleList.IndexOf(Identification) = -1) then begin
     158      ModuleList.Add(Identification);
     159      Self.EnumModulesUninstall(Identification, ModuleList);
    145160    end;
    146161  end;
     
    210225begin
    211226  if not Installed then Exit;
    212   Manager.UninstallDependencies(Name);
     227  Manager.UninstallDependencies(Identification);
    213228  FInstalled := False;
    214229end;
     
    228243begin
    229244  ModuleList.Clear;
    230   Manager.EnumModulesUninstall(Name, ModuleList);
     245  Manager.EnumModulesUninstall(Identification, ModuleList);
    231246end;
    232247
Note: See TracChangeset for help on using the changeset viewer.