Skip to content

Commit

Permalink
Bugfix: Filenames wasn't always unique
Browse files Browse the repository at this point in the history
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
JensBorrisholt authored Jul 21, 2018
1 parent 1e3e8e4 commit 0ed5bfc
Show file tree
Hide file tree
Showing 7 changed files with 885 additions and 711 deletions.
74 changes: 74 additions & 0 deletions Delphi/EventDispatcher.pas
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.
12 changes: 6 additions & 6 deletions Delphi/GoogleSpeak.dpr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
program GoogleSpeak;

uses
Vcl.Forms,
MainU in 'MainU.pas' {FormMain},
GoogleSpeakU in 'GoogleSpeakU.pas',
CRC32U in 'CRC32U.pas',
LanguagesU in 'LanguagesU.pas';

Vcl.Forms,
MainU in 'MainU.pas' {FormMain},
GoogleSpeakU in 'GoogleSpeakU.pas',
LanguagesU in 'LanguagesU.pas',
EventDispatcher in 'EventDispatcher.pas';

{$R *.res}

begin
Expand Down
1,099 changes: 566 additions & 533 deletions Delphi/GoogleSpeak.dproj

Large diffs are not rendered by default.

Binary file modified Delphi/GoogleSpeak.res
Binary file not shown.
Loading

0 comments on commit 0ed5bfc

Please sign in to comment.