KiCad PCB EDA Suite
class_action_plugin.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2017 KiCad Developers, see CHANGELOG.TXT for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 
30 #ifndef CLASS_ACTION_PLUGIN_H
31 #define CLASS_ACTION_PLUGIN_H
32 #include <vector>
33 #include <wxPcbStruct.h>
34 
41 {
42 public:
43  // association between the plugin and its menu id
44  // m_actionMenuId set to 0 means the corresponding menuitem to call this
45  // action is not yet created
47 
48 public:
49  ACTION_PLUGIN() : m_actionMenuId( 0 ) {}
50  virtual ~ACTION_PLUGIN();
51 
56  virtual wxString GetCategoryName() = 0;
57 
63  virtual wxString GetName() = 0;
64 
69  virtual wxString GetDescription() = 0;
70 
76  virtual void* GetObject() = 0;
77 
82  virtual void Run() = 0;
83 
89  void register_action();
90 };
91 
92 
98 {
99 private:
103  static std::vector<ACTION_PLUGIN*> m_actionsList;
104 
105 public:
113  static void register_action( ACTION_PLUGIN* aAction );
114 
123  static bool deregister_object( void* aObject );
124 
130  static ACTION_PLUGIN* GetAction( wxString aName );
131 
138  static void SetActionMenu( int aIndex, int idMenu );
139 
140 
147  static int GetActionMenu( int aIndex );
148 
149 
156  static ACTION_PLUGIN* GetActionByMenu( int aMenu );
157 
158 
164  static ACTION_PLUGIN* GetAction( int aIndex );
165 
170  static int GetActionsCount();
171 };
172 
173 #endif /* PCBNEW_ACTION_PLUGINS_H */
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.
Class ACTION_PLUGINS Mainly static.
virtual wxString GetDescription()=0
Function GetDescription.
static int GetActionMenu(int aIndex)
Function GetActionMenu Provide menu id for a plugin index.
void register_action()
Function register_action It's the standard method of a "ACTION_PLUGIN" to register itself into the AC...
virtual void Run()=0
Function Run This method the the action.
static ACTION_PLUGIN * GetActionByMenu(int aMenu)
Function GetActionByMenu find action plugin associated to a menu id.
static int GetActionsCount()
Function GetActionsCount.
static void register_action(ACTION_PLUGIN *aAction)
Function register_action An action calls this static method when it wants to register itself into the...
static std::vector< ACTION_PLUGIN * > m_actionsList
ACTION_PLUGIN system wide static list.
virtual wxString GetCategoryName()=0
Function GetCategoryName.
static void SetActionMenu(int aIndex, int idMenu)
Function SetActionMenu Associate a menu id to an action plugin.
static bool deregister_object(void *aObject)
Function deregister_object Anyone calls this method to deregister an object which builds a action...
virtual void * GetObject()=0
Function GetObject This method gets the pointer to the object from where this action constructs...