-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Filenames wasn't always unique
Bugfix: Calculation of hashed file names changed to use THashMD5.GetHashString. The CRC32 wasn't accurate enough. Improvements: Implemented double buffering in order to reduce the gap between sentences
- Loading branch information
1 parent
1e3e8e4
commit 0ed5bfc
Showing
7 changed files
with
885 additions
and
711 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
unit EventDispatcher; | ||
|
||
interface | ||
|
||
uses | ||
System.Classes, System.SysUtils, Data.db; | ||
(* | ||
Note: | ||
HINS OFF in order for hiding | ||
H2269 Overriding virtual method XX has lower visibility (strict protected) than base class YY (public) | ||
*) | ||
|
||
type | ||
{$HINTS OFF} | ||
TEventDispatcher<T> = class abstract(TComponent) | ||
strict protected | ||
FClosure: TProc<T>; | ||
constructor Create(aOwner: TComponent); override; | ||
procedure Notify(Sender: T); | ||
end; | ||
{$HINTS ON} | ||
|
||
TNotifyEventDispatcher = class sealed(TEventDispatcher<TObject>) | ||
public | ||
class function Construct(Owner: TComponent; Closure: TProc<TObject>): TNotifyEvent; overload; | ||
function Attach(Closure: TProc<TObject>): TNotifyEvent; | ||
end; | ||
|
||
TDataSetNotifyEventDispatcher = class sealed(TEventDispatcher<TDataSet>) | ||
public | ||
class function Construct(Owner: TComponent; Closure: TProc<TDataSet>): TDataSetNotifyEvent; overload; | ||
function Attach(Closure: TProc<TDataSet>): TDataSetNotifyEvent; | ||
end; | ||
|
||
implementation | ||
|
||
class function TNotifyEventDispatcher.Construct(Owner: TComponent; Closure: TProc<TObject>): TNotifyEvent; | ||
begin | ||
Result := TNotifyEventDispatcher.Create(Owner).Attach(Closure) | ||
end; | ||
|
||
function TNotifyEventDispatcher.Attach(Closure: TProc<TObject>): TNotifyEvent; | ||
begin | ||
FClosure := Closure; | ||
Result := Notify; | ||
end; | ||
|
||
{ TDataSetNotifyEventDispatcher } | ||
|
||
function TDataSetNotifyEventDispatcher.Attach(Closure: TProc<TDataSet>): TDataSetNotifyEvent; | ||
begin | ||
FClosure := Closure; | ||
Result := Notify; | ||
end; | ||
|
||
class function TDataSetNotifyEventDispatcher.Construct(Owner: TComponent; Closure: TProc<TDataSet>): TDataSetNotifyEvent; | ||
begin | ||
Result := TDataSetNotifyEventDispatcher.Create(Owner).Attach(Closure); | ||
end; | ||
|
||
{ TEventDispatcher } | ||
|
||
constructor TEventDispatcher<T>.Create(aOwner: TComponent); | ||
begin | ||
inherited; | ||
end; | ||
|
||
procedure TEventDispatcher<T>.Notify(Sender: T); | ||
begin | ||
if Assigned(FClosure) then | ||
FClosure(Sender) | ||
end; | ||
|
||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.