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

Last change on this file since 31 was 31, checked in by sgosseli, 11 years ago

Huge commit: use the new includes style in all the files, add the license header in all the headers, and in some cpp.

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