Skip to content

Commit

Permalink
Removed conditional for broadcast, now it is merged as default behavi…
Browse files Browse the repository at this point in the history
…our. #20
  • Loading branch information
bero committed Dec 6, 2024
1 parent 4592450 commit 84b624c
Show file tree
Hide file tree
Showing 20 changed files with 134 additions and 186 deletions.
4 changes: 0 additions & 4 deletions Source/Bold.inc
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ Illegal symbol combination
//Adds brJson StringRepresentation via BoldObjectRepresentationJson unit
{$DEFINE BoldJson}

// BoldSystem broadcasts member events - allows getting events from all objects and their members by only placing one subscription on system
{$DEFINE BoldSystemBroadcastMemberEvents}

// NoEnsureEnclosure skips EnsureEnclosure call in UpdateDatabase, use NoEnsureEnclosure if objects passed to UpdateDatabase are already enclosed
{.$DEFINE NoEnsureEnclosure}

Expand Down Expand Up @@ -237,6 +234,5 @@ Illegal symbol combination
{$UNDEF IDServer}
{$UNDEF NoNegativeDates}
{$UNDEF ConvertZeroDateToDateNil}
{$UNDEF BoldSystemBroadcastMemberEvents}
{$ENDIF}

4 changes: 2 additions & 2 deletions Source/BoldAFPDefault.pas
Original file line number Diff line number Diff line change
Expand Up @@ -952,14 +952,14 @@ function TBoldDefaultObjectAutoFormProvider.GetGoodStringRepresentationForSingle
ClassTypeInfo := (MemberRTInfo as TBoldRoleRTInfo).ClassTypeInfoOfOtherEnd;
if ClassTypeInfo.DefaultStringRepresentation = '' then
begin
for i := 0 to ClassTypeInfo.AllMembers.Count - 1 do
for i := 0 to ClassTypeInfo.AllMembersCount - 1 do
if ClassTypeInfo.AllMembers[i].BoldType.ExpressionName = 'String' then // do not localize
begin
Result := ClassTypeInfo.AllMembers[i].ExpressionName;
exit;
end;

for i := 0 to ClassTypeInfo.AllMembers.Count - 1 do
for i := 0 to ClassTypeInfo.AllMembersCount - 1 do
if ClassTypeInfo.AllMembers[i] is TBoldAttributeRTInfo then
begin
Result := ClassTypeInfo.AllMembers[i].ExpressionName;
Expand Down
4 changes: 0 additions & 4 deletions Source/BoldConstraintValidator.pas
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,7 @@ procedure TBoldConstraintValidator.Changed;
case ValidationMode of
vmManual:;
vmOnModify:
{$IFDEF BoldSystemBroadcastMemberEvents}
BoldSystem.AddSubscription(Subscriber, beCompleteModify, beCompleteModify);
{$ELSE}
raise Exception.CreateFmt(sVMOnModifyRequirements, [ClassName]);
{$ENDIF}
vmPreUpdate:
BoldSystem.OnPreUpdate := PreUpdate;
end;
Expand Down
1 change: 0 additions & 1 deletion Source/BoldCoreConsts.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,6 @@ interface
sUMLGenInterface = 'Generate Persistence Interfaces';

// BoldConstraintValidator
sVMOnModifyRequirements = '%s: vmOnModify mode requires BoldSystemBroadcastMemberEvents conditional define.';
sConstraints = 'Constraints';

implementation
Expand Down
7 changes: 4 additions & 3 deletions Source/BoldElements.pas
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ interface
befInDelayDestructionList = BoldElementFlag13;
befDiscarding = BoldElementFlag14;
befDeleting = BoldElementFlag15;
befCreating = BoldElementFlag16;

{flags for BoldMember}
befIsNull = BoldElementFlag4;
Expand Down Expand Up @@ -711,8 +712,8 @@ procedure TBoldElement.CompareTypeError(CompType: TBoldCompareType; BoldElement:
ElementName := BoldElement.ClassName
else
ElementName := 'nil';
raise EBold.CreateFmt(sInvalidCompareType, [ClassName,

raise EBold.CreateFmt(sInvalidCompareType, [ClassName,
GetEnumName(TypeInfo(TBoldCompareType), Ord(CompType)), ElementName]);
end;

Expand Down Expand Up @@ -1175,7 +1176,7 @@ procedure InitDebugMethods;
List: TBoldExternalVariableList;
begin
// Used to force compiler to link AsCommaText, so it can be used in debugging
exit;
exit;
List := nil;
List.AsCommaText;
end;
Expand Down
24 changes: 16 additions & 8 deletions Source/BoldLogHandlerForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ TBoldLogHandlerReceiver = class(TInterfacedObject, IBoldLogReceiver)
procedure SetProgressMax(const Value: integer);
procedure ProcessInterruption;
public
procedure AfterConstruction; override;
destructor Destroy; override;
procedure Clear;
procedure Hide;
Expand All @@ -42,6 +43,8 @@ TBoldLogHandlerReceiver = class(TInterfacedObject, IBoldLogReceiver)
procedure SaveLog;
end;

function BoldLogForm: IBoldLogReceiver;

implementation

uses
Expand All @@ -54,8 +57,21 @@ implementation
var
LogHandlerForm: TBoldLogHandlerReceiver;

function BoldLogForm: IBoldLogReceiver;
begin
if not Assigned(LogHandlerForm) then
LogHandlerForm := TBoldLogHandlerReceiver.Create;
result := LogHandlerForm;
end;

{ TBoldLogHandlerReceiver }

procedure TBoldLogHandlerReceiver.AfterConstruction;
begin
inherited;
BoldLog.RegisterLogReceiver(self as IBoldLogReceiver);
end;

procedure TBoldLogHandlerReceiver.Clear;
begin
LogForm.Clear;
Expand Down Expand Up @@ -155,12 +171,4 @@ procedure TBoldLogHandlerReceiver.Sync;
Application.ProcessMessages;
end;

initialization
// LogHandlerForm := TBoldLogHandlerReceiver.Create;
// BoldLog.RegisterLogReceiver(LogHandlerForm as IBoldLogReceiver);

finalization
// if Assigned(LogHandlerForm) then
// BoldLog.UnregisterLogReceiver(LogHandlerForm as IBoldLogReceiver);

end.
108 changes: 52 additions & 56 deletions Source/BoldObjectListControllers.pas
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ TBoldClassListController = class(TBoldObjectListController)
public
constructor Create(OwningList: TBoldObjectList);
destructor Destroy; override;
procedure ReceiveClassEvent(BoldObject: TBoldObject; Event: TBoldEvent);
procedure ReceiveClassEvent(BoldElement: TBoldDomainElement; Event: TBoldEvent; const Args: array of const);
function ProxyInterface(const IId: TGUID; Mode: TBoldDomainElementProxyMode; out Obj): Boolean; override;
function AtTime(Time: TBoldTimeStampType): TBoldMember; override;
function HandlesAtTime: Boolean; override;
Expand Down Expand Up @@ -393,16 +393,10 @@ procedure TBoldObjectListController._ReceiveObjectDeleted(
var
DeletedLocator: TBoldObjectLocator;
begin
assert(originator is TBoldObjectList);
case OriginalEvent of
beLocatorDestroying,
beItemDeleted:
beLocatorDestroying, beObjectDeleted:
begin
assert(High(Args) = 0);
assert(Args[0].vType = vtObject);
Assert(Args[0].VObject is TBoldObjectLocator);
DeletedLocator := TBoldObjectLocator(Args[0].VObject);
Assert(not Assigned(OwningList.Boldtype) or DeletedLocator.BoldClassTypeInfo.BoldIsA(OwningObjectList.ListElementTypeInfo));
DeletedLocator := (Originator as TBoldObject).BoldObjectLocator;
RemoveLocator(DeletedLocator);
end;
beDestroying:
Expand Down Expand Up @@ -434,13 +428,13 @@ procedure TBoldObjectListController.SubscribeToObjectDeleted(Locator: TBoldObjec
// Subscribe to ClassList instead of System to avoid having all subscriptions on system.
// When object is deleted, system sends beObjectDeleted, ClassList receives it and sends beItemDeleted instead
if OwningObjectList.SubscribeToObjectsInList then
ClassList.AddSmallSubscription(FSubscriber, [beLocatorDestroying, beDestroying, beItemDeleted])
ClassList.AddSmallSubscription(FSubscriber, [beLocatorDestroying, beObjectDeleted{, beDestroying}])
else
ClassList.AddSmallSubscription(FSubscriber, [beLocatorDestroying]);
end
else
if OwningObjectList.SubscribeToObjectsInList then
ClassList.AddSmallSubscription(FSubscriber, [beDestroying, beItemDeleted]);
ClassList.AddSmallSubscription(FSubscriber, [beDestroying, beObjectDeleted]);
end;

procedure TBoldObjectListController.DropSubscriptions;
Expand Down Expand Up @@ -664,68 +658,70 @@ procedure TBoldClassListController.MarkListCurrent;
type
TBoldObjectListAccess = class(TBoldObjectList);

procedure TBoldClassListController.ReceiveClassEvent(BoldObject: TBoldObject; Event: TBoldEvent);
procedure TBoldClassListController.ReceiveClassEvent(BoldElement: TBoldDomainElement; Event: TBoldEvent; const Args: array of const);
var
List: TBoldObjectListAccess;
begin
List := TBoldObjectListAccess(OwningList);
if Assigned(fSuperClassController) then
fSuperClassController.ReceiveClassEvent(BoldObject, Event);
case Event of
beObjectCreated:
begin
inc(fLoadedObjectCount);
if Owninglist.BoldPersistenceState in [bvpsCurrent, bvpsTransient] then
fSuperClassController.ReceiveClassEvent(BoldElement, Event, args);
List := TBoldObjectListAccess(OwningList);
if BoldElement is TBoldObject then
begin
var BoldObject: TBoldObject;
BoldObject := BoldElement as TBoldObject;
case Event of
beObjectCreated:
begin
AddLocator(BoldObject.BoldObjectLocator);
Owninglist.Invalidate;
inc(fLoadedObjectCount);
if not List.BoldPersistenceStateIsInvalid then
begin
AddLocator(BoldObject.BoldObjectLocator);
if List.HasSubscribers then
List.Publisher.SendEvent(beValueInvalid);
end;
end;
end;
beObjectDeleted:
begin
Dec(fLoadedObjectCount);
if Owninglist.BoldPersistenceState in [bvpsCurrent, bvpsTransient] then
beObjectDeleted:
begin
if ClassTypeInfo.Persistent and BoldSystem.BoldPersistent then
LocatorList.Remove(BoldObject.BoldObjectLocator);
Owninglist.Invalidate;
Dec(fLoadedObjectCount);
LocatorList.Remove(BoldObject.BoldObjectLocator);
if not List.BoldPersistenceStateIsInvalid then
begin
// if ClassTypeInfo.Persistent and BoldSystem.BoldPersistent then
// Assert(LocatorList.Includes(BoldObject.BoldObjectLocator));
if List.HasSubscribers then
List.Publisher.SendEvent(beValueInvalid);
end;
end;
end;
beObjectFetched:
begin
inc(fLoadedObjectCount);
if Owninglist.BoldPersistenceState in [bvpsCurrent, bvpsTransient] then
beObjectFetched:
begin
if not LocatorList.LocatorInList[BoldObject.BoldObjectLocator] then
AddLocator(BoldObject.BoldObjectLocator);
if (Owninglist.BoldPersistenceState = bvpsTransient) and (fLoadedObjectCount = count) then
MarkListCurrent;
inc(fLoadedObjectCount);
if not List.BoldPersistenceStateIsInvalid then
begin
if not LocatorList.LocatorInList[BoldObject.BoldObjectLocator] then
AddLocator(BoldObject.BoldObjectLocator);
if (List.BoldPersistenceState = bvpsTransient) and (fLoadedObjectCount = count) then
MarkListCurrent;
end;
end;
end;
beObjectUnloaded:
begin
if not BoldObject.BoldObjectIsDeleted then
beObjectUnloaded:
begin
Dec(fLoadedObjectCount);
if Owninglist.BoldPersistenceState in [bvpsCurrent, bvpsTransient] then
if not BoldObject.BoldObjectIsDeleted then
begin
SetPersistenceState(bvpsTransient);
if list.HasSubscribers then
OwningList.SendEvent(beValueInvalid);
Dec(fLoadedObjectCount);
if not List.BoldPersistenceStateIsInvalid then
begin
SetPersistenceState(bvpsTransient);
if list.HasSubscribers then
List.Publisher.SendEvent(beValueInvalid);
end;
end;
end;
end;
end;
if List.HasSubscribers then
case event of
beObjectCreated: List.Publisher.SendExtendedEvent(OwningList, beItemAdded, [BoldObject.BoldObjectLocator]);
beObjectDeleted: List.Publisher.SendExtendedEvent(OwningList, beItemDeleted, [BoldObject.BoldObjectLocator]);
beObjectFetched: List.Publisher.SendExtendedEvent(OwningList, beObjectFetched, [BoldObject.BoldObjectLocator]);
beObjectUnloaded: List.Publisher.SendExtendedEvent(OwningList, beObjectUnloaded, [BoldObject.BoldObjectLocator]);
beLocatorDestroying: List.Publisher.SendExtendedEvent(OwningList, beLocatorDestroying, [BoldObject.BoldObjectLocator])
else
raise EBoldInternal.CreateFmt('%s.ReceiveClassEvent: Unknown event: %d', [ClassName, Event]);
end;
begin
List.Publisher.SendExtendedEvent(BoldElement, Event, Args);
end;
end;

procedure TBoldClassListController.RemoveByIndex(index: Integer);
Expand Down
2 changes: 1 addition & 1 deletion Source/BoldObjectRepresentationJson.pas
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ function TBoldElementJsonConverter.CreateJsonForBoldObject(aBoldObject: TBoldObj
//js.Add('id',StrToInt(aBoldObject.BoldObjectLocator.BoldObjectID.AsString));
//Result.Add('id',aBoldObject.BoldMemberByExpressionName['objectGUID'].AsString);

for I := 0 to aBoldObject.BoldClassTypeInfo.AllMembers.Count - 1 do
for I := 0 to aBoldObject.BoldClassTypeInfo.AllMembersCount - 1 do
try
vBoldMember := aBoldObject.BoldMembers[i];
vMemberRTInfo := vBoldMember.BoldMemberRTInfo;
Expand Down
2 changes: 1 addition & 1 deletion Source/BoldOcl.pas
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ procedure TBoldOcl.CalculateMaxMemberNameLength;
begin
ClassInfo := fSystemTypeInfo.TopSortedClasses[i];
vLength := 0;
for j := 0 to ClassInfo.AllMembers.Count - 1 do
for j := 0 to ClassInfo.AllMembersCount - 1 do
vLength := Max(vLength, Length(ClassInfo.AllMembers[j].ExpressionName));
fMaxMemberNameArray[i] := vLength;
end;
Expand Down
2 changes: 1 addition & 1 deletion Source/BoldOclPropEditor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ procedure TBoldOclPropEditForm.MemberHelp(Ocl: String);
if ExpressionType is TBoldClasstypeInfo then
begin
ClassInfo := ExpressionType as TBoldClasstypeInfo;
for I := 0 to ClassInfo.AllMembers.Count - 1 do
for I := 0 to ClassInfo.AllMembersCount - 1 do
begin
Member := ClassInfo.AllMembers[I];
if not ShowDerived and Member.IsDerived then continue;
Expand Down
2 changes: 1 addition & 1 deletion Source/BoldRegionDefinitionParser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ procedure TBoldRegionParser.GenerateDefaultRegions;
DefaultRegion := DefaultCore.EnsuredConcreteDefinition(ClassTypeInfo, existed);
if not existed then
begin
for MemberIx := 0 to ClassTypeInfo.AllMembers.Count-1 do
for MemberIx := 0 to ClassTypeInfo.AllMembersCount-1 do
begin
MemberRTInfo := ClassTypeInfo.AllMembers[MemberIx];
if MemberRTInfo.IsAttribute then
Expand Down
6 changes: 3 additions & 3 deletions Source/BoldSamplesReg.pas
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ procedure RegisterEditors;

procedure Register;
begin
RegisterComponentsOnPalette;
RegisterBoldActions;
RegisterEditors;
RegisterComponentsOnPalette;
RegisterBoldActions;
RegisterEditors;
end;

{ TTextFileProperty }
Expand Down
2 changes: 1 addition & 1 deletion Source/BoldSmallLogFrame.pas
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ procedure TBoldLogFrame.btnStopClick(Sender: TObject);

procedure TBoldLogFrame.ProcessInterruption;
begin
application.ProcessMessages;
Application.ProcessMessages;
end;

procedure TBoldLogFrame.Sync;
Expand Down
Loading

0 comments on commit 84b624c

Please sign in to comment.