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

Last change on this file since 156 was 91, checked in by DHERBOMEZ Gérald, 12 years ago

Improvement of the build system to avoid some workarounds

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