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