1 | // %pacpus:license{
|
---|
2 | // This file is part of the PACPUS framework distributed under the
|
---|
3 | // CECILL-C License, Version 1.0.
|
---|
4 | // %pacpus:license}
|
---|
5 | /// @author Gerald Dherbomez <firstname.surname@utc.fr>
|
---|
6 | /// @version $Id: DbtPlyEngineStateChart.cpp 91 2013-05-19 10:32:48Z gdherbom $
|
---|
7 |
|
---|
8 | #include <Pacpus/DbitePlayer/DbtPlyEngineStateChart.h>
|
---|
9 |
|
---|
10 | #include <Pacpus/DbitePlayer/DbtPlyEngine.h>
|
---|
11 | #include <Pacpus/kernel/Log.h>
|
---|
12 |
|
---|
13 | namespace pacpus {
|
---|
14 |
|
---|
15 | DECLARE_STATIC_LOGGER("pacpus.core.DbtPlyEngineStateChart");
|
---|
16 |
|
---|
17 | typedef float SpeedType;
|
---|
18 | static const SpeedType kMinSpeed = 1.0 / 32;
|
---|
19 | static const SpeedType kMaxSpeed = 32;
|
---|
20 |
|
---|
21 | ////////////////////////////////////////////////////////////////////////////////
|
---|
22 | DbtPlyEngineState::DbtPlyEngineState()
|
---|
23 | {
|
---|
24 | }
|
---|
25 |
|
---|
26 | DbtPlyEngineState::~DbtPlyEngineState()
|
---|
27 | {
|
---|
28 | }
|
---|
29 |
|
---|
30 | void DbtPlyEngineState::play(DbtPlyEngine & /*engine*/)
|
---|
31 | {
|
---|
32 | // do nothing
|
---|
33 | }
|
---|
34 |
|
---|
35 | void DbtPlyEngineState::pause(DbtPlyEngine & /*engine*/)
|
---|
36 | {
|
---|
37 | // do nothing
|
---|
38 | }
|
---|
39 |
|
---|
40 | void DbtPlyEngineState::stop(DbtPlyEngine & /*engine*/)
|
---|
41 | {
|
---|
42 | // do nothing
|
---|
43 | }
|
---|
44 |
|
---|
45 | void DbtPlyEngineState::speedUp(DbtPlyEngine & engine)
|
---|
46 | {
|
---|
47 | engine.speedUp();
|
---|
48 | }
|
---|
49 |
|
---|
50 | void DbtPlyEngineState::speedDown(DbtPlyEngine & engine)
|
---|
51 | {
|
---|
52 | engine.speedDown();
|
---|
53 | }
|
---|
54 |
|
---|
55 | bool DbtPlyEngineState::isPlaying()
|
---|
56 | {
|
---|
57 | return false;
|
---|
58 | }
|
---|
59 |
|
---|
60 | ////////////////////////////////////////////////////////////////////////////////
|
---|
61 | PlayingState::PlayingState()
|
---|
62 | {
|
---|
63 | }
|
---|
64 |
|
---|
65 | void PlayingState::pause(DbtPlyEngine & engine)
|
---|
66 | {
|
---|
67 | engine.setState(PausedState::getInstance());
|
---|
68 | }
|
---|
69 |
|
---|
70 | void PlayingState::stop(DbtPlyEngine & engine)
|
---|
71 | {
|
---|
72 | engine.reset();
|
---|
73 | engine.setState(StoppedState::getInstance());
|
---|
74 | }
|
---|
75 |
|
---|
76 | bool PlayingState::isPlaying()
|
---|
77 | {
|
---|
78 | return true;
|
---|
79 | }
|
---|
80 |
|
---|
81 | QString PlayingState::toString() const
|
---|
82 | {
|
---|
83 | return "Playing";
|
---|
84 | }
|
---|
85 |
|
---|
86 | DbtPlyEngineState * PlayingState::getInstance()
|
---|
87 | {
|
---|
88 | return &mInstance;
|
---|
89 | }
|
---|
90 |
|
---|
91 | PlayingState PlayingState::mInstance;
|
---|
92 |
|
---|
93 | ////////////////////////////////////////////////////////////////////////////////
|
---|
94 | PausedState::PausedState()
|
---|
95 | {
|
---|
96 | }
|
---|
97 |
|
---|
98 | void PausedState::play(DbtPlyEngine & engine)
|
---|
99 | {
|
---|
100 | engine.setLastTNow(road_time());
|
---|
101 | engine.setState(PlayingState::getInstance());
|
---|
102 | }
|
---|
103 |
|
---|
104 | void PausedState::stop(DbtPlyEngine & engine)
|
---|
105 | {
|
---|
106 | engine.reset();
|
---|
107 | engine.setState(StoppedState::getInstance());
|
---|
108 | }
|
---|
109 |
|
---|
110 | QString PausedState::toString() const
|
---|
111 | {
|
---|
112 | return "Paused";
|
---|
113 | }
|
---|
114 |
|
---|
115 | DbtPlyEngineState * PausedState::getInstance()
|
---|
116 | {
|
---|
117 | return &mInstance;
|
---|
118 | }
|
---|
119 |
|
---|
120 | PausedState PausedState::mInstance;
|
---|
121 |
|
---|
122 | ////////////////////////////////////////////////////////////////////////////////
|
---|
123 | StoppedState::StoppedState()
|
---|
124 | {
|
---|
125 | }
|
---|
126 |
|
---|
127 | void StoppedState::play(DbtPlyEngine & engine)
|
---|
128 | {
|
---|
129 | engine.setLastTNow(road_time());
|
---|
130 | engine.setState(PlayingState::getInstance());
|
---|
131 | }
|
---|
132 |
|
---|
133 | QString StoppedState::toString() const
|
---|
134 | {
|
---|
135 | return "Stopped";
|
---|
136 | }
|
---|
137 |
|
---|
138 | DbtPlyEngineState * StoppedState::getInstance()
|
---|
139 | {
|
---|
140 | return &mInstance;
|
---|
141 | }
|
---|
142 |
|
---|
143 | StoppedState StoppedState::mInstance;
|
---|
144 |
|
---|
145 | } // namespace pacpus
|
---|