Changeset 251


Ignore:
Timestamp:
Jun 13, 2011, 8:21:12 AM (13 years ago)
Author:
george
Message:
  • Modified: DebugLog transformed to component.
  • Fixed: String compare for template generics.
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Common/Common.lpk

    r249 r251  
    66    <Author Value="Chronos (robie@centrum.cz)"/>
    77    <CompilerOptions>
    8       <Version Value="9"/>
     8      <Version Value="10"/>
    99      <PathDelim Value="\"/>
    1010      <SearchPaths>
     
    2929      <Item3>
    3030        <Filename Value="UDebugLog.pas"/>
     31        <HasRegisterProc Value="True"/>
    3132        <UnitName Value="UDebugLog"/>
    3233      </Item3>
  • Common/Common.pas

    r230 r251  
    88
    99uses
    10     StopWatch, UCommon, UDebugLog, UDelay, UPrefixMultiplier, UURI,
    11   UThreading, LazarusPackageIntf;
     10  StopWatch, UCommon, UDebugLog, UDelay, UPrefixMultiplier, UURI, UThreading,
     11  LazarusPackageIntf;
    1212
    1313implementation
     
    1515procedure Register;
    1616begin
     17  RegisterUnit('UDebugLog', @UDebugLog.Register);
    1718end;
    1819
  • Common/UDebugLog.pas

    r250 r251  
    2424  private
    2525    FFileName: string;
     26    FMaxCount: Integer;
    2627    FOnNewItem: TNewItemEvent;
     28    FWriteToFileEnable: Boolean;
     29    procedure SetMaxCount(const AValue: Integer);
    2730  public
    28     WriteToFileEnable: Boolean;
    2931    Items: TThreadList;
    30     MaxCount: Integer;
    3132    procedure Add(Group: string; Text: string);
    3233    procedure WriteToFile(Text: string);
    33     property OnNewItem: TNewItemEvent read FOnNewItem write FOnNewItem;
    3434    constructor Create(AOwner: TComponent); override;
    3535    destructor Destroy; override;
    3636  published
     37    property WriteToFileEnable: Boolean read FWriteToFileEnable
     38      write FWriteToFileEnable;
    3739    property FileName: string read FFileName write FFileName;
     40    property MaxCount: Integer read FMaxCount write SetMaxCount;
     41    property OnNewItem: TNewItemEvent read FOnNewItem write FOnNewItem;
    3842  end;
    3943
    40 var
    41   DebugLog: TDebugLog;
     44procedure Register;
    4245
    4346implementation
    4447
     48procedure Register;
     49begin
     50  RegisterComponents('Common', [TDebugLog]);
     51end;
     52
    4553{ TDebugLog }
     54
     55procedure TDebugLog.SetMaxCount(const AValue: Integer);
     56var
     57  List: TList;
     58  I: Integer;
     59begin
     60  if FMaxCount = AValue then Exit;
     61  FMaxCount := AValue;
     62  List := Items.LockList;
     63  if List.Count > 0 then begin
     64    for I := AValue to List.Count - 1 do
     65      TDebugLogItem(List[I]).Free;
     66    List.Count := AValue;
     67  end;
     68  Items.UnlockList;
     69end;
    4670
    4771procedure TDebugLog.Add(Group: string; Text: string);
  • Generics/TemplateGenerics/Generic/GenericList.inc

    r247 r251  
    4242    function GetArray: TGListItemArray;
    4343    function Implode(Separator: string; Converter: TGListToStringConverter): string;
    44     function IndexOf(Item: TGListItem; Start: TGListIndex = 0): TGListIndex;
     44    function IndexOf(Item: TGListItem; Start: TGListIndex = 0): TGListIndex; virtual;
    4545    function IndexOfList(List: TGList; Start: TGListIndex = 0): TGListIndex;
    4646    procedure Insert(Index: TGListIndex; Item: TGListItem);
  • Generics/TemplateGenerics/Generic/GenericListString.inc

    r112 r251  
    1818    procedure Clear; override;
    1919    procedure Assign(Source: TGList); override;
     20    function IndexOf(Item: TGListItem; Start: TGListIndex = 0): TGListIndex; override;
    2021    constructor Create;
    2122    destructor Destroy; override;
     
    7172end;
    7273
     74function TGListString.IndexOf(Item: TGListItem; Start: TGListIndex): TGListIndex;
     75begin
     76  Result := Start;
     77  while (Result < Count) and
     78  (CompareStr(FItems[Result], Item) = -1) do
     79    Result := Result + 1;
     80  if Result = FCount then Result := -1;
     81end;
     82
    7383constructor TGListString.Create;
    7484begin
Note: See TracChangeset for help on using the changeset viewer.