1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Private implementation of Baget. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "baget_p.h" |
|
19 |
|
20 /*! |
|
21 \class BagetPrivate |
|
22 \brief Private implementation of Baget. |
|
23 */ |
|
24 |
|
25 /*! |
|
26 Constructs a new BagetPrivate with \a bagetPublic. |
|
27 */ |
|
28 BagetPrivate::BagetPrivate(Baget * const bagetPublic) : |
|
29 m_q(bagetPublic), mState(BagetStateConstructed) |
|
30 { |
|
31 } |
|
32 |
|
33 /*! |
|
34 Destructs the class. |
|
35 */ |
|
36 BagetPrivate::~BagetPrivate() |
|
37 { |
|
38 } |
|
39 |
|
40 /*! |
|
41 Manages Baget's start. |
|
42 */ |
|
43 void BagetPrivate::start() |
|
44 { |
|
45 switch (mState) |
|
46 { |
|
47 case BagetStateConstructed: |
|
48 case BagetStateStopped: |
|
49 break; |
|
50 |
|
51 default: |
|
52 return; |
|
53 } |
|
54 |
|
55 mState = BagetStateRunning; |
|
56 if (!m_q->onStart()) { |
|
57 emit m_q->faulted(); |
|
58 } |
|
59 } |
|
60 |
|
61 /*! |
|
62 Manages Baget's stop. |
|
63 */ |
|
64 void BagetPrivate::stop() |
|
65 { |
|
66 switch (mState) |
|
67 { |
|
68 case BagetStateRunning: |
|
69 case BagetStateSuspended: |
|
70 break; |
|
71 |
|
72 default: |
|
73 return; |
|
74 } |
|
75 |
|
76 mState = BagetStateStopped; |
|
77 if (!m_q->onStop()) { |
|
78 emit m_q->faulted(); |
|
79 } |
|
80 } |
|
81 |
|
82 /*! |
|
83 Manages Baget's resume. |
|
84 */ |
|
85 void BagetPrivate::resume() |
|
86 { |
|
87 switch (mState) |
|
88 { |
|
89 case BagetStateSuspended: |
|
90 break; |
|
91 |
|
92 default: |
|
93 return; |
|
94 } |
|
95 |
|
96 mState = BagetStateRunning; |
|
97 if (!m_q->onResume()) { |
|
98 emit m_q->faulted(); |
|
99 } |
|
100 } |
|
101 |
|
102 /*! |
|
103 Manages Baget's suspend. |
|
104 */ |
|
105 void BagetPrivate::suspend() |
|
106 { |
|
107 switch (mState) |
|
108 { |
|
109 case BagetStateRunning: |
|
110 break; |
|
111 |
|
112 default: |
|
113 return; |
|
114 } |
|
115 |
|
116 mState = BagetStateSuspended; |
|
117 if (!m_q->onSuspend()) { |
|
118 emit m_q->faulted(); |
|
119 } |
|
120 } |
|
121 |
|
122 /*! |
|
123 Returns Baget's current state. |
|
124 \return The current state. |
|
125 */ |
|
126 BagetState BagetPrivate::currentState() |
|
127 { |
|
128 return mState; |
|
129 } |
|