DataPoint
This commit is contained in:
+40
-18
@@ -69,6 +69,7 @@ type
|
||||
private
|
||||
FState: IState;
|
||||
function GetIsSet: Boolean; inline;
|
||||
function GetAsSignal: TSignal; inline;
|
||||
{$ENDREGION}
|
||||
public
|
||||
constructor Create(const AState: IState);
|
||||
@@ -84,6 +85,10 @@ type
|
||||
function Subscribe(Subscriber: TSignal.ISubscriber): TSignal.TSubscription; inline;
|
||||
|
||||
property IsSet: Boolean read GetIsSet;
|
||||
|
||||
// Explicitly cast a state to a signal. This is dangerous, use with care!
|
||||
// States only notify, when they change. This behaviour is obscured by treating it like a signal.
|
||||
property AsSignal: TSignal read GetAsSignal;
|
||||
end;
|
||||
|
||||
// An event is a stateless signal that forwards all notifications to the subscribers.
|
||||
@@ -113,6 +118,7 @@ type
|
||||
class operator Implicit(const A: TEvent): IEvent; overload;
|
||||
|
||||
class function CreateEvent: TEvent; static;
|
||||
class function CreateRouter(const Signal: TSignal): TEvent; static;
|
||||
|
||||
class property Null: IEvent read FNull;
|
||||
|
||||
@@ -141,7 +147,7 @@ type
|
||||
|
||||
private
|
||||
FLatch: ILatch;
|
||||
function GetState: TState; inline;
|
||||
function GetState: TState.IState; inline;
|
||||
{$ENDREGION}
|
||||
public
|
||||
constructor Create(const ALatch: ILatch);
|
||||
@@ -149,7 +155,7 @@ type
|
||||
class operator Implicit(const A: ILatch): TLatch; overload;
|
||||
class operator Implicit(const A: TLatch): ILatch; overload;
|
||||
|
||||
class function CreateLatch(Count: Integer): TLatch; static;
|
||||
class function CreateLatch(Count: Integer): ILatch; static;
|
||||
|
||||
class function Enqueue1(var Gate: TLatch): TState; overload; static;
|
||||
function Enqueue: TState; overload;
|
||||
@@ -158,7 +164,7 @@ type
|
||||
|
||||
function Notify: Boolean; inline;
|
||||
|
||||
property State: TState read GetState;
|
||||
property State: TState.IState read GetState;
|
||||
end;
|
||||
|
||||
// TFlag represents a resettable flag, typically indicating if a State is "dirty" (requiring attention) or "clean".
|
||||
@@ -179,17 +185,18 @@ type
|
||||
class constructor ClassCreate;
|
||||
|
||||
private
|
||||
FDirty: IFlag;
|
||||
FFlag: IFlag;
|
||||
function GetState: TState; inline;
|
||||
|
||||
{$ENDREGION}
|
||||
public
|
||||
constructor Create(const ADirty: IFlag);
|
||||
constructor Create(const AFlag: IFlag);
|
||||
class operator Initialize(out Dest: TFlag);
|
||||
class operator Implicit(const A: IFlag): TFlag; overload;
|
||||
class operator Implicit(const A: TFlag): IFlag; overload;
|
||||
|
||||
class function CreateFlag: IFlag; static;
|
||||
class function CreateFlag: TFlag; static;
|
||||
class function CreateObserver(const Signal: TSignal): TFlag; static;
|
||||
class property Null: IFlag read FNull;
|
||||
|
||||
function Notify: Boolean; inline;
|
||||
@@ -268,6 +275,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TState.GetAsSignal: TSignal;
|
||||
begin
|
||||
Result := FState;
|
||||
end;
|
||||
|
||||
function TState.GetIsSet: Boolean;
|
||||
begin
|
||||
Result := FState.IsSet;
|
||||
@@ -312,6 +324,11 @@ begin
|
||||
Result := TMycEvent.Create;
|
||||
end;
|
||||
|
||||
class function TEvent.CreateRouter(const Signal: TSignal): TEvent;
|
||||
begin
|
||||
Result := TMycRouterEvent.Create(Signal);
|
||||
end;
|
||||
|
||||
function TEvent.GetSignal: TSignal;
|
||||
begin
|
||||
Result := FEvent.Signal;
|
||||
@@ -344,31 +361,36 @@ begin
|
||||
FNull := TMycNullFlag.Create;
|
||||
end;
|
||||
|
||||
constructor TFlag.Create(const ADirty: IFlag);
|
||||
constructor TFlag.Create(const AFlag: IFlag);
|
||||
begin
|
||||
FDirty := ADirty;
|
||||
if not Assigned(FDirty) then
|
||||
FDirty := FNull;
|
||||
FFlag := AFlag;
|
||||
if not Assigned(FFlag) then
|
||||
FFlag := FNull;
|
||||
end;
|
||||
|
||||
class function TFlag.CreateFlag: IFlag;
|
||||
class function TFlag.CreateFlag: TFlag;
|
||||
begin
|
||||
Result := TMycFlag.Create;
|
||||
end;
|
||||
|
||||
class function TFlag.CreateObserver(const Signal: TSignal): TFlag;
|
||||
begin
|
||||
Result.Create(TMycObserverFlag.Create(Signal));
|
||||
end;
|
||||
|
||||
function TFlag.GetState: TState;
|
||||
begin
|
||||
Result := FDirty.State;
|
||||
Result := FFlag.State;
|
||||
end;
|
||||
|
||||
function TFlag.Notify: Boolean;
|
||||
begin
|
||||
Result := FDirty.Notify;
|
||||
Result := FFlag.Notify;
|
||||
end;
|
||||
|
||||
function TFlag.Reset: Boolean;
|
||||
begin
|
||||
Result := FDirty.Reset;
|
||||
Result := FFlag.Reset;
|
||||
end;
|
||||
|
||||
class operator TFlag.Implicit(const A: IFlag): TFlag;
|
||||
@@ -378,12 +400,12 @@ end;
|
||||
|
||||
class operator TFlag.Implicit(const A: TFlag): IFlag;
|
||||
begin
|
||||
Result := A.FDirty;
|
||||
Result := A.FFlag;
|
||||
end;
|
||||
|
||||
class operator TFlag.Initialize(out Dest: TFlag);
|
||||
begin
|
||||
Dest.FDirty := FNull;
|
||||
Dest.FFlag := FNull;
|
||||
end;
|
||||
|
||||
{ TLatch }
|
||||
@@ -402,7 +424,7 @@ begin
|
||||
FLatch := FNull;
|
||||
end;
|
||||
|
||||
class function TLatch.CreateLatch(Count: Integer): TLatch;
|
||||
class function TLatch.CreateLatch(Count: Integer): ILatch;
|
||||
begin
|
||||
if Count > 0 then
|
||||
Result := TMycLatch.Create(Count)
|
||||
@@ -452,7 +474,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TLatch.GetState: TState;
|
||||
function TLatch.GetState: TState.IState;
|
||||
begin
|
||||
Result := FLatch.State;
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user