From d492eaf113145982a61dd3082428799484577569 Mon Sep 17 00:00:00 2001 From: Roland Bengtsson Date: Sat, 7 Dec 2024 00:07:24 +0200 Subject: [PATCH] Various minor changes #20 --- Source/BoldClassSubscriber.pas | 28 ++++++++++++++-------------- Source/BoldModel.pas | 4 ++-- Source/BoldSystem.pas | 19 ++++++++----------- Source/BoldUMLModelValidator.pas | 9 ++++++--- Source/BoldUMLOCLValidator.pas | 6 ++++-- 5 files changed, 34 insertions(+), 32 deletions(-) diff --git a/Source/BoldClassSubscriber.pas b/Source/BoldClassSubscriber.pas index ab95c2d..84c74e1 100644 --- a/Source/BoldClassSubscriber.pas +++ b/Source/BoldClassSubscriber.pas @@ -13,7 +13,7 @@ interface TBoldClassSubscriber = class; TBoldClassEventMapping = class; TBoldClassEventMappingCollection = class; - TEventMappingEnumerator = class; + TBoldEventMappingEnumerator = class; TBoldClassSubscriptionEvent = procedure (AClassList: TBoldObjectList; ASubscriber: TBoldSubscriber) of object; @@ -21,7 +21,7 @@ TBoldClassEventMapping = class(TCollectionItem) private fSubscriber: TBoldExtendedPassthroughSubscriber; fClassTypeName: string; - fOnChange: TBoldExtendedEventHandler; + fOnEvent: TBoldExtendedEventHandler; fOnSubscribe: TBoldClassSubscriptionEvent; procedure SetClassTypeName(const Value: string); function GetStaticSystemTypeInfo: TBoldSystemTypeInfo; @@ -42,7 +42,7 @@ TBoldClassEventMapping = class(TCollectionItem) procedure Assign(Source: TPersistent); override; published property ClassTypeName: string read fClassTypeName write SetClassTypeName; - property OnChange: TBoldExtendedEventHandler read fOnChange write fOnChange; + property OnEvent: TBoldExtendedEventHandler read fOnEvent write fOnEvent; property OnSubscribe: TBoldClassSubscriptionEvent read fOnSubscribe write SetOnSubscribe; end; @@ -58,7 +58,7 @@ TBoldClassEventMappingCollection = class(TCollection) public constructor Create(AEventSubscriber: TBoldClassSubscriber); function Add: TBoldClassEventMapping; - function GetEnumerator: TEventMappingEnumerator; + function GetEnumerator: TBoldEventMappingEnumerator; property Items[Index: Integer]: TBoldClassEventMapping read GetItem write SetItem; default; end; @@ -79,7 +79,7 @@ TBoldClassSubscriber = class(TBoldSystemExtensionComponent) property EventMapping: TBoldClassEventMappingCollection read fMappingCollection write SetEventMappingCollection; end; - TEventMappingEnumerator = class + TBoldEventMappingEnumerator = class private FIndex: Integer; FCollection: TBoldClassEventMappingCollection; @@ -140,7 +140,7 @@ procedure TBoldClassEventMapping.Assign(Source: TPersistent); begin if source is TBoldClassEventMapping then begin - fOnChange := (Source as TBoldClassEventMapping).OnChange; + fOnEvent := (Source as TBoldClassEventMapping).OnEvent; fOnSubscribe := (Source as TBoldClassEventMapping).OnSubscribe; end else @@ -209,8 +209,8 @@ procedure TBoldClassEventMapping.SetOnSubscribe(const Value: TBoldClassSubscript procedure TBoldClassEventMapping._Receive(Originator: TObject; OriginalEvent: TBoldEvent; RequestedEvent: TBoldRequestedEvent; const args: array of const); begin - if Assigned(OnChange) then - OnChange(Originator, OriginalEvent, RequestedEvent, args); + if Assigned(OnEvent) then + OnEvent(Originator, OriginalEvent, RequestedEvent, args); end; { TBoldClassEventMappingCollection } @@ -227,9 +227,9 @@ constructor TBoldClassEventMappingCollection.Create( fBoldEventSubscriber := AEventSubscriber; end; -function TBoldClassEventMappingCollection.GetEnumerator: TEventMappingEnumerator; +function TBoldClassEventMappingCollection.GetEnumerator: TBoldEventMappingEnumerator; begin - Result := TEventMappingEnumerator.Create(Self); + Result := TBoldEventMappingEnumerator.Create(Self); end; function TBoldClassEventMappingCollection.GetEventSubscriber: TBoldClassSubscriber; @@ -253,9 +253,9 @@ procedure TBoldClassEventMappingCollection.SetItem(Index: Integer; inherited SetItem(Index, Value); end; -{ TEventMappingEnumerator } +{ TBoldEventMappingEnumerator } -constructor TEventMappingEnumerator.Create( +constructor TBoldEventMappingEnumerator.Create( ACollection: TBoldClassEventMappingCollection); begin inherited Create; @@ -263,12 +263,12 @@ constructor TEventMappingEnumerator.Create( FCollection := ACollection; end; -function TEventMappingEnumerator.GetCurrent: TBoldClassEventMapping; +function TBoldEventMappingEnumerator.GetCurrent: TBoldClassEventMapping; begin Result := FCollection.Items[FIndex]; end; -function TEventMappingEnumerator.MoveNext: Boolean; +function TBoldEventMappingEnumerator.MoveNext: Boolean; begin Inc(FIndex); Result := FIndex < FCollection.Count; diff --git a/Source/BoldModel.pas b/Source/BoldModel.pas index fcf45e3..c55ad29 100644 --- a/Source/BoldModel.pas +++ b/Source/BoldModel.pas @@ -56,14 +56,14 @@ TBoldModel = class(TBoldAbstractModel) procedure EnsureMoldModelCurrent; override; property UMLModelExposed: Boolean read FUMLModelExposed; property UMLModelMoreCurrent: Boolean read GetUMLModelMoreCurrent; + procedure StartValidation; + procedure EndValidation; public constructor Create(owner: TComponent); override; destructor Destroy; override; procedure Assign(Source: TPersistent); override; procedure EnsureTypes; function UMLModelToString: string; - procedure StartValidation; - procedure EndValidation; property UMLModel: TUMLModel read GetUMLModel; property EnsuredUMLModel: TUMLModel read GetEnsuredUMLModel; property IsValidating: boolean read GetIsValidating; diff --git a/Source/BoldSystem.pas b/Source/BoldSystem.pas index e780a75..b9a4264 100644 --- a/Source/BoldSystem.pas +++ b/Source/BoldSystem.pas @@ -331,7 +331,7 @@ TBoldSystem = class(TBoldDomainElement) function GetClassByObjectClass(AObjectClass: TBoldObjectClass): TBoldObjectList; function GetClassByIndex(index: Integer): TBoldObjectList; function GetDirtyObjects: TList; {of TBoldObject} - function GetDirtyObjectsAsBoldList(AClassType: TBoldObjectClass): TBoldObjectList; + function GetDirtyObjectsAsBoldList(AClassType: TBoldClassTypeInfo): TBoldObjectList; function GetDirtyObjectsAsBoldListByClassExpressionName(const AClass: string): TBoldObjectList; function GetAllDirtyObjectsAsBoldList: TBoldObjectList; function GetEnsuredLocatorByID(ObjectID: TBoldObjectId): TBoldObjectLocator; @@ -432,7 +432,7 @@ TBoldSystem = class(TBoldDomainElement) property ClassByObjectClass[ObjectClass: TBoldObjectClass]: TBoldObjectList read GetClassByObjectClass; property Classes[index: Integer]: TBoldObjectList read GetClassByIndex; property DirtyObjects: TList read GetDirtyObjects; - property DirtyObjectsAsBoldListByClass[AClassType: TBoldObjectClass]: TBoldObjectList read GetDirtyObjectsAsBoldList; + property DirtyObjectsAsBoldListByClass[AClassType: TBoldCLassTypeInfo]: TBoldObjectList read GetDirtyObjectsAsBoldList; property DirtyObjectsAsBoldListByClassExpressionName[const AClass: string]: TBoldObjectList read GetDirtyObjectsAsBoldListByClassExpressionName; property DirtyObjectsAsBoldList: TBoldObjectList read GetAllDirtyObjectsAsBoldList; property EnsuredLocatorByID[ObjectID: TBoldObjectId]: TBoldObjectLocator read GetEnsuredLocatorByID; @@ -2660,18 +2660,18 @@ function TBoldSystem.GetDirtyObjects: TList; result := fDirtyObjects; end; -function TBoldSystem.GetDirtyObjectsAsBoldList(AClassType: TBoldObjectClass): TBoldObjectList; +function TBoldSystem.GetDirtyObjectsAsBoldList(AClassType: TBoldClassTypeInfo): TBoldObjectList; var i: integer; begin if not Assigned(AClassType) then - AClassType := TBoldObjectClass(BoldSystemTypeInfo.RootClassTypeInfo.ObjectClass); - result := TBoldObjectList.CreateWithTypeInfo(BoldSystemTypeInfo.ClassTypeInfoByClass[AClassType]); + AClassType := BoldSystemTypeInfo.RootClassTypeInfo; + result := TBoldObjectList.CreateWithTypeInfo(AClassType); result.DuplicateMode := bldmAllow; result.SubscribeToObjectsInList := false; with result.ObjectListController, GetDirtyObjects do for I := 0 to Count - 1 do - if TBoldObject(Items[i]) is AClassType then + if TBoldObject(Items[i]).BoldType = AClassType then AddLocator(TBoldObject(Items[i]).BoldObjectLocator); result.DuplicateMode := bldmMerge; end; @@ -2685,10 +2685,7 @@ function TBoldSystem.GetDirtyObjectsAsBoldListByClassExpressionName( result := nil; ClassTypeInfo := BoldSystemTypeInfo.ClassTypeInfoByExpressionName[AClass]; if Assigned(ClassTypeInfo) then - begin - AClassType := TBoldObjectClass(ClassTypeInfo.ObjectClass); - result := GetDirtyObjectsAsBoldList(AClassType); - end; + result := GetDirtyObjectsAsBoldList(ClassTypeInfo); end; function TBoldSystem.GetAllDirtyObjectsAsBoldList: TBoldObjectList; @@ -7348,7 +7345,7 @@ function TBoldList.AsCommaText(AIncludeType: boolean; Representation: TBoldRepre begin s := Elements[i].StringRepresentation[Representation]; if AIncludeType then - s := Elements[i].ClassName + ':' + s; + s := Elements[i].DebugInfo + ':' + s; end else s := 'nil'; diff --git a/Source/BoldUMLModelValidator.pas b/Source/BoldUMLModelValidator.pas index 20fe0dc..034c872 100644 --- a/Source/BoldUMLModelValidator.pas +++ b/Source/BoldUMLModelValidator.pas @@ -108,7 +108,8 @@ implementation BoldPMappers, BoldDefaultTaggedValues, BoldDefaultStreamNames, - BoldAttributes; + BoldAttributes, + BoldModel; resourcestring // Validator errors @@ -369,6 +370,8 @@ function TBoldUMLModelValidator.ExpandedDBName(Elem: TUMLModelElement): String; NationalCharConversion); end; +type TBoldModelAccess = class(TBoldModel); + procedure TBoldUMLModelValidator.Validate(TypeNameDictionary: TBoldTypeNameDictionary); var I: Integer; @@ -391,7 +394,7 @@ procedure TBoldUMLModelValidator.Validate(TypeNameDictionary: TBoldTypeNameDicti BoldLog.StartLog('Validating the model'); UndoWasEnabled := UMLModel.BoldSystem.UndoHandlerInterface.Enabled; UMLModel.BoldSystem.UndoHandlerInterface.Enabled := false; - BoldModel.StartValidation; + TBoldModelAccess(BoldModel).StartValidation; try UMLModel.BoldSystem.StartTransaction(); try @@ -474,7 +477,7 @@ procedure TBoldUMLModelValidator.Validate(TypeNameDictionary: TBoldTypeNameDicti end; finally BoldLog.EndLog; - BoldModel.EndValidation; + TBoldModelAccess(BoldModel).EndValidation; UMLModel.BoldSystem.UndoHandlerInterface.Enabled := UndoWasEnabled; end; end; diff --git a/Source/BoldUMLOCLValidator.pas b/Source/BoldUMLOCLValidator.pas index ac18e22..6f7e181 100644 --- a/Source/BoldUMLOCLValidator.pas +++ b/Source/BoldUMLOCLValidator.pas @@ -201,13 +201,15 @@ procedure TOCLValidityChecker.ValidateExpression(const ScopeName: string; Elemen AddViolation(sError, Element, ErrorHeader + Format(' Type mismatch: Expected %s got %s', [ElementTypeInfo.ExpressionName, Result.ExpressionName])); end; +type TBoldModelAccess = class(TBoldModel); + procedure TOCLValidityChecker.ValidateModel(BoldModel: TBoldModel); var i: integer; begin fBoldModel := BoldModel; fUMLModel := BoldModel.EnsuredUMLModel; - BoldModel.StartValidation; + TBoldModelAccess(BoldModel).StartValidation; BoldLog.StartLog('Validating OCL in model'); try fSystemTypeInfo := ExtractSystemTypeInfo(BoldModel); @@ -217,7 +219,7 @@ procedure TOCLValidityChecker.ValidateModel(BoldModel: TBoldModel); for i := 0 to UMLModel.associations.Count - 1 do ValidateAssociation(UMLModel.associations[i]); finally - BoldModel.EndValidation; + TBoldModelAccess(BoldModel).EndValidation; BoldLog.EndLog; end; end;