camerauis/cameraxui/cxengine/inc/cxestatemachinebase.h
changeset 46 c826656d6714
parent 28 3075d9b614e6
equal deleted inserted replaced
42:feebad15db8c 46:c826656d6714
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
       
    17 
    17 #ifndef CXESTATEMACHINEBASE_H
    18 #ifndef CXESTATEMACHINEBASE_H
    18 #define CXESTATEMACHINEBASE_H
    19 #define CXESTATEMACHINEBASE_H
    19 
    20 
    20 #include <QHash>
    21 #include <QHash>
    21 #include <QString>
    22 #include <QString>
    50     /**
    51     /**
    51     * CxeStateMachine constructor.
    52     * CxeStateMachine constructor.
    52     * @sa addState setInitialState
    53     * @sa addState setInitialState
    53     * @param stateMachineName  Name for this state machine (used for debug prints)
    54     * @param stateMachineName  Name for this state machine (used for debug prints)
    54     */
    55     */
    55     CxeStateMachineBase(const char* stateMachineName);
    56     CxeStateMachineBase(const char *stateMachineName);
    56     virtual ~CxeStateMachineBase();
    57     virtual ~CxeStateMachineBase();
    57 
    58 
    58 protected:
    59 protected:
    59     /**
    60     /**
    60      * Add a new state to the machine. Takes ownership of state.
    61      * Add a new state to the machine. Takes ownership of state.
    74      * @param stateId State ID of the new state
    75      * @param stateId State ID of the new state
    75      * @param error   Optional error code to be associated with the transition
    76      * @param error   Optional error code to be associated with the transition
    76      * @return False if state change fails. True if changing is allowed, or the current state is same
    77      * @return False if state change fails. True if changing is allowed, or the current state is same
    77      * as the new state.
    78      * as the new state.
    78      */
    79      */
    79     virtual bool setState(int stateId, int error = 0);
    80     virtual bool setState(int stateId, CxeError::Id error = CxeError::None);
    80 
    81 
    81     /**
    82     /**
    82      * Set the initial state of the state machine. Can be called only once.
    83      * Set the initial state of the state machine. Can be called only once.
    83      * This method will panic, if initial state is unknown, or initial state has already
    84      * This method will panic, if initial state is unknown, or initial state has already
    84      * been set.
    85      * been set.
   114     bool verifyStateChange(int newStateId);
   115     bool verifyStateChange(int newStateId);
   115 
   116 
   116 private:
   117 private:
   117 
   118 
   118     //! Hash table of all states. stateId as key
   119     //! Hash table of all states. stateId as key
   119     QHash<int, CxeState*> mStates;
   120     QHash<int, CxeState *> mStates;
   120 
   121 
   121     //! All states ORed together
   122     //! All states ORed together
   122     int mStateBitsUsed;
   123     int mStateBitsUsed;
   123 
   124 
   124     //! Current state
   125     //! Current state
   128     QString mName;
   129     QString mName;
   129 
   130 
   130 };
   131 };
   131 
   132 
   132 #endif // CXESTATEMACHINEBASE_H
   133 #endif // CXESTATEMACHINEBASE_H
   133 
       
   134