From c8548cd4def96709b377e400c02179db8d2a5b75 Mon Sep 17 00:00:00 2001 From: ernstaii Date: Wed, 12 Jun 2024 16:24:07 +0100 Subject: [PATCH] Added class diagrams and some comments Diagrams for the main application classes and the model. --- .../Actions/Management/ActionManager.cs | 4 + .../Actions/Management/ActionStore.cs | 20 +++ .../ApplicationClasses.cd | 126 ++++++++++++++ .../DsmSuite.DsmViewer.Application.csproj | 4 +- .../Interfaces/ActionType.cs | 4 + .../Queries/DsmQueries.cs | 6 + .../Core/DsmActionModel.cs | 3 + .../Core/DsmElementModel.cs | 3 + .../Core/DsmRelationModel.cs | 3 + .../DsmSuite.DsmViewer.Model.csproj | 4 +- .../Interfaces/IDsmModel.cs | 10 ++ DsmSuite.DsmViewer.Model/ModelClasses.cd | 163 ++++++++++++++++++ 12 files changed, 348 insertions(+), 2 deletions(-) create mode 100644 DsmSuite.DsmViewer.Application/ApplicationClasses.cd create mode 100644 DsmSuite.DsmViewer.Model/ModelClasses.cd diff --git a/DsmSuite.DsmViewer.Application/Actions/Management/ActionManager.cs b/DsmSuite.DsmViewer.Application/Actions/Management/ActionManager.cs index 0f096b7e..a4620e33 100644 --- a/DsmSuite.DsmViewer.Application/Actions/Management/ActionManager.cs +++ b/DsmSuite.DsmViewer.Application/Actions/Management/ActionManager.cs @@ -7,6 +7,10 @@ namespace DsmSuite.DsmViewer.Application.Actions.Management { + /// + /// Manages user actions. + /// This include executing them, undo/redo and keeping a list of all executed actions. + /// public class ActionManager : IActionManager { private readonly Stack _undoActionStack; diff --git a/DsmSuite.DsmViewer.Application/Actions/Management/ActionStore.cs b/DsmSuite.DsmViewer.Application/Actions/Management/ActionStore.cs index b6f1c6d0..e81151d9 100644 --- a/DsmSuite.DsmViewer.Application/Actions/Management/ActionStore.cs +++ b/DsmSuite.DsmViewer.Application/Actions/Management/ActionStore.cs @@ -8,10 +8,21 @@ namespace DsmSuite.DsmViewer.Application.Actions.Management { + /// + /// Stores/restores user actions to/from the model. + /// + /// + /// The ActionType enum tags are used as the action string for the model. + /// public class ActionStore { private readonly IDsmModel _model; private readonly IActionManager _actionManager; + // Translate ActionType's to the implementing classes. + // The ActionType enum tags are used as the action string for the model. + // TODO Isn't a string->Type dictionary more suitable? + // TODO Make certain (compile/runtime) all actions are indeed in the table (cut/copy/paste currently aren't) + // otherwise we can't load model that we saved. private readonly Dictionary _types; public ActionStore(IDsmModel model, IActionManager actionManager) @@ -23,6 +34,11 @@ public ActionStore(IDsmModel model, IActionManager actionManager) RegisterActionTypes(); } + /// + /// Loads all actions from the model into the ActionManager. + /// Unrecognized actions are silently ignored. + /// If any action cannot be loaded correctly, the ActionManager is cleared. + /// public void LoadFromModel() { foreach (IDsmAction action in _model.GetActions()) @@ -50,6 +66,9 @@ public void LoadFromModel() } } + /// + /// Saves all actions in the ActionManager to the model. + /// public void SaveToModel() { if (_actionManager.Validate()) @@ -63,6 +82,7 @@ public void SaveToModel() private void RegisterActionTypes() { + //TODO cut/copy/paste actions not present _types[ElementChangeNameAction.RegisteredType] = typeof(ElementChangeNameAction); _types[ElementChangeTypeAction.RegisteredType] = typeof(ElementChangeTypeAction); _types[ElementChangeParentAction.RegisteredType] = typeof(ElementChangeParentAction); diff --git a/DsmSuite.DsmViewer.Application/ApplicationClasses.cd b/DsmSuite.DsmViewer.Application/ApplicationClasses.cd new file mode 100644 index 00000000..9a183fe9 --- /dev/null +++ b/DsmSuite.DsmViewer.Application/ApplicationClasses.cd @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ApE2RAoAJoyABACDABIbREEhoAhopYCERlAgBIUAQIA= + Core\DsmApplication.cs + + + + + + + + + + + + + + + + + + + + + + + + AAIQAAQABACABASAAIAAEAIBAAAAAAAAECACAAFAAAA= + Actions\Management\ActionManager.cs + + + + + + + + + + + + + + + + AAAAAAAAAAAAAAQAAgAABAAAEAAAAAAAAAAAAEAAQAA= + Actions\Management\ActionStore.cs + + + + + + + + + + AAAAAAIAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA= + Metrics\DsmMetrics.cs + + + + + + + + + + + AAEAAAAAAAAAAAACAgACBAAAgABgAQCAAAAAAAAAAIA= + Queries\DsmQueries.cs + + + + + + + + + + + + + AAIAAAAAAACAAAQAAIAAAAAAAAAAAAAAACAAAABAAAA= + Actions\Management\IActionManager.cs + + + + + + AAAAAAAAAAAgBEAAAAgAAAAACAAAABAAAQAAAAAAAAA= + Interfaces\IAction.cs + + + + \ No newline at end of file diff --git a/DsmSuite.DsmViewer.Application/DsmSuite.DsmViewer.Application.csproj b/DsmSuite.DsmViewer.Application/DsmSuite.DsmViewer.Application.csproj index aad11881..16cf5b84 100644 --- a/DsmSuite.DsmViewer.Application/DsmSuite.DsmViewer.Application.csproj +++ b/DsmSuite.DsmViewer.Application/DsmSuite.DsmViewer.Application.csproj @@ -68,7 +68,9 @@ - + + + {7106d2f0-804e-4f73-950c-266ffc096a87} diff --git a/DsmSuite.DsmViewer.Application/Interfaces/ActionType.cs b/DsmSuite.DsmViewer.Application/Interfaces/ActionType.cs index 0d9ccb86..73b24a8e 100644 --- a/DsmSuite.DsmViewer.Application/Interfaces/ActionType.cs +++ b/DsmSuite.DsmViewer.Application/Interfaces/ActionType.cs @@ -1,5 +1,9 @@ namespace DsmSuite.DsmViewer.Application.Interfaces { + /// + /// The enumeration of all available user actions (i.e. IAction implementors). + /// Every enumeration tag should be equal to the name of its implementing class. + /// public enum ActionType { ElementChangeName, diff --git a/DsmSuite.DsmViewer.Application/Queries/DsmQueries.cs b/DsmSuite.DsmViewer.Application/Queries/DsmQueries.cs index 9d21d1a1..93dbeac9 100644 --- a/DsmSuite.DsmViewer.Application/Queries/DsmQueries.cs +++ b/DsmSuite.DsmViewer.Application/Queries/DsmQueries.cs @@ -4,6 +4,12 @@ namespace DsmSuite.DsmViewer.Application.Queries { + /// + /// Contains some but not all queries the application executes on the model + /// + /// TODO Can this class be made more useful? + /// DsmApplicaton does some queries as well and dispatches others here. Can we make this class more useful + /// by forwarding once and dispatching here? public class DsmQueries { private readonly IDsmModel _model; diff --git a/DsmSuite.DsmViewer.Model/Core/DsmActionModel.cs b/DsmSuite.DsmViewer.Model/Core/DsmActionModel.cs index e3fb13b4..e126083a 100644 --- a/DsmSuite.DsmViewer.Model/Core/DsmActionModel.cs +++ b/DsmSuite.DsmViewer.Model/Core/DsmActionModel.cs @@ -4,6 +4,9 @@ namespace DsmSuite.DsmViewer.Model.Core { + /// + /// Manages the actions of a model. Only used by DsmModel, which forwards calls here. + /// public class DsmActionModel : IDsmActionModelFileCallback { private readonly List _actions; diff --git a/DsmSuite.DsmViewer.Model/Core/DsmElementModel.cs b/DsmSuite.DsmViewer.Model/Core/DsmElementModel.cs index b5aeeea5..03f6bab7 100644 --- a/DsmSuite.DsmViewer.Model/Core/DsmElementModel.cs +++ b/DsmSuite.DsmViewer.Model/Core/DsmElementModel.cs @@ -6,6 +6,9 @@ namespace DsmSuite.DsmViewer.Model.Core { + /// + /// Manages the elements of a model. Only used by DsmModel, which forwards calls here. + /// public class DsmElementModel : IDsmElementModelFileCallback { private readonly Dictionary _elementsById; diff --git a/DsmSuite.DsmViewer.Model/Core/DsmRelationModel.cs b/DsmSuite.DsmViewer.Model/Core/DsmRelationModel.cs index c77a510e..bf697e58 100644 --- a/DsmSuite.DsmViewer.Model/Core/DsmRelationModel.cs +++ b/DsmSuite.DsmViewer.Model/Core/DsmRelationModel.cs @@ -6,6 +6,9 @@ namespace DsmSuite.DsmViewer.Model.Core { + /// + /// Manages the relations of a model. Only used by DsmModel, which forwards calls here. + /// public class DsmRelationModel : IDsmRelationModelFileCallback { private readonly Dictionary _relationsById; diff --git a/DsmSuite.DsmViewer.Model/DsmSuite.DsmViewer.Model.csproj b/DsmSuite.DsmViewer.Model/DsmSuite.DsmViewer.Model.csproj index 752de267..62957cd0 100644 --- a/DsmSuite.DsmViewer.Model/DsmSuite.DsmViewer.Model.csproj +++ b/DsmSuite.DsmViewer.Model/DsmSuite.DsmViewer.Model.csproj @@ -61,7 +61,9 @@ DsmSuite.Common.Util - + + +