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