Commit 8ed9b47a authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

first working version of a plugin based composer extension mechanism

parent 999a178a
...@@ -45,6 +45,10 @@ SOURCE_GROUP("Header Files" REGULAR_EXPRESSION .*\\.h\$) ...@@ -45,6 +45,10 @@ SOURCE_GROUP("Header Files" REGULAR_EXPRESSION .*\\.h\$)
## Installation ## Installation
## ################################################################# ## #################################################################
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_RPATH 0)
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
install(TARGETS ${PROJECT_NAME} install(TARGETS ${PROJECT_NAME}
BUNDLE DESTINATION bin BUNDLE DESTINATION bin
RUNTIME DESTINATION bin) RUNTIME DESTINATION bin)
...@@ -86,6 +86,10 @@ target_link_libraries(${PROJECT_NAME} Qt5::Widgets) ...@@ -86,6 +86,10 @@ target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
## Installation ## Installation
## ################################################################# ## #################################################################
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_RPATH 0)
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
install(FILES ${${PROJECT_NAME}_MODULES} DESTINATION modules) install(FILES ${${PROJECT_NAME}_MODULES} DESTINATION modules)
install(TARGETS ${PROJECT_NAME} install(TARGETS ${PROJECT_NAME}
BUNDLE DESTINATION bin BUNDLE DESTINATION bin
......
...@@ -38,6 +38,10 @@ target_link_libraries(${PROJECT_NAME} Qt5::Core) ...@@ -38,6 +38,10 @@ target_link_libraries(${PROJECT_NAME} Qt5::Core)
## Installation ## Installation
## ################################################################# ## #################################################################
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_RPATH 0)
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
install(TARGETS ${PROJECT_NAME} install(TARGETS ${PROJECT_NAME}
BUNDLE DESTINATION bin BUNDLE DESTINATION bin
RUNTIME DESTINATION bin) RUNTIME DESTINATION bin)
......
...@@ -46,6 +46,10 @@ SOURCE_GROUP("Header Files" REGULAR_EXPRESSION .*\\.h\$) ...@@ -46,6 +46,10 @@ SOURCE_GROUP("Header Files" REGULAR_EXPRESSION .*\\.h\$)
## Installation ## Installation
## ################################################################# ## #################################################################
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_RPATH 0)
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
install(TARGETS ${PROJECT_NAME} install(TARGETS ${PROJECT_NAME}
BUNDLE DESTINATION bin BUNDLE DESTINATION bin
RUNTIME DESTINATION bin) RUNTIME DESTINATION bin)
...@@ -44,6 +44,7 @@ set(${PROJECT_NAME}_HEADERS ...@@ -44,6 +44,7 @@ set(${PROJECT_NAME}_HEADERS
dtkComposerEvaluator_p.h dtkComposerEvaluator_p.h
dtkComposerEvaluatorProcess.h dtkComposerEvaluatorProcess.h
dtkComposerEvaluatorSlave.h dtkComposerEvaluatorSlave.h
dtkComposerExtension.h
dtkComposerFactory.h dtkComposerFactory.h
dtkComposerGraph.h dtkComposerGraph.h
dtkComposerGraphEdge.h dtkComposerGraphEdge.h
......
...@@ -9,18 +9,46 @@ ...@@ -9,18 +9,46 @@
*/ */
#include "dtkComposer.h" #include "dtkComposer.h"
#include <dtkConfig.h>
#include "dtkComposerNodeFactory.h" #include "dtkComposerNodeFactory.h"
#include "dtkComposerFactory.h"
#include "dtkComposerExtension.h"
namespace dtkComposer namespace dtkComposer
{ {
namespace node namespace node
{
dtkComposerNodeFactory *factory(void) {
return dtkComposerFactory::instance();
}
}
namespace extension
{ {
namespace _private { namespace _private {
dtkComposerNodeFactory _factory; dtkComposerExtensionPluginFactory factory;
dtkComposerExtensionPluginManager manager;
}
dtkComposerExtensionPluginFactory& pluginFactory(void) {
return _private::factory;
} }
dtkComposerNodeFactory& factory(void) { dtkComposerExtensionPluginManager& pluginManager(void) {
return _private::_factory; return _private::manager;
}
void initialize(const QString& path) {
if (path.isEmpty()) {
QString default_path = QDir(DTK_INSTALL_PREFIX).filePath("plugins/dtkComposer");
dtkDebug() << "no composer plugin path configured, use default:" << default_path ;
pluginManager().setVerboseLoading(true);
pluginManager().initialize(default_path);
} else {
dtkDebug() << "initialize composer plugins using path:" << path ;
pluginManager().initialize(path);
}
} }
} }
} }
...@@ -15,12 +15,21 @@ ...@@ -15,12 +15,21 @@
#pragma once #pragma once
#include "dtkComposerExport.h" #include "dtkComposerExport.h"
#include <QtCore>
class dtkComposerNodeFactory; class dtkComposerNodeFactory;
class dtkComposerExtensionPlugin;
class dtkComposerExtensionPluginManager;
class dtkComposerExtensionPluginFactory;
namespace dtkComposer namespace dtkComposer
{ {
namespace node { namespace node {
DTKCOMPOSER_EXPORT dtkComposerNodeFactory& factory(void); DTKCOMPOSER_EXPORT dtkComposerNodeFactory *factory(void);
}
namespace extension {
DTKCOMPOSER_EXPORT dtkComposerExtensionPluginFactory& pluginFactory(void);
DTKCOMPOSER_EXPORT dtkComposerExtensionPluginManager& pluginManager(void);
DTKCOMPOSER_EXPORT void initialize(const QString& path = "");
} }
} }
/* @(#)dtkComposerExtension.h ---
*
* Author: Nicolas Niclausse
* Copyright (C) 2016 - Nicolas Niclausse, Inria.
* Created: 2016/02/09 14:13:42
*/
/* Commentary:
*
*/
/* Change log:
*
*/
#pragma once
#include "dtkComposerExport.h"
#include <dtkCore/dtkCorePlugin.h>
class dtkComposerNodeFactory;
class DTKCOMPOSER_EXPORT dtkComposerExtension
{
public:
dtkComposerExtension(void) {}
virtual ~dtkComposerExtension(void) {}
public:
virtual void extend(dtkComposerNodeFactory *factory) = 0;
};
DTK_DECLARE_PLUGIN(dtkComposerExtension, DTKCOMPOSER_EXPORT)
DTK_DECLARE_PLUGIN_FACTORY(dtkComposerExtension, DTKCOMPOSER_EXPORT)
DTK_DECLARE_PLUGIN_MANAGER(dtkComposerExtension, DTKCOMPOSER_EXPORT)
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
// Code: // Code:
#include "dtkComposerNodeFactory.h" #include "dtkComposerNodeFactory.h"
#include "dtkComposerExtension.h"
#include "dtkComposerNodeMetaData.h" #include "dtkComposerNodeMetaData.h"
#include <dtkMeta> #include <dtkMeta>
...@@ -71,7 +73,7 @@ void dtkComposerNodeFactory::record(const QString& metadata_file_path, creator f ...@@ -71,7 +73,7 @@ void dtkComposerNodeFactory::record(const QString& metadata_file_path, creator f
} }
} }
void dtkComposerNodeFactory::extend(dtkComposerNodeFactoryExtension *extension) void dtkComposerNodeFactory::extend(dtkComposerExtension *extension)
{ {
extension->extend(this); extension->extend(this);
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
class dtkComposerNodeFactoryPrivate; class dtkComposerNodeFactoryPrivate;
class dtkComposerNodeMetaData; class dtkComposerNodeMetaData;
class dtkComposerNodeFactoryExtension; class dtkComposerExtension;
// /////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////
// dtkComposerNodeFactory definition // dtkComposerNodeFactory definition
...@@ -42,7 +42,7 @@ public: ...@@ -42,7 +42,7 @@ public:
void record(const QString& metadata_file_path, creator func); void record(const QString& metadata_file_path, creator func);
public: public:
void extend(dtkComposerNodeFactoryExtension *extension); void extend(dtkComposerExtension *extension);
public: public:
const QStringList& nodes(void) const; const QStringList& nodes(void) const;
...@@ -65,15 +65,6 @@ template <typename T> dtkComposerNode *dtkComposerNodeCreator(void) ...@@ -65,15 +65,6 @@ template <typename T> dtkComposerNode *dtkComposerNodeCreator(void)
// //
// /////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////
class DTKCOMPOSER_EXPORT dtkComposerNodeFactoryExtension
{
public:
dtkComposerNodeFactoryExtension(void) {}
virtual ~dtkComposerNodeFactoryExtension(void) {}
public:
virtual void extend(dtkComposerNodeFactory *factory) = 0;
};
// //
// dtkComposerNodeFactory.h ends here // dtkComposerNodeFactory.h ends here
...@@ -32,7 +32,7 @@ void dtkComposerSceneTestCase::test(void) ...@@ -32,7 +32,7 @@ void dtkComposerSceneTestCase::test(void)
dtkComposerStack *stack = new dtkComposerStack; dtkComposerStack *stack = new dtkComposerStack;
dtkComposerScene *scene = new dtkComposerScene; dtkComposerScene *scene = new dtkComposerScene;
scene->setFactory(&(dtkComposer::node::factory())); scene->setFactory(dtkComposer::node::factory());
scene->setGraph(graph); scene->setGraph(graph);
scene->setStack(stack); scene->setStack(stack);
...@@ -75,7 +75,7 @@ void dtkComposerSceneTestCase::test(void) ...@@ -75,7 +75,7 @@ void dtkComposerSceneTestCase::test(void)
{ // Create a boolean node { // Create a boolean node
dtkComposerStackCommandCreateNode *command = new dtkComposerStackCommandCreateNode; dtkComposerStackCommandCreateNode *command = new dtkComposerStackCommandCreateNode;
command->setFactory(&(dtkComposer::node::factory())); command->setFactory(dtkComposer::node::factory());
command->setScene(scene); command->setScene(scene);
command->setGraph(graph); command->setGraph(graph);
command->setParent(scene->root()); command->setParent(scene->root());
...@@ -89,7 +89,7 @@ void dtkComposerSceneTestCase::test(void) ...@@ -89,7 +89,7 @@ void dtkComposerSceneTestCase::test(void)
{ // Create another boolean node { // Create another boolean node
dtkComposerStackCommandCreateNode *command = new dtkComposerStackCommandCreateNode; dtkComposerStackCommandCreateNode *command = new dtkComposerStackCommandCreateNode;
command->setFactory(&(dtkComposer::node::factory())); command->setFactory(dtkComposer::node::factory());
command->setScene(scene); command->setScene(scene);
command->setGraph(graph); command->setGraph(graph);
command->setParent(scene->root()); command->setParent(scene->root());
...@@ -103,7 +103,7 @@ void dtkComposerSceneTestCase::test(void) ...@@ -103,7 +103,7 @@ void dtkComposerSceneTestCase::test(void)
{ // Create another boolean node { // Create another boolean node
dtkComposerStackCommandCreateNode *command = new dtkComposerStackCommandCreateNode; dtkComposerStackCommandCreateNode *command = new dtkComposerStackCommandCreateNode;
command->setFactory(&(dtkComposer::node::factory())); command->setFactory(dtkComposer::node::factory());
command->setScene(scene); command->setScene(scene);
command->setGraph(graph); command->setGraph(graph);
command->setParent(scene->root()); command->setParent(scene->root());
...@@ -117,7 +117,7 @@ void dtkComposerSceneTestCase::test(void) ...@@ -117,7 +117,7 @@ void dtkComposerSceneTestCase::test(void)
{ // Create a boolean operator node { // Create a boolean operator node
dtkComposerStackCommandCreateNode *command = new dtkComposerStackCommandCreateNode; dtkComposerStackCommandCreateNode *command = new dtkComposerStackCommandCreateNode;
command->setFactory(&(dtkComposer::node::factory())); command->setFactory(dtkComposer::node::factory());
command->setScene(scene); command->setScene(scene);
command->setGraph(graph); command->setGraph(graph);
command->setParent(scene->root()); command->setParent(scene->root());
......
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