Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create a DLL project and specify the preprocessor directive e.g. /DIFLOOR_EXPORTS_COMMONPLUGINBASE (this preprocessor variable only in DLL project)</p> <p>Then create a header which specifies whether your classes are imported or exported:</p> <p><strong>CommonPluing.h</strong></p> <pre><code>#ifndef _COMMONPLUGIN_H #define _COMMONPLUGIN_H #if defined(__WXMSW__) #ifdef IFLOOR_EXPORTS_COMMONPLUGINBASE #define IFLOOR_API_COMMONPLUGINBASE __declspec(dllexport) #else #define IFLOOR_API_COMMONPLUGINBASE __declspec(dllimport) #endif #else #define IFLOOR_API_COMMONPLUGINBASE #endif #endif // _COMMONPLUGIN_H </code></pre> <p>Then create your exported class and add the specifier from first header:</p> <p><strong>CommonConfigWindowBase.h</strong></p> <pre><code>class IFLOOR_API_COMMONPLUGINBASE CommonConfigWindowBase : public wxPanel { DECLARE_DYNAMIC_CLASS(CommonConfigWindowBase) public: /// Constructors CommonConfigWindowBase(); CommonConfigWindowBase(wxWindow *parent, wxWindowID winid = wxID_ANY, const wxPoint&amp; pos = wxDefaultPosition, const wxSize&amp; size = wxDefaultSize, long style = wxTAB_TRAVERSAL | wxNO_BORDER, const wxString&amp; name = wxPanelNameStr); /// Pseudo ctor bool Create(wxWindow *parent, wxWindowID winid = wxID_ANY, const wxPoint&amp; pos = wxDefaultPosition, const wxSize&amp; size = wxDefaultSize, long style = wxTAB_TRAVERSAL | wxNO_BORDER, const wxString&amp; name = wxPanelNameStr); virtual ~CommonConfigWindowBase(); /// Reads config from the effect virtual bool ReadConfig(){return true;} /// Saves config to the effect virtual bool SaveConfig(){return true;} }; </code></pre> <p>Create the exported function callable from main executable (you may want to create a wrapper class and call methods which return wxWindow *). You need an exported method for creating the plugin object and for deleting it. Also you need a !!! virtual destructors !!! for exported object and for your windows. so assuming that SportEffectPlugin contains a wxWindow * CreateConfigWindow(wxWindow * parent) method:</p> <p><strong>Exports.cpp</strong></p> <pre><code>#include "stdwx.h" #include "CommonConfigWindowBase.h" IFLOOR_API_COMMONPLUGINBASE IFloorEffectPluginBase * CreatePlugin(const wxString&amp; sBasePath, iFloorBlobVector * blobs) { return new SportEffectPlugin(sBasePath, blobs); } IFLOOR_API_COMMONPLUGINBASE void DeletePlugin(IFloorEffectPluginBase * plugin) { wxDELETE(plugin); } </code></pre> <p>Then in main app load the DLL (you will need to adopt the following code for your needs):</p> <p><strong>Loader.cpp</strong></p> <pre><code>bool IFloorSystem::LoadPlugins(bool forceProgramPath) { if (!m_DefaultPlugin) { m_DefaultPlugin = new DefaultEffectPlugin(GetDefaultGraphicsPath()); RegisterEffectPlugin(m_DefaultPlugin); } wxFileName fn; fn.AssignDir(GetPluginsPath(forceProgramPath)); wxLogDebug(wxT("%s"), fn.GetFullPath().data()); fn.AppendDir(wxT("effects")); wxLogDebug(wxT("%s"), fn.GetFullPath().data()); if (!fn.DirExists()) return false; wxDir dir(fn.GetFullPath()); if (!dir.IsOpened()) return false; // scan for plugins wxString filename; wxString ext = wxT("*.dll"); // TODO: change ext for different platforms bool bFound = dir.GetFirst(&amp;filename, ext, wxDIR_FILES); while (bFound) { fn.SetFullName(filename); wxDynamicLibrary * dll = new wxDynamicLibrary(fn.GetFullPath()); if (dll-&gt;IsLoaded()) { wxDYNLIB_FUNCTION(CreatePlugin_function, CreatePlugin, *dll); if (pfnCreatePlugin) { IFloorEffectPluginBase* plugin = pfnCreatePlugin(GetDefaultGraphicsPath(), &amp;IFloorStorage::Instance().GetBlobs()); RegisterEffectPlugin(plugin); m_DllList.Append(dll); m_MapPluginsDll[plugin] = dll; } else wxDELETE(dll); } bFound = dir.GetNext(&amp;filename); } return true; } </code></pre> <p>Then in the end you will need to unload plugins and delete all loaded objects by calling the function from DLL:</p> <pre><code>bool IFloorSystem::UnRegisterEffectPlugin(IFloorEffectPluginBase * plugin) { IFloorEffectPluginBaseList::compatibility_iterator it = m_Plugins.Find(plugin); if (it == NULL) return false; do { wxDynamicLibrary * dll = m_MapPluginsDll[plugin]; if (!dll) // Probably plugin was not loaded from dll break; wxDYNLIB_FUNCTION(DeletePlugin_function, DeletePlugin, *dll); if (pfnDeletePlugin) { pfnDeletePlugin(plugin); m_Plugins.Erase(it); m_MapPluginsDll.erase(plugin); return true; } } while (false); // If plugin is not loaded from DLL wxDELETE(plugin); m_Plugins.Erase(it); return true; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload