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