Skip to content

Commit

Permalink
Various minor changes #20
Browse files Browse the repository at this point in the history
  • Loading branch information
bero committed Dec 6, 2024
1 parent ec4b65a commit d492eaf
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 32 deletions.
28 changes: 14 additions & 14 deletions Source/BoldClassSubscriber.pas
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ interface
TBoldClassSubscriber = class;
TBoldClassEventMapping = class;
TBoldClassEventMappingCollection = class;
TEventMappingEnumerator = class;
TBoldEventMappingEnumerator = class;

TBoldClassSubscriptionEvent = procedure (AClassList: TBoldObjectList; ASubscriber: TBoldSubscriber) of object;

TBoldClassEventMapping = class(TCollectionItem)
private
fSubscriber: TBoldExtendedPassthroughSubscriber;
fClassTypeName: string;
fOnChange: TBoldExtendedEventHandler;
fOnEvent: TBoldExtendedEventHandler;
fOnSubscribe: TBoldClassSubscriptionEvent;
procedure SetClassTypeName(const Value: string);
function GetStaticSystemTypeInfo: TBoldSystemTypeInfo;
Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -79,7 +79,7 @@ TBoldClassSubscriber = class(TBoldSystemExtensionComponent)
property EventMapping: TBoldClassEventMappingCollection read fMappingCollection write SetEventMappingCollection;
end;

TEventMappingEnumerator = class
TBoldEventMappingEnumerator = class
private
FIndex: Integer;
FCollection: TBoldClassEventMappingCollection;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand All @@ -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;
Expand All @@ -253,22 +253,22 @@ procedure TBoldClassEventMappingCollection.SetItem(Index: Integer;
inherited SetItem(Index, Value);
end;

{ TEventMappingEnumerator }
{ TBoldEventMappingEnumerator }

constructor TEventMappingEnumerator.Create(
constructor TBoldEventMappingEnumerator.Create(
ACollection: TBoldClassEventMappingCollection);
begin
inherited Create;
FIndex := -1;
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;
Expand Down
4 changes: 2 additions & 2 deletions Source/BoldModel.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 8 additions & 11 deletions Source/BoldSystem.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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';
Expand Down
9 changes: 6 additions & 3 deletions Source/BoldUMLModelValidator.pas
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ implementation
BoldPMappers,
BoldDefaultTaggedValues,
BoldDefaultStreamNames,
BoldAttributes;
BoldAttributes,
BoldModel;

resourcestring
// Validator errors
Expand Down Expand Up @@ -369,6 +370,8 @@ function TBoldUMLModelValidator.ExpandedDBName(Elem: TUMLModelElement): String;
NationalCharConversion);
end;

type TBoldModelAccess = class(TBoldModel);

procedure TBoldUMLModelValidator.Validate(TypeNameDictionary: TBoldTypeNameDictionary);
var
I: Integer;
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions Source/BoldUMLOCLValidator.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit d492eaf

Please sign in to comment.