source: pacpusframework/branches/0.2.x/src/DBITEPlayerLib/DbtPlyEngineStateChart.cpp

Last change on this file was 89, checked in by morasjul, 11 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

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