ScenarioDocumentModel.hpp
1 #pragma once
2 #include <Process/Dataflow/Cable.hpp>
3 #include <Process/Dataflow/Port.hpp>
4 
5 #include <Scenario/Instantiations.hpp>
6 
7 #include <score/plugins/documentdelegate/DocumentDelegateModel.hpp>
8 #include <score/selection/Selection.hpp>
9 #include <score/serialization/VisitorInterface.hpp>
10 
11 #include <score_plugin_scenario_export.h>
12 
13 #include <verdigris>
14 
15 namespace Process
16 {
17 class LayerPresenter;
18 }
19 class QObject;
20 
21 namespace Scenario
22 {
23 class BaseScenario;
24 class IntervalModel;
25 class FullViewConstraintViewModel;
26 class SCORE_PLUGIN_SCENARIO_EXPORT ScenarioDocumentModel final
28  , public Nano::Observer
29 {
30  W_OBJECT(ScenarioDocumentModel)
31  SCORE_SERIALIZE_FRIENDS
32 public:
33  ScenarioDocumentModel(const score::DocumentContext& ctx, QObject* parent);
34 
35  template <typename Impl>
36  ScenarioDocumentModel(Impl& vis, const score::DocumentContext& ctx, QObject* parent)
37  : score::DocumentDelegateModel{vis, parent}
38  , m_context{ctx}
39  {
40  vis.writeTo(*this);
41  init();
42  }
43 
44  void finishLoading();
45  bool closing() const noexcept { return !m_baseScenario; }
46  ~ScenarioDocumentModel() override;
47 
48  BaseScenario& baseScenario() const { return *m_baseScenario; }
49 
50  IntervalModel& baseInterval() const;
51 
52  void serialize(const VisitorVariant&) const override;
53  void close() override;
54 
56 
57  void addBus(const IntervalModel*);
58  void removeBus(const IntervalModel*);
59  void busDeleted(const IdentifiedObjectAbstract* itv);
60 
61  std::vector<const IntervalModel*> busIntervals;
62  std::vector<const StateModel*> statesWithControls;
63 
64  void busesChanged() E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, busesChanged)
65 
66  const score::DocumentContext& context() const noexcept { return m_context; }
67 
68 private:
69  void init();
70  const score::DocumentContext& m_context;
71  BaseScenario* m_baseScenario{};
72  std::vector<QByteArray> m_savedCables;
73  rapidjson::Document m_savedCablesJson;
74 };
75 }
Base class for IdentifiedObject.
Definition: IdentifiedObjectAbstract.hpp:16
Definition: BaseScenario.hpp:24
Definition: IntervalModel.hpp:50
Definition: ScenarioDocumentModel.hpp:29
Definition: DocumentDelegateModel.hpp:11
Base classes and tools to implement processes and layers.
Definition: JSONVisitor.hpp:1324
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
The VisitorVariant struct.
Definition: VisitorInterface.hpp:26
Definition: DocumentContext.hpp:18