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

Last change on this file since 3 was 3, checked in by sgosseli, 12 years ago
  • Add the existing Pacpus files from pacpusdev and pacpuscore.
  • Provide a clean build system based on multiple CMake files.
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 "DbitePlayer/DbtPlyEngineStateChart.h"
12
13#include "kernel/Log.h"
14
15#include "DbitePlayer/DbtPlyEngine.h"
16
17namespace pacpus {
18
19DECLARE_STATIC_LOGGER("pacpus.core.DbtPlyEngineStateChart");
20
21typedef float SpeedType;
22static const SpeedType kMinSpeed = 1.0 / 32;
23static const SpeedType kMaxSpeed = 32;
24
25////////////////////////////////////////////////////////////////////////////////
26DbtPlyEngineState::DbtPlyEngineState()
27{
28}
29
30DbtPlyEngineState::~DbtPlyEngineState()
31{
32}
33
34void DbtPlyEngineState::play(DbtPlyEngine & /*engine*/)
35{
36 // do nothing
37}
38
39void DbtPlyEngineState::pause(DbtPlyEngine & /*engine*/)
40{
41 // do nothing
42}
43
44void DbtPlyEngineState::stop(DbtPlyEngine & /*engine*/)
45{
46 // do nothing
47}
48
49void DbtPlyEngineState::speedUp(DbtPlyEngine & engine)
50{
51 engine.speedUp();
52}
53
54void DbtPlyEngineState::speedDown(DbtPlyEngine & engine)
55{
56 engine.speedDown();
57}
58
59bool DbtPlyEngineState::isPlaying()
60{
61 return false;
62}
63
64////////////////////////////////////////////////////////////////////////////////
65PlayingState::PlayingState()
66{
67}
68
69void PlayingState::pause(DbtPlyEngine & engine)
70{
71 engine.setState(PausedState::getInstance());
72}
73
74void PlayingState::stop(DbtPlyEngine & engine)
75{
76 engine.reset();
77 engine.setState(StoppedState::getInstance());
78}
79
80bool PlayingState::isPlaying()
81{
82 return true;
83}
84
85QString PlayingState::toString() const
86{
87 return "Playing";
88}
89
90DbtPlyEngineState * PlayingState::getInstance()
91{
92 return &mInstance;
93}
94
95PlayingState PlayingState::mInstance;
96
97////////////////////////////////////////////////////////////////////////////////
98PausedState::PausedState()
99{
100}
101
102void PausedState::play(DbtPlyEngine & engine)
103{
104 engine.setLastTNow(road_time());
105 engine.setState(PlayingState::getInstance());
106}
107
108void PausedState::stop(DbtPlyEngine & engine)
109{
110 engine.reset();
111 engine.setState(StoppedState::getInstance());
112}
113
114QString PausedState::toString() const
115{
116 return "Paused";
117}
118
119DbtPlyEngineState * PausedState::getInstance()
120{
121 return &mInstance;
122}
123
124PausedState PausedState::mInstance;
125
126////////////////////////////////////////////////////////////////////////////////
127StoppedState::StoppedState()
128{
129}
130
131void StoppedState::play(DbtPlyEngine & engine)
132{
133 engine.setLastTNow(road_time());
134 engine.setState(PlayingState::getInstance());
135}
136
137QString StoppedState::toString() const
138{
139 return "Stopped";
140}
141
142DbtPlyEngineState * StoppedState::getInstance()
143{
144 return &mInstance;
145}
146
147StoppedState StoppedState::mInstance;
148
149} // namespace pacpus
Note: See TracBrowser for help on using the repository browser.