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