KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pluginldr.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) 2015-2016 Cirilo Bernardo <[email protected]>
5 * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
31#ifndef PLUGINLDR_H
32#define PLUGINLDR_H
33
34#include <string>
35#include <wx/dynlib.h>
36#include <wx/string.h>
37
38// Mask for plugin loader tracing.
39extern const wxChar* const tracePluginLoader;
40
41#define MASK_PLUGINLDR wxT( "PLUGIN_LOADER" )
42
43
44// helper function to link functions in the plugin
45#define LINK_ITEM( funcPtr, funcType, funcName ) \
46 funcPtr = (funcType) m_PluginLoader.GetSymbol( wxT( funcName ) )
47
48// typedefs of the functions exported by the 3D Plugin Class
49typedef char const* (*GET_PLUGIN_CLASS) ( void );
50
51typedef void (*GET_CLASS_VERSION) ( unsigned char*, unsigned char*,
52 unsigned char*, unsigned char* );
53
54typedef bool (*CHECK_CLASS_VERSION) ( unsigned char, unsigned char,
55 unsigned char, unsigned char );
56
57typedef const char* (*GET_PLUGIN_NAME) ( void );
58
59typedef void (*GET_VERSION) ( unsigned char*, unsigned char*,
60 unsigned char*, unsigned char* );
61
62
64{
65public:
67 virtual ~KICAD_PLUGIN_LDR();
68
72 virtual void GetLoaderVersion( unsigned char* Major, unsigned char* Minor,
73 unsigned char* Patch, unsigned char* Revision ) const = 0;
74
82 virtual bool Open( const wxString& aFullFileName ) = 0;
83
87 virtual void Close( void ) = 0;
88
92 std::string GetLastError( void ) const;
93
94 // Return the Plugin Class or NULL if no plugin loaded.
95 char const* GetKicadPluginClass( void );
96
97 // Return false if no plugin loaded.
98 bool GetClassVersion( unsigned char* Major, unsigned char* Minor,
99 unsigned char* Patch, unsigned char* Revision );
100
101 // Return false if the class version check fails or no plugin is loaded.
102 bool CheckClassVersion( unsigned char Major, unsigned char Minor,
103 unsigned char Patch, unsigned char Revision );
104
105 // Return the Plugin Name or NULL if no plugin loaded.
106 const char* GetKicadPluginName( void );
107
108 // Return false if no plugin is loaded.
109 bool GetVersion( unsigned char* Major, unsigned char* Minor,
110 unsigned char* Patch, unsigned char* Revision );
111
112 void GetPluginInfo( std::string& aPluginInfo );
113
114protected:
120 bool open( const wxString& aFullFileName, const char* aPluginClass );
121
125 void close( void );
126
132 bool reopen( void );
133
134 std::string m_error; // error message
135
136 // the plugin loader
137 wxDynamicLibrary m_PluginLoader;
138
139private:
140 bool ok; // set TRUE if all functions are linked
146 wxString m_fileName; // name of last opened Plugin
147 std::string m_pluginInfo; // Name:Version tag for plugin
148};
149
150#endif // PLUGINLDR_H
virtual void GetLoaderVersion(unsigned char *Major, unsigned char *Minor, unsigned char *Patch, unsigned char *Revision) const =0
Return the version information of the Plugin Loader for plugin compatibility checking.
CHECK_CLASS_VERSION m_checkClassVersion
Definition: pluginldr.h:143
std::string GetLastError(void) const
Return the value of the internal error string.
Definition: pluginldr.cpp:288
char const * GetKicadPluginClass(void)
Definition: pluginldr.cpp:294
GET_PLUGIN_CLASS m_getPluginClass
Definition: pluginldr.h:141
GET_CLASS_VERSION m_getClassVersion
Definition: pluginldr.h:142
GET_VERSION m_getVersion
Definition: pluginldr.h:145
std::string m_pluginInfo
Definition: pluginldr.h:147
virtual void Close(void)=0
Clean up and closes/unloads the plugin.
virtual bool Open(const wxString &aFullFileName)=0
Open a plugin of the given class, performs version compatibility checks, and links all required funct...
bool CheckClassVersion(unsigned char Major, unsigned char Minor, unsigned char Patch, unsigned char Revision)
Definition: pluginldr.cpp:380
GET_PLUGIN_NAME m_getPluginName
Definition: pluginldr.h:144
void GetPluginInfo(std::string &aPluginInfo)
Definition: pluginldr.cpp:465
bool open(const wxString &aFullFileName, const char *aPluginClass)
Open a plugin of the specified class and links the extensions required by kicad_plugin.
Definition: pluginldr.cpp:63
bool GetClassVersion(unsigned char *Major, unsigned char *Minor, unsigned char *Patch, unsigned char *Revision)
Definition: pluginldr.cpp:321
wxDynamicLibrary m_PluginLoader
Definition: pluginldr.h:137
bool GetVersion(unsigned char *Major, unsigned char *Minor, unsigned char *Patch, unsigned char *Revision)
Definition: pluginldr.cpp:435
const char * GetKicadPluginName(void)
Definition: pluginldr.cpp:408
std::string m_error
Definition: pluginldr.h:134
virtual ~KICAD_PLUGIN_LDR()
Definition: pluginldr.cpp:56
void close(void)
Nullify internal pointers in preparation for closing the plugin.
Definition: pluginldr.cpp:261
wxString m_fileName
Definition: pluginldr.h:146
bool reopen(void)
Reopen a plugin.
Definition: pluginldr.cpp:275
const wxChar *const tracePluginLoader
Flag to enable plugin loader trace output.
Definition: pluginldr.cpp:40
void(* GET_VERSION)(unsigned char *, unsigned char *, unsigned char *, unsigned char *)
Definition: pluginldr.h:59
void(* GET_CLASS_VERSION)(unsigned char *, unsigned char *, unsigned char *, unsigned char *)
Definition: pluginldr.h:51
bool(* CHECK_CLASS_VERSION)(unsigned char, unsigned char, unsigned char, unsigned char)
Definition: pluginldr.h:54
char const *(* GET_PLUGIN_CLASS)(void)
Definition: pluginldr.h:49
const char *(* GET_PLUGIN_NAME)(void)
Definition: pluginldr.h:57