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