KiCad PCB EDA Suite
ACTION_PLUGINS Class Reference

Class ACTION_PLUGINS Mainly static. More...

#include <action_plugin.h>

Static Public Member Functions

static void register_action (ACTION_PLUGIN *aAction)
 Function register_action An action calls this static method when it wants to register itself into the system actions. More...
 
static bool deregister_object (void *aObject)
 Function deregister_object Anyone calls this method to deregister an object which builds a action, it will lookup on the vector calling GetObject until find, then removed and deleted. More...
 
static ACTION_PLUGINGetAction (const wxString &aName)
 Function GetAction. More...
 
static void SetActionMenu (int aIndex, int idMenu)
 Function SetActionMenu Associate a menu id to an action plugin. More...
 
static int GetActionMenu (int aIndex)
 Function GetActionMenu Provide menu id for a plugin index. More...
 
static ACTION_PLUGINGetActionByMenu (int aMenu)
 Function GetActionByMenu find action plugin associated to a menu id. More...
 
static ACTION_PLUGINGetAction (int aIndex)
 Function GetAction. More...
 
static int GetActionsCount ()
 Function GetActionsCount. More...
 
static bool IsActionRunning ()
 Function IsActionRunning. More...
 
static void SetActionRunning (bool aRunning)
 Function SetActionRunning. More...
 

Static Private Attributes

static std::vector< ACTION_PLUGIN * > m_actionsList
 ACTION_PLUGIN system wide static list. More...
 
static bool m_actionRunning = false
 

Detailed Description

Class ACTION_PLUGINS Mainly static.

Storing all plugins informations.

Definition at line 97 of file action_plugin.h.

Member Function Documentation

bool ACTION_PLUGINS::deregister_object ( void *  aObject)
static

Function deregister_object Anyone calls this method to deregister an object which builds a action, it will lookup on the vector calling GetObject until find, then removed and deleted.

Parameters
aObjectis the action plugin object to be deregistered

Definition at line 134 of file action_plugin.cpp.

References ACTION_PLUGIN::GetObject(), i, and max.

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

135 {
136  int max = GetActionsCount();
137 
138  for( int i = 0; i<max; i++ )
139  {
140  ACTION_PLUGIN* action = GetAction( i );
141 
142  if( action->GetObject() == aObject )
143  {
144  m_actionsList.erase( m_actionsList.begin() + i );
145  //m_actionsListMenu.erase( m_actionsListMenu.begin() + i );
146  delete action;
147  return true;
148  }
149  }
150 
151  return false;
152 }
Class ACTION_PLUGIN This is the parent class from where any action plugin class must derive...
Definition: action_plugin.h:40
static int GetActionsCount()
Function GetActionsCount.
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
static ACTION_PLUGIN * GetAction(const wxString &aName)
Function GetAction.
#define max(a, b)
Definition: auxiliary.h:86
size_t i
Definition: json11.cpp:597
virtual void * GetObject()=0
Function GetObject This method gets the pointer to the object from where this action constructs...
ACTION_PLUGIN * ACTION_PLUGINS::GetAction ( const wxString &  aName)
static

Function GetAction.

Parameters
aNameis the action plugin name
Returns
a action object by it's name or NULL if it isn't available.

Definition at line 82 of file action_plugin.cpp.

References ACTION_PLUGIN::GetName(), i, max, and name.

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

83 {
84  int max = GetActionsCount();
85 
86  for( int i = 0; i<max; i++ )
87  {
88  ACTION_PLUGIN* action = GetAction( i );
89 
90  wxString name = action->GetName();
91 
92  if( name.Cmp( aName )==0 )
93  return action;
94  }
95 
96  return NULL;
97 }
virtual wxString GetName()=0
Function GetName.
Class ACTION_PLUGIN This is the parent class from where any action plugin class must derive...
Definition: action_plugin.h:40
static int GetActionsCount()
Function GetActionsCount.
static ACTION_PLUGIN * GetAction(const wxString &aName)
Function GetAction.
const char * name
Definition: DXF_plotter.cpp:61
#define max(a, b)
Definition: auxiliary.h:86
size_t i
Definition: json11.cpp:597
ACTION_PLUGIN * ACTION_PLUGINS::GetAction ( int  aIndex)
static

Function GetAction.

Returns
a action object by it's number or NULL if it isn't available.
Parameters
aIndexis the action index in list

Definition at line 50 of file action_plugin.cpp.

51 {
52  return m_actionsList[aIndex];
53 }
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
ACTION_PLUGIN * ACTION_PLUGINS::GetActionByMenu ( int  aMenu)
static

Function GetActionByMenu find action plugin associated to a menu id.

Parameters
aMenuis the menu id (defined with SetActionMenu)
Returns
the associated ACTION_PLUGIN (or null if not found)

Definition at line 56 of file action_plugin.cpp.

References i, ACTION_PLUGIN::m_actionMenuId, and max.

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

57 {
58  int max = GetActionsCount();
59 
60  for( int i = 0; i < max; i++ )
61  {
62  if( m_actionsList[i]->m_actionMenuId == aMenu )
63  return m_actionsList[i];
64  }
65 
66  return NULL;
67 }
static int GetActionsCount()
Function GetActionsCount.
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
#define max(a, b)
Definition: auxiliary.h:86
size_t i
Definition: json11.cpp:597
int ACTION_PLUGINS::GetActionMenu ( int  aIndex)
static

Function GetActionMenu Provide menu id for a plugin index.

Parameters
aIndexis the action index
Returns
associated menuitem id

Definition at line 76 of file action_plugin.cpp.

77 {
78  return m_actionsList[aIndex]->m_actionMenuId;
79 }
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
int ACTION_PLUGINS::GetActionsCount ( )
static

Function GetActionsCount.

Returns
the number of actions available into the system

Definition at line 100 of file action_plugin.cpp.

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

101 {
102  return m_actionsList.size();
103 }
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
bool ACTION_PLUGINS::IsActionRunning ( )
static

Function IsActionRunning.

Returns
Is an action running right now

Definition at line 155 of file action_plugin.cpp.

References m_actionRunning.

Referenced by IsActionRunning().

156 {
158 }
static bool m_actionRunning
void ACTION_PLUGINS::register_action ( ACTION_PLUGIN aAction)
static

Function register_action An action calls this static method when it wants to register itself into the system actions.

Parameters
aActionis the action plugin to be registered

Definition at line 106 of file action_plugin.cpp.

References ACTION_PLUGIN::GetName().

Referenced by ACTION_PLUGIN::register_action().

107 {
108  // Search for this entry do not register twice this action:
109  for( int ii = 0; ii < GetActionsCount(); ii++ )
110  {
111  if( aAction == GetAction( ii ) ) // Already registered
112  return;
113  }
114 
115  // Search for a action with the same name, and remove it if found
116  for( int ii = 0; ii < GetActionsCount(); ii++ )
117  {
118  ACTION_PLUGIN* action = GetAction( ii );
119 
120  if( action->GetName() == aAction->GetName() )
121  {
122  m_actionsList.erase( m_actionsList.begin() + ii );
123 
124  delete action;
125 
126  break;
127  }
128  }
129 
130  m_actionsList.push_back( aAction );
131 }
virtual wxString GetName()=0
Function GetName.
Class ACTION_PLUGIN This is the parent class from where any action plugin class must derive...
Definition: action_plugin.h:40
static int GetActionsCount()
Function GetActionsCount.
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
static ACTION_PLUGIN * GetAction(const wxString &aName)
Function GetAction.
void ACTION_PLUGINS::SetActionMenu ( int  aIndex,
int  idMenu 
)
static

Function SetActionMenu Associate a menu id to an action plugin.

Parameters
aIndexis the action index
idMenuis the associated menuitem id

Definition at line 70 of file action_plugin.cpp.

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

71 {
72  m_actionsList[aIndex]->m_actionMenuId = idMenu;
73 }
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
void ACTION_PLUGINS::SetActionRunning ( bool  aRunning)
static

Function SetActionRunning.

Parameters
aRunningsets whether an action is running now.

Definition at line 161 of file action_plugin.cpp.

References m_actionRunning.

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

162 {
164 }
static bool m_actionRunning

Member Data Documentation

bool ACTION_PLUGINS::m_actionRunning = false
staticprivate
std::vector< ACTION_PLUGIN * > ACTION_PLUGINS::m_actionsList
staticprivate

ACTION_PLUGIN system wide static list.

Definition at line 103 of file action_plugin.h.

Referenced by ACTION_PLUGIN::register_action().


The documentation for this class was generated from the following files: