Commit 9d9bd0db authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas
Browse files

first attempt to wrap dtkCorePluginFactory and dtkCorePluginManager

parent 28ee575a
......@@ -46,9 +46,7 @@ if(SIP_FOUND)
COMMAND ${SIP_EXECUTABLE}
ARGS
"-I" "${PYQT5_MODULE_DIR}/"
"-I" "${CMAKE_SOURCE_DIR}/sip"
"-I" "${CMAKE_SOURCE_DIR}/sip/dtkCore"
"-I" "${CMAKE_SOURCE_DIR}/sip/dtkWidgets"
"-I" "${dtk_INCLUDE_DIR}/sip"
"-t" "${SIP_PLATFORM}"
"-c" "${CMAKE_CURRENT_BINARY_DIR}/"
${input}
......
template <TYPE> class dtkCorePluginFactory : public QObject
{
%TypeHeaderCode
#include <dtkCore/dtkCorePluginFactory.h>
%End
public:
dtkCorePluginFactory();
~dtkCorePluginFactory();
// https://www.riverbankcomputing.com/pipermail/pyqt/2009-June/023375.html
// public:
// typedef TYPE *(*creator) ();
// typedef dtkCorePluginTuner<TYPE> *(*tunerCreator) ();
public:
void record(const QString& key, creator func);
void recordTuner(const QString& key, tunerCreator func);
public:
TYPE *create(const QString& key) const;
dtkCorePluginTuner<TYPE> *createTuner(const QString& key) const;
public:
QStringList keys() const;
};
class dtkCorePluginManagerBase : public QObject
{
%TypeHeaderCode
#include <dtkCore/dtkCorePluginManager.h>
%End
public:
virtual ~dtkCorePluginManagerBase();
public:
virtual void initialize(const QString& path) = 0;
virtual void uninitialize() = 0;
virtual void setVerboseLoading(bool value) = 0;
virtual bool verboseLoading() const = 0;
virtual void setAutoLoading(bool value) = 0;
virtual bool autoLoading() const = 0;
virtual void load(const QString& path) = 0;
virtual void unload(const QString& path) = 0;
};
template <TYPE> class dtkCorePluginManager : public dtkCorePluginManagerBase
{
%TypeHeaderCode
#include <dtkCore/dtkCorePluginManager.h>
%End
public:
dtkCorePluginManager();
~dtkCorePluginManager();
void initialize(const QString& path);
void uninitialize();
public:
void setVerboseLoading(bool value);
bool verboseLoading() const;
void setAutoLoading(bool value);
bool autoLoading() const;
void loadFromName(const QString& plugin_name);
void setLayerVersion(const QString& layer_version);
void load(const QString& path);
void unload(const QString& path);
QStringList plugins() const ;
QStringList availablePlugins() const;
};
......@@ -3,3 +3,5 @@
%Import QtCore/QtCoremod.sip
%Include dtkCorePluginBase.sip
%Include dtkCorePluginFactory.sip
%Include dtkCorePluginManager.sip
......@@ -98,7 +98,9 @@ if(DTK_BUILD_WRAPPERS)
set(${PROJECT_NAME}_WRAP_DEPENDS ${${PROJECT_NAME}_HEADERS})
if(SIP_FOUND)
set(${PROJECT_NAME}_SIP_WRAPPERS sip${PROJECT_NAME}dtkCorePluginBase.cpp)
set(${PROJECT_NAME}_SIP_WRAPPERS
sip${PROJECT_NAME}dtkCorePluginBase.cpp
sip${PROJECT_NAME}dtkCorePluginManagerBase.cpp)
dtk_wrap_sip(${PROJECT_NAME} ${PROJECT_NAME}_SOURCES_WRAP dtkCore ${CMAKE_SOURCE_DIR}/sip/dtkCore/dtkCoremod.sip "${${PROJECT_NAME}_SIP_WRAPPERS}" ${${PROJECT_NAME}_WRAP_DEPENDS})
endif(SIP_FOUND)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment