Loading...
Searching...
No Matches
BaseScenarioPresenter.hpp
1#pragma once
2
3#include <Scenario/Document/Event/EventPresenter.hpp>
4#include <Scenario/Document/Interval/FullView/FullViewIntervalPresenter.hpp>
5#include <Scenario/Document/Interval/IntervalModel.hpp>
6#include <Scenario/Document/State/StatePresenter.hpp>
7#include <Scenario/Document/TimeSync/TimeSyncPresenter.hpp>
8
9#include <score/tools/std/IndirectContainer.hpp>
10
11template <typename Model_T, typename IntervalPresenter_T>
13{
14public:
15 BaseScenarioPresenter(const Model_T& model)
16 : m_model{model}
17 {
18 }
19
20 virtual ~BaseScenarioPresenter() = default;
21
23 {
24 return {m_intervalPresenter};
25 }
26
28 {
29 return {m_startStatePresenter, m_endStatePresenter};
30 }
31
33 {
34 return {m_startEventPresenter, m_endEventPresenter};
35 }
36
38 {
39 return {m_startNodePresenter, m_endNodePresenter};
40 }
41
42 const Scenario::EventPresenter& event(const Id<Scenario::EventModel>& id) const
43 {
44 if(id == m_model.startEvent().id())
45 return *m_startEventPresenter;
46 else if(id == m_model.endEvent().id())
47 return *m_endEventPresenter;
48 SCORE_ABORT;
49 }
51 timeSync(const Id<Scenario::TimeSyncModel>& id) const
52 {
53 if(id == m_model.startTimeSync().id())
54 return *m_startNodePresenter;
55 else if(id == m_model.endTimeSync().id())
56 return *m_endNodePresenter;
57 SCORE_ABORT;
58 }
59 const IntervalPresenter_T& interval(const Id<Scenario::IntervalModel>& id) const
60 {
61 if(id == m_model.interval().id())
62 return *m_intervalPresenter;
63 SCORE_ABORT;
64 }
65 const Scenario::StatePresenter& state(const Id<Scenario::StateModel>& id) const
66 {
67 if(id == m_model.startState().id())
68 return *m_startStatePresenter;
69 else if(id == m_model.endState().id())
70 return *m_endStatePresenter;
71 SCORE_ABORT;
72 }
73
74 const Scenario::TimeSyncModel& startTimeSync() const
75 {
76 return m_startNodePresenter->model();
77 }
78
79 IntervalPresenter_T* intervalPresenter() const { return m_intervalPresenter; }
80
81protected:
82 const Model_T& m_model;
83
84 IntervalPresenter_T* m_intervalPresenter{};
85 Scenario::StatePresenter* m_startStatePresenter{};
86 Scenario::StatePresenter* m_endStatePresenter{};
87 Scenario::EventPresenter* m_startEventPresenter{};
88 Scenario::EventPresenter* m_endEventPresenter{};
89 Scenario::TimeSyncPresenter* m_startNodePresenter{};
90 Scenario::TimeSyncPresenter* m_endNodePresenter{};
91};
Definition BaseScenarioPresenter.hpp:13
Definition EventPresenter.hpp:24
Definition StatePresenter.hpp:23
Definition TimeSyncModel.hpp:34
Definition TimeSyncPresenter.hpp:29
The id_base_t class.
Definition Identifier.hpp:57
Definition IndirectContainer.hpp:129