1 /******************************************************************************************************
2  * (C) 2020 markummitchell@github.com. This file is part of Engauge Digitizer, which is released      *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission.     *
5  ******************************************************************************************************/
6 
7 #ifndef GUIDELINE_VIEW_STATE_CONTEXT_H
8 #define GUIDELINE_VIEW_STATE_CONTEXT_H
9 
10 #include "GuidelineViewState.h"
11 #include "GuidelineViewStateAbstractBase.h"
12 #include <QVector>
13 
14 /// Context class for state machine that tracks the View / Guidelines mode. This is needed to track before
15 /// and after states for generating CmdGuidelineViewState
16 class GuidelineViewStateContext
17 {
18 public:
19   /// Single constructor.
20   GuidelineViewStateContext ();
21   virtual ~GuidelineViewStateContext();
22 
23   /// Handle user or code generated change in  selected guideline view mode
24   void handleStateChange (GuidelineViewState state);
25 
26   /// Request a state transition
27   void requestStateTransition (GuidelineViewState guidelineState);
28 
29   /// Current state for serializing
30   GuidelineViewState state () const;
31 
32 private:
33 
34   /// Transition if requested
35   void transitionIfRequested ();
36 
37   QVector<GuidelineViewStateAbstractBase*> m_states;
38   GuidelineViewState m_currentState;
39   GuidelineViewState m_nextState;
40 };
41 
42 #endif // GUIDELINE_VIEW_STATE_CONTEXT_H
43