source: pacpusframework/trunk/src/DBITEPlayerLib/DbtPlyEngineStateChart.cpp@ 73

Last change on this file since 73 was 73, checked in by Marek Kurdej, 11 years ago

Minor: line-endings.

  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
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
11namespace pacpus {
12
13DECLARE_STATIC_LOGGER("pacpus.core.DbtPlyEngineStateChart");
14
15typedef float SpeedType;
16static const SpeedType kMinSpeed = 1.0 / 32;
17static const SpeedType kMaxSpeed = 32;
18
19////////////////////////////////////////////////////////////////////////////////
20DbtPlyEngineState::DbtPlyEngineState()
21{
22}
23
24DbtPlyEngineState::~DbtPlyEngineState()
25{
26}
27
28void DbtPlyEngineState::play(DbtPlyEngine & /*engine*/)
29{
30 // do nothing
31}
32
33void DbtPlyEngineState::pause(DbtPlyEngine & /*engine*/)
34{
35 // do nothing
36}
37
38void DbtPlyEngineState::stop(DbtPlyEngine & /*engine*/)
39{
40 // do nothing
41}
42
43void DbtPlyEngineState::speedUp(DbtPlyEngine & engine)
44{
45 engine.speedUp();
46}
47
48void DbtPlyEngineState::speedDown(DbtPlyEngine & engine)
49{
50 engine.speedDown();
51}
52
53bool DbtPlyEngineState::isPlaying()
54{
55 return false;
56}
57
58////////////////////////////////////////////////////////////////////////////////
59PlayingState::PlayingState()
60{
61}
62
63void PlayingState::pause(DbtPlyEngine & engine)
64{
65 engine.setState(PausedState::getInstance());
66}
67
68void PlayingState::stop(DbtPlyEngine & engine)
69{
70 engine.reset();
71 engine.setState(StoppedState::getInstance());
72}
73
74bool PlayingState::isPlaying()
75{
76 return true;
77}
78
79QString PlayingState::toString() const
80{
81 return "Playing";
82}
83
84DbtPlyEngineState * PlayingState::getInstance()
85{
86 return &mInstance;
87}
88
89PlayingState PlayingState::mInstance;
90
91////////////////////////////////////////////////////////////////////////////////
92PausedState::PausedState()
93{
94}
95
96void PausedState::play(DbtPlyEngine & engine)
97{
98 engine.setLastTNow(road_time());
99 engine.setState(PlayingState::getInstance());
100}
101
102void PausedState::stop(DbtPlyEngine & engine)
103{
104 engine.reset();
105 engine.setState(StoppedState::getInstance());
106}
107
108QString PausedState::toString() const
109{
110 return "Paused";
111}
112
113DbtPlyEngineState * PausedState::getInstance()
114{
115 return &mInstance;
116}
117
118PausedState PausedState::mInstance;
119
120////////////////////////////////////////////////////////////////////////////////
121StoppedState::StoppedState()
122{
123}
124
125void StoppedState::play(DbtPlyEngine & engine)
126{
127 engine.setLastTNow(road_time());
128 engine.setState(PlayingState::getInstance());
129}
130
131QString StoppedState::toString() const
132{
133 return "Stopped";
134}
135
136DbtPlyEngineState * StoppedState::getInstance()
137{
138 return &mInstance;
139}
140
141StoppedState StoppedState::mInstance;
142
143} // namespace pacpus
Note: See TracBrowser for help on using the repository browser.