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 ACTION_PLUGINGetActionByMenu (int aMenu)
 Function GetActionByMenu find action plugin associated to a menu id. More...
 
static void SetActionButton (ACTION_PLUGIN *aAction, int idButton)
 Function SetActionButton Associate a button id to an action plugin. More...
 
static ACTION_PLUGINGetActionByButton (int aButton)
 Function GetActionByButton find action plugin associated to a button id. More...
 
static ACTION_PLUGINGetActionByPath (const wxString &aPath)
 Function GetActionByPath find action plugin by module path. 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 122 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 176 of file action_plugin.cpp.

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

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

177 {
178  int max = GetActionsCount();
179 
180  for( int i = 0; i<max; i++ )
181  {
182  ACTION_PLUGIN* action = GetAction( i );
183 
184  if( action->GetObject() == aObject )
185  {
186  m_actionsList.erase( m_actionsList.begin() + i );
187  //m_actionsListMenu.erase( m_actionsListMenu.begin() + i );
188  delete action;
189  return true;
190  }
191  }
192 
193  return false;
194 }
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 110 of file action_plugin.cpp.

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

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

111 {
112  int max = GetActionsCount();
113 
114  for( int i = 0; i<max; i++ )
115  {
116  ACTION_PLUGIN* action = GetAction( i );
117 
118  wxString name = action->GetName();
119 
120  if( name.Cmp( aName )==0 )
121  return action;
122  }
123 
124  return NULL;
125 }
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::GetActionByButton ( int  aButton)
static

Function GetActionByButton find action plugin associated to a button id.

Parameters
aButtonis the button id (defined with SetActionButton)
Returns
the associated ACTION_PLUGIN (or null if not found)

Definition at line 76 of file action_plugin.cpp.

References i, ACTION_PLUGIN::m_actionButtonId, and max.

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

77 {
78  int max = GetActionsCount();
79 
80  for( int i = 0; i < max; i++ )
81  {
82  if( m_actionsList[i]->m_actionButtonId == aButton )
83  return m_actionsList[i];
84  }
85 
86  return NULL;
87 }
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
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
ACTION_PLUGIN * ACTION_PLUGINS::GetActionByPath ( const wxString &  aPath)
static

Function GetActionByPath find action plugin by module path.

Parameters
aPaththe path of plugin
Returns
the corresponding ACTION_PLUGIN (or null if not found)

Definition at line 96 of file action_plugin.cpp.

References ACTION_PLUGIN::GetPluginPath(), and i.

97 {
98  for( int i = 0; i < GetActionsCount() ; i++ )
99  {
100  if( m_actionsList[i]->GetPluginPath() == aPath)
101  {
102  return m_actionsList[i];
103  }
104  }
105 
106  return NULL;
107 }
static int GetActionsCount()
Function GetActionsCount.
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
size_t i
Definition: json11.cpp:597
int ACTION_PLUGINS::GetActionsCount ( )
static

Function GetActionsCount.

Returns
the number of actions available into the system

Definition at line 128 of file action_plugin.cpp.

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

129 {
130  return m_actionsList.size();
131 }
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 197 of file action_plugin.cpp.

References m_actionRunning.

Referenced by IsActionRunning().

198 {
200 }
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 134 of file action_plugin.cpp.

References ACTION_PLUGIN::GetIconFileName(), ACTION_PLUGIN::GetName(), and ACTION_PLUGIN::iconBitmap.

Referenced by ACTION_PLUGIN::register_action().

135 {
136  // Search for this entry do not register twice this action:
137  for( int ii = 0; ii < GetActionsCount(); ii++ )
138  {
139  if( aAction == GetAction( ii ) ) // Already registered
140  return;
141  }
142 
143  // Search for a action with the same name, and remove it if found
144  for( int ii = 0; ii < GetActionsCount(); ii++ )
145  {
146  ACTION_PLUGIN* action = GetAction( ii );
147 
148  if( action->GetName() == aAction->GetName() )
149  {
150  m_actionsList.erase( m_actionsList.begin() + ii );
151 
152  delete action;
153 
154  break;
155  }
156  }
157 
158  // Load icon if supplied
159  if (!aAction->GetIconFileName().IsEmpty())
160  {
161  {
162  wxLogNull eat_errors;
163  aAction->iconBitmap.LoadFile( aAction->GetIconFileName() , wxBITMAP_TYPE_PNG );
164  }
165 
166  if ( !aAction->iconBitmap.IsOk() )
167  {
168  wxLogVerbose( "Failed to load icon " + aAction->GetIconFileName() + " for action plugin " );
169  }
170  }
171 
172  m_actionsList.push_back( aAction );
173 }
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
wxBitmap iconBitmap
Definition: action_plugin.h:50
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.
virtual wxString GetIconFileName()=0
Function GetIconFileName.
void ACTION_PLUGINS::SetActionButton ( ACTION_PLUGIN aAction,
int  idButton 
)
static

Function SetActionButton Associate a button id to an action plugin.

Parameters
aActionis the action
idButtonis the associated menuitem id

Definition at line 90 of file action_plugin.cpp.

References ACTION_PLUGIN::m_actionButtonId.

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

91 {
92  aAction->m_actionButtonId = idButton;
93 }
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 203 of file action_plugin.cpp.

References m_actionRunning.

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

204 {
206 }
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 128 of file action_plugin.h.

Referenced by ACTION_PLUGIN::register_action().


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