KiCad PCB EDA Suite
ACTION_PLUGINS Class Reference

Class ACTION_PLUGINS Mainly static. More...

#include <class_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 (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 Private Attributes

static std::vector< ACTION_PLUGIN * > m_actionsList
 ACTION_PLUGIN system wide static list. More...
 

Detailed Description

Class ACTION_PLUGINS Mainly static.

Storing all plugins informations.

Definition at line 97 of file class_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 131 of file class_action_plugin.cpp.

References GetAction(), GetActionsCount(), ACTION_PLUGIN::GetObject(), m_actionsList, and max.

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

132 {
133  int max = GetActionsCount();
134 
135  for( int i = 0; i<max; i++ )
136  {
137  ACTION_PLUGIN* action = GetAction( i );
138 
139  if( action->GetObject() == aObject )
140  {
141  m_actionsList.erase( m_actionsList.begin() + i );
142  //m_actionsListMenu.erase( m_actionsListMenu.begin() + i );
143  delete action;
144  return true;
145  }
146  }
147 
148  return false;
149 }
Class ACTION_PLUGIN This is the parent class from where any action plugin class must derive...
static ACTION_PLUGIN * GetAction(wxString aName)
Function GetAction.
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
virtual void * GetObject()=0
Function GetObject This method gets the pointer to the object from where this action constructs...
ACTION_PLUGIN * ACTION_PLUGINS::GetAction ( 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 79 of file class_action_plugin.cpp.

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

Referenced by deregister_object(), and register_action().

80 {
81  int max = GetActionsCount();
82 
83  for( int i = 0; i<max; i++ )
84  {
85  ACTION_PLUGIN* action = GetAction( i );
86 
87  wxString name = action->GetName();
88 
89  if( name.Cmp( aName )==0 )
90  return action;
91  }
92 
93  return NULL;
94 }
virtual wxString GetName()=0
Function GetName.
Class ACTION_PLUGIN This is the parent class from where any action plugin class must derive...
static ACTION_PLUGIN * GetAction(wxString aName)
Function GetAction.
static int GetActionsCount()
Function GetActionsCount.
#define max(a, b)
Definition: auxiliary.h:86
const char * name
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 47 of file class_action_plugin.cpp.

References m_actionsList.

48 {
49  return m_actionsList[aIndex];
50 }
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 53 of file class_action_plugin.cpp.

References GetActionsCount(), m_actionsList, and max.

54 {
55  int max = GetActionsCount();
56 
57  for( int i = 0; i < max; i++ )
58  {
59  if( m_actionsList[i]->m_actionMenuId == aMenu )
60  return m_actionsList[i];
61  }
62 
63  return NULL;
64 }
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
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 73 of file class_action_plugin.cpp.

References m_actionsList.

74 {
75  return m_actionsList[aIndex]->m_actionMenuId;
76 }
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 97 of file class_action_plugin.cpp.

References m_actionsList.

Referenced by deregister_object(), GetAction(), GetActionByMenu(), and register_action().

98 {
99  return m_actionsList.size();
100 }
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
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 103 of file class_action_plugin.cpp.

References GetAction(), GetActionsCount(), ACTION_PLUGIN::GetName(), and m_actionsList.

Referenced by ACTION_PLUGIN::register_action().

104 {
105  // Search for this entry do not register twice this action:
106  for( int ii = 0; ii < GetActionsCount(); ii++ )
107  {
108  if( aAction == GetAction( ii ) ) // Already registered
109  return;
110  }
111 
112  // Search for a action with the same name, and remove it if found
113  for( int ii = 0; ii < GetActionsCount(); ii++ )
114  {
115  ACTION_PLUGIN* action = GetAction( ii );
116 
117  if( action->GetName() == aAction->GetName() )
118  {
119  m_actionsList.erase( m_actionsList.begin() + ii );
120 
121  delete action;
122 
123  break;
124  }
125  }
126 
127  m_actionsList.push_back( aAction );
128 }
virtual wxString GetName()=0
Function GetName.
Class ACTION_PLUGIN This is the parent class from where any action plugin class must derive...
static ACTION_PLUGIN * GetAction(wxString aName)
Function GetAction.
static int GetActionsCount()
Function GetActionsCount.
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
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 67 of file class_action_plugin.cpp.

References m_actionsList.

68 {
69  m_actionsList[aIndex]->m_actionMenuId = idMenu;
70 }
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.

Member Data Documentation

std::vector< ACTION_PLUGIN * > ACTION_PLUGINS::m_actionsList
staticprivate

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