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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
25
26
27#ifndef PLUGINLDR_H
28#define PLUGINLDR_H
29
30#include <string>
31#include <wx/dynlib.h>
32#include <wx/string.h>
33
34// Mask for plugin loader tracing.
35extern const wxChar* const tracePluginLoader;
36
37#define MASK_PLUGINLDR wxT( "PLUGIN_LOADER" )
38
39
40// helper function to link functions in the plugin
41#define LINK_ITEM( funcPtr, funcType, funcName ) \
42 funcPtr = (funcType) m_PluginLoader.GetSymbol( wxT( funcName ) )
43
44// typedefs of the functions exported by the 3D Plugin Class
45typedef char const* (*GET_PLUGIN_CLASS) ( void );
46
47typedef void (*GET_CLASS_VERSION) ( unsigned char*, unsigned char*,
48 unsigned char*, unsigned char* );
49
50typedef bool (*CHECK_CLASS_VERSION) ( unsigned char, unsigned char,
51 unsigned char, unsigned char );
52
53typedef const char* (*GET_PLUGIN_NAME) ( void );
54
55typedef void (*GET_VERSION) ( unsigned char*, unsigned char*,
56 unsigned char*, unsigned char* );
57
58
60{
61public:
63 virtual ~KICAD_PLUGIN_LDR();
64
68 virtual void GetLoaderVersion( unsigned char* Major, unsigned char* Minor,
69 unsigned char* Patch, unsigned char* Revision ) const = 0;
70
78 virtual bool Open( const wxString& aFullFileName ) = 0;
79
83 virtual void Close( void ) = 0;
84
88 std::string GetLastError( void ) const;
89
90 // Return the Plugin Class or NULL if no plugin loaded.
91 char const* GetKicadPluginClass( void );
92
93 // Return false if no plugin loaded.
94 bool GetClassVersion( unsigned char* Major, unsigned char* Minor,
95 unsigned char* Patch, unsigned char* Revision );
96
97 // Return false if the class version check fails or no plugin is loaded.
98 bool CheckClassVersion( unsigned char Major, unsigned char Minor,
99 unsigned char Patch, unsigned char Revision );
100
101 // Return the Plugin Name or NULL if no plugin loaded.
102 const char* GetKicadPluginName( void );
103
104 // Return false if no plugin is loaded.
105 bool GetVersion( unsigned char* Major, unsigned char* Minor,
106 unsigned char* Patch, unsigned char* Revision );
107
108 void GetPluginInfo( std::string& aPluginInfo );
109
110protected:
116 bool open( const wxString& aFullFileName, const char* aPluginClass );
117
121 void close( void );
122
128 bool reopen( void );
129
130 std::string m_error; // error message
131
132 // the plugin loader
133 wxDynamicLibrary m_PluginLoader;
134
135private:
136 bool ok; // set TRUE if all functions are linked
142 wxString m_fileName; // name of last opened Plugin
143 std::string m_pluginInfo; // Name:Version tag for plugin
144};
145
146#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:139
std::string GetLastError(void) const
Return the value of the internal error string.
char const * GetKicadPluginClass(void)
GET_PLUGIN_CLASS m_getPluginClass
Definition pluginldr.h:137
GET_CLASS_VERSION m_getClassVersion
Definition pluginldr.h:138
GET_VERSION m_getVersion
Definition pluginldr.h:141
std::string m_pluginInfo
Definition pluginldr.h:143
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)
GET_PLUGIN_NAME m_getPluginName
Definition pluginldr.h:140
void GetPluginInfo(std::string &aPluginInfo)
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:59
bool GetClassVersion(unsigned char *Major, unsigned char *Minor, unsigned char *Patch, unsigned char *Revision)
wxDynamicLibrary m_PluginLoader
Definition pluginldr.h:133
bool GetVersion(unsigned char *Major, unsigned char *Minor, unsigned char *Patch, unsigned char *Revision)
const char * GetKicadPluginName(void)
std::string m_error
Definition pluginldr.h:130
virtual ~KICAD_PLUGIN_LDR()
Definition pluginldr.cpp:52
void close(void)
Nullify internal pointers in preparation for closing the plugin.
wxString m_fileName
Definition pluginldr.h:142
bool reopen(void)
Reopen a plugin.
const wxChar *const tracePluginLoader
Flag to enable plugin loader trace output.
Definition pluginldr.cpp:36
void(* GET_VERSION)(unsigned char *, unsigned char *, unsigned char *, unsigned char *)
Definition pluginldr.h:55
void(* GET_CLASS_VERSION)(unsigned char *, unsigned char *, unsigned char *, unsigned char *)
Definition pluginldr.h:47
bool(* CHECK_CLASS_VERSION)(unsigned char, unsigned char, unsigned char, unsigned char)
Definition pluginldr.h:50
char const *(* GET_PLUGIN_CLASS)(void)
Definition pluginldr.h:45
const char *(* GET_PLUGIN_NAME)(void)
Definition pluginldr.h:53