Loading...
Searching...
No Matches
ContainersAccessors.hpp
1#pragma once
2#include <Scenario/Document/BaseScenario/BaseScenarioContainer.hpp>
3#include <Scenario/Process/ScenarioModel.hpp>
4
5namespace Scenario
6{
7
8inline static auto& getIntervals(const ProcessModel& target)
9{
10 return target.intervals;
11}
12
13inline static auto& getStates(const ProcessModel& target)
14{
15 return target.states;
16}
17
18inline static auto& getEvents(const ProcessModel& target)
19{
20 return target.events;
21}
22
23inline static auto& getTimeSyncs(const ProcessModel& target)
24{
25 return target.timeSyncs;
26}
27
28inline static auto getIntervals(const BaseScenarioContainer& target)
29{
30 return target.intervals();
31}
32
33inline static auto getStates(const BaseScenarioContainer& target)
34{
35 return target.states();
36}
37
38inline static auto getEvents(const BaseScenarioContainer& target)
39{
40 return target.events();
41}
42
43inline static auto getTimeSyncs(const BaseScenarioContainer& target)
44{
45 return target.timeSyncs();
46}
47
55template <typename T>
57{
58public:
59 std::vector<T*> elements;
60
61 void visit(Scenario::ScenarioInterface& s)
62 {
64 const auto& sc = (s.*type::accessor)();
65 elements.reserve(elements.size() + sc.size());
66 for(auto& e : sc)
67 {
68 elements.push_back(&e);
69 visit(e);
70 }
71 }
72
73 void visit(Scenario::IntervalModel& c)
74 {
75 for(auto& proc : c.processes)
76 {
77 if(auto scenario = dynamic_cast<Scenario::ScenarioInterface*>(&proc))
78 {
79 visit(*scenario);
80 }
81 }
82 }
83};
84}
Definition IntervalModel.hpp:50
score::EntityMap< Process::ProcessModel, true > processes
Definition IntervalModel.hpp:62
Definition ScenarioInterface.hpp:20
Definition ContainersAccessors.hpp:57
Main plug-in of score.
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:13
Definition ScenarioInterface.hpp:55