KiCad PCB EDA Suite
TOOL_MANAGER::TOOL_STATE Struct Reference

Struct describing the current execution state of a TOOL. More...

Public Member Functions

 TOOL_STATE (TOOL_BASE *aTool)
 
 TOOL_STATE (const TOOL_STATE &aState)
 
 ~TOOL_STATE ()
 
TOOL_STATEoperator= (const TOOL_STATE &aState)
 
bool operator== (const TOOL_MANAGER::TOOL_STATE &aRhs) const
 
bool operator!= (const TOOL_MANAGER::TOOL_STATE &aRhs) const
 
void Push ()
 Function Push() Stores the current state of the tool on stack. More...
 
bool Pop ()
 Function Pop() Restores state of the tool from stack. More...
 

Public Attributes

TOOL_BASEtheTool
 The tool itself. More...
 
bool idle
 Is the tool active (pending execution) or disabled at the moment. More...
 
bool shutdown
 Should the tool shutdown during next execution. More...
 
bool pendingWait
 Flag defining if the tool is waiting for any event (i.e. More...
 
bool pendingContextMenu
 Is there a context menu being displayed. More...
 
ACTION_MENUcontextMenu
 Context menu currently used by the tool. More...
 
CONTEXT_MENU_TRIGGER contextMenuTrigger
 Defines when the context menu is opened. More...
 
COROUTINE< int, const TOOL_EVENT & > * cofunc
 Tool execution context. More...
 
TOOL_EVENT wakeupEvent
 The event that triggered the execution/wakeup of the tool after Wait() call. More...
 
TOOL_EVENT_LIST waitEvents
 List of events the tool is currently waiting for. More...
 
std::vector< TRANSITIONtransitions
 List of possible transitions (ie. More...
 
KIGFX::VC_SETTINGS vcSettings
 VIEW_CONTROLS settings to preserve settings when the tools are switched. More...
 

Private Member Functions

void clear ()
 

Restores the initial state.

More...
 

Private Attributes

std::stack< std::unique_ptr< TOOL_STATE > > stateStack
 

Stack preserving previous states of a TOOL.

More...
 

Detailed Description

Struct describing the current execution state of a TOOL.

Definition at line 48 of file tool_manager.cpp.

Constructor & Destructor Documentation

◆ TOOL_STATE() [1/2]

TOOL_MANAGER::TOOL_STATE::TOOL_STATE ( TOOL_BASE aTool)
inline

Definition at line 50 of file tool_manager.cpp.

50  :
51  theTool( aTool )
52  {
53  clear();
54  }
TOOL_BASE * theTool
The tool itself.
void clear()
Restores the initial state.

References clear().

◆ TOOL_STATE() [2/2]

TOOL_MANAGER::TOOL_STATE::TOOL_STATE ( const TOOL_STATE aState)
inline

Definition at line 56 of file tool_manager.cpp.

57  {
58  theTool = aState.theTool;
59  idle = aState.idle;
60  shutdown = aState.shutdown;
61  pendingWait = aState.pendingWait;
62  pendingContextMenu = aState.pendingContextMenu;
63  contextMenu = aState.contextMenu;
64  contextMenuTrigger = aState.contextMenuTrigger;
65  cofunc = aState.cofunc;
66  wakeupEvent = aState.wakeupEvent;
67  waitEvents = aState.waitEvents;
68  transitions = aState.transitions;
69  vcSettings = aState.vcSettings;
70  // do not copy stateStack
71  }
TOOL_BASE * theTool
The tool itself.
std::vector< TRANSITION > transitions
List of possible transitions (ie.
KIGFX::VC_SETTINGS vcSettings
VIEW_CONTROLS settings to preserve settings when the tools are switched.
ACTION_MENU * contextMenu
Context menu currently used by the tool.
bool pendingWait
Flag defining if the tool is waiting for any event (i.e.
bool pendingContextMenu
Is there a context menu being displayed.
bool idle
Is the tool active (pending execution) or disabled at the moment.
TOOL_EVENT wakeupEvent
The event that triggered the execution/wakeup of the tool after Wait() call.
COROUTINE< int, const TOOL_EVENT & > * cofunc
Tool execution context.
CONTEXT_MENU_TRIGGER contextMenuTrigger
Defines when the context menu is opened.
bool shutdown
Should the tool shutdown during next execution.
TOOL_EVENT_LIST waitEvents
List of events the tool is currently waiting for.

References cofunc, contextMenu, contextMenuTrigger, idle, pendingContextMenu, pendingWait, shutdown, theTool, transitions, vcSettings, waitEvents, and wakeupEvent.

◆ ~TOOL_STATE()

TOOL_MANAGER::TOOL_STATE::~TOOL_STATE ( )
inline

Definition at line 73 of file tool_manager.cpp.

74  {
75  if( !stateStack.empty() )
76  wxFAIL;
77  }
std::stack< std::unique_ptr< TOOL_STATE > > stateStack
Stack preserving previous states of a TOOL.

References stateStack.

Member Function Documentation

◆ clear()

void TOOL_MANAGER::TOOL_STATE::clear ( )
inlineprivate

Restores the initial state.

Definition at line 185 of file tool_manager.cpp.

186  {
187  idle = true;
188  shutdown = false;
189  pendingWait = false;
190  pendingContextMenu = false;
191  cofunc = NULL;
192  contextMenu = NULL;
194  vcSettings.Reset();
195  transitions.clear();
196  }
void Reset()
Restores the default settings
std::vector< TRANSITION > transitions
List of possible transitions (ie.
KIGFX::VC_SETTINGS vcSettings
VIEW_CONTROLS settings to preserve settings when the tools are switched.
ACTION_MENU * contextMenu
Context menu currently used by the tool.
bool pendingWait
Flag defining if the tool is waiting for any event (i.e.
bool pendingContextMenu
Is there a context menu being displayed.
#define NULL
bool idle
Is the tool active (pending execution) or disabled at the moment.
COROUTINE< int, const TOOL_EVENT & > * cofunc
Tool execution context.
CONTEXT_MENU_TRIGGER contextMenuTrigger
Defines when the context menu is opened.
bool shutdown
Should the tool shutdown during next execution.

References CMENU_OFF, cofunc, contextMenu, contextMenuTrigger, idle, NULL, pendingContextMenu, pendingWait, KIGFX::VC_SETTINGS::Reset(), shutdown, transitions, and vcSettings.

Referenced by Push(), and TOOL_STATE().

◆ operator!=()

bool TOOL_MANAGER::TOOL_STATE::operator!= ( const TOOL_MANAGER::TOOL_STATE aRhs) const
inline

Definition at line 140 of file tool_manager.cpp.

141  {
142  return aRhs.theTool != this->theTool;
143  }
TOOL_BASE * theTool
The tool itself.

References theTool.

◆ operator=()

TOOL_STATE& TOOL_MANAGER::TOOL_STATE::operator= ( const TOOL_STATE aState)
inline

Definition at line 117 of file tool_manager.cpp.

118  {
119  theTool = aState.theTool;
120  idle = aState.idle;
121  shutdown = aState.shutdown;
122  pendingWait = aState.pendingWait;
123  pendingContextMenu = aState.pendingContextMenu;
124  contextMenu = aState.contextMenu;
125  contextMenuTrigger = aState.contextMenuTrigger;
126  cofunc = aState.cofunc;
127  wakeupEvent = aState.wakeupEvent;
128  waitEvents = aState.waitEvents;
129  transitions = aState.transitions;
130  vcSettings = aState.vcSettings;
131  // do not copy stateStack
132  return *this;
133  }
TOOL_BASE * theTool
The tool itself.
std::vector< TRANSITION > transitions
List of possible transitions (ie.
KIGFX::VC_SETTINGS vcSettings
VIEW_CONTROLS settings to preserve settings when the tools are switched.
ACTION_MENU * contextMenu
Context menu currently used by the tool.
bool pendingWait
Flag defining if the tool is waiting for any event (i.e.
bool pendingContextMenu
Is there a context menu being displayed.
bool idle
Is the tool active (pending execution) or disabled at the moment.
TOOL_EVENT wakeupEvent
The event that triggered the execution/wakeup of the tool after Wait() call.
COROUTINE< int, const TOOL_EVENT & > * cofunc
Tool execution context.
CONTEXT_MENU_TRIGGER contextMenuTrigger
Defines when the context menu is opened.
bool shutdown
Should the tool shutdown during next execution.
TOOL_EVENT_LIST waitEvents
List of events the tool is currently waiting for.

References cofunc, contextMenu, contextMenuTrigger, idle, pendingContextMenu, pendingWait, shutdown, theTool, transitions, vcSettings, waitEvents, and wakeupEvent.

◆ operator==()

bool TOOL_MANAGER::TOOL_STATE::operator== ( const TOOL_MANAGER::TOOL_STATE aRhs) const
inline

Definition at line 135 of file tool_manager.cpp.

136  {
137  return aRhs.theTool == this->theTool;
138  }
TOOL_BASE * theTool
The tool itself.

References theTool.

◆ Pop()

bool TOOL_MANAGER::TOOL_STATE::Pop ( )
inline

Function Pop() Restores state of the tool from stack.

Stacks are stored internally and are not shared between different TOOL_STATE objects.

Returns
True if state was restored, false if the stack was empty.

Definition at line 163 of file tool_manager.cpp.

164  {
165  delete cofunc;
166 
167  if( !stateStack.empty() )
168  {
169  *this = *stateStack.top().get();
170  stateStack.pop();
171  return true;
172  }
173  else
174  {
175  cofunc = NULL;
176  return false;
177  }
178  }
#define NULL
std::stack< std::unique_ptr< TOOL_STATE > > stateStack
Stack preserving previous states of a TOOL.
COROUTINE< int, const TOOL_EVENT & > * cofunc
Tool execution context.

References cofunc, NULL, and stateStack.

Referenced by TOOL_MANAGER::finishTool().

◆ Push()

void TOOL_MANAGER::TOOL_STATE::Push ( )
inline

Function Push() Stores the current state of the tool on stack.

Stacks are stored internally and are not shared between different TOOL_STATE objects.

Definition at line 150 of file tool_manager.cpp.

151  {
152  auto state = std::make_unique<TOOL_STATE>( *this );
153  stateStack.push( std::move( state ) );
154  clear();
155  }
std::stack< std::unique_ptr< TOOL_STATE > > stateStack
Stack preserving previous states of a TOOL.
void clear()
Restores the initial state.

References clear(), and stateStack.

Referenced by TOOL_MANAGER::dispatchInternal().

Member Data Documentation

◆ cofunc

COROUTINE<int, const TOOL_EVENT&>* TOOL_MANAGER::TOOL_STATE::cofunc

◆ contextMenu

ACTION_MENU* TOOL_MANAGER::TOOL_STATE::contextMenu

Context menu currently used by the tool.

Definition at line 96 of file tool_manager.cpp.

Referenced by clear(), TOOL_MANAGER::DispatchContextMenu(), operator=(), TOOL_MANAGER::ScheduleContextMenu(), and TOOL_STATE().

◆ contextMenuTrigger

CONTEXT_MENU_TRIGGER TOOL_MANAGER::TOOL_STATE::contextMenuTrigger

Defines when the context menu is opened.

Definition at line 99 of file tool_manager.cpp.

Referenced by clear(), TOOL_MANAGER::DispatchContextMenu(), operator=(), TOOL_MANAGER::ScheduleContextMenu(), and TOOL_STATE().

◆ idle

bool TOOL_MANAGER::TOOL_STATE::idle

Is the tool active (pending execution) or disabled at the moment.

Definition at line 83 of file tool_manager.cpp.

Referenced by clear(), TOOL_MANAGER::dispatchInternal(), TOOL_MANAGER::finishTool(), operator=(), and TOOL_STATE().

◆ pendingContextMenu

bool TOOL_MANAGER::TOOL_STATE::pendingContextMenu

Is there a context menu being displayed.

Definition at line 93 of file tool_manager.cpp.

Referenced by clear(), operator=(), and TOOL_STATE().

◆ pendingWait

bool TOOL_MANAGER::TOOL_STATE::pendingWait

Flag defining if the tool is waiting for any event (i.e.

if it issued a Wait() call).

Definition at line 90 of file tool_manager.cpp.

Referenced by clear(), TOOL_MANAGER::DispatchContextMenu(), TOOL_MANAGER::dispatchInternal(), operator=(), TOOL_MANAGER::ScheduleWait(), and TOOL_STATE().

◆ shutdown

bool TOOL_MANAGER::TOOL_STATE::shutdown

Should the tool shutdown during next execution.

Definition at line 86 of file tool_manager.cpp.

Referenced by clear(), operator=(), TOOL_MANAGER::ScheduleWait(), and TOOL_STATE().

◆ stateStack

std::stack<std::unique_ptr<TOOL_STATE> > TOOL_MANAGER::TOOL_STATE::stateStack
private

Stack preserving previous states of a TOOL.

Definition at line 182 of file tool_manager.cpp.

Referenced by Pop(), Push(), and ~TOOL_STATE().

◆ theTool

TOOL_BASE* TOOL_MANAGER::TOOL_STATE::theTool

◆ transitions

std::vector<TRANSITION> TOOL_MANAGER::TOOL_STATE::transitions

List of possible transitions (ie.

association of events and state handlers that are executed upon the event reception

Definition at line 112 of file tool_manager.cpp.

Referenced by clear(), TOOL_MANAGER::dispatchInternal(), operator=(), TOOL_MANAGER::ScheduleNextState(), and TOOL_STATE().

◆ vcSettings

KIGFX::VC_SETTINGS TOOL_MANAGER::TOOL_STATE::vcSettings

VIEW_CONTROLS settings to preserve settings when the tools are switched.

Definition at line 115 of file tool_manager.cpp.

Referenced by TOOL_MANAGER::applyViewControls(), clear(), TOOL_MANAGER::DispatchContextMenu(), TOOL_MANAGER::dispatchInternal(), operator=(), TOOL_MANAGER::saveViewControls(), and TOOL_STATE().

◆ waitEvents

TOOL_EVENT_LIST TOOL_MANAGER::TOOL_STATE::waitEvents

List of events the tool is currently waiting for.

Definition at line 108 of file tool_manager.cpp.

Referenced by TOOL_MANAGER::DispatchContextMenu(), TOOL_MANAGER::dispatchInternal(), operator=(), TOOL_MANAGER::ScheduleWait(), and TOOL_STATE().

◆ wakeupEvent

TOOL_EVENT TOOL_MANAGER::TOOL_STATE::wakeupEvent

The event that triggered the execution/wakeup of the tool after Wait() call.

Definition at line 105 of file tool_manager.cpp.

Referenced by TOOL_MANAGER::dispatchInternal(), operator=(), TOOL_MANAGER::ScheduleWait(), and TOOL_STATE().


The documentation for this struct was generated from the following file: