Commit ef63402e authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas
Browse files

Merge branch 'master' into pluginCheckVersion

Conflicts:
	src/dtkCore/dtkCorePluginManager.tpp
parents 36243baf 77cd7dfe
......@@ -12,7 +12,7 @@
##
### Code:
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.2.0)
######################################################################
......@@ -32,7 +32,7 @@ set(dtk_VERSION_MAJOR 1)
set(dtk_VERSION_MINOR 1)
set(dtk_VERSION_PATCH 0)
set(dtk_VERSION
${dtk_VERSION_MAJOR}.${dtk_VERSION_PATCH}.${dtk_VERSION_PATCH})
${dtk_VERSION_MAJOR}.${dtk_VERSION_MINOR}.${dtk_VERSION_PATCH})
## ###################################################################
## Path setup
......@@ -54,6 +54,12 @@ endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
## #################################################################
## Generate compilation database
## #################################################################
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
## #################################################################
## Install prefix
## #################################################################
......@@ -71,32 +77,28 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(GenerateExportHeader)
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -I/usr/lib/c++/v1")
endif(APPLE)
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
endif(UNIX)
if(NOT APPLE AND NOT MSVC)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-unknown-pragmas")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wno-unknown-pragmas")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
if(CMAKE_COMPILER_IS_GNUCXX AND DTK_ENABLE_COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
endif(CMAKE_COMPILER_IS_GNUCXX AND DTK_ENABLE_COVERAGE)
else(NOT APPLE AND NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif(NOT APPLE AND NOT MSVC)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(DTK_BUILD_32 0)
set(DTK_BUILD_64 1)
......@@ -159,6 +161,7 @@ if(DTK_ENABLE_COVERAGE)
include(dtkCodeCoverage)
include(FindPythonInterp)
if(DTK_COVERAGE_USE_COBERTURA)
SETUP_TARGET_FOR_COVERAGE_COBERTURA(cov ctest coverage)
else(DTK_COVERAGE_USE_COBERTURA)
......
......@@ -19,6 +19,7 @@
#define dtk_VERSION_PATCH @dtk_VERSION_PATCH@
#include <QString>
static const QString DTK_INSTALL_PREFIX = "@CMAKE_INSTALL_PREFIX@";
#cmakedefine DTK_HAVE_MPI
......@@ -45,8 +46,5 @@ static const QString DTK_INSTALL_PREFIX = "@CMAKE_INSTALL_PREFIX@";
#cmakedefine COMPILER_SUPPORTS_CXX11
#cmakedefine COMPILER_SUPPORTS_CXX11
#cmakedefine COMPILER_SUPPORTS_CXX11
//
// dtkConfig.h.in ends here
/* dtkComposerNodeFactoryView.cpp ---
*
* Author: Thibaud Kloczko
* Created: Thu Apr 11 10:39:25 2013 (+0200)
* Version:
* Last-Updated: ven. janv. 9 10:50:29 2015 (+0100)
* By: Thibaud Kloczko
* Update #: 141
*/
/* Change Log:
*
*/
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkComposerNodeFactory.h"
#include "dtkComposerNodeFactoryView.h"
......@@ -28,7 +28,6 @@ public:
dtkComposerNodeFactory *factory;
public:
dtkWidgetsTagCloud *cloud;
dtkWidgetsTagCloudController *controller;
dtkWidgetsTagCloudScope *scope;
dtkWidgetsTagCloudView *view;
......@@ -41,31 +40,18 @@ dtkComposerNodeFactoryView::dtkComposerNodeFactoryView(QWidget *parent) : QWidge
d->scope = new dtkWidgetsTagCloudScope(this);
d->scope->toggle();
d->cloud = new dtkWidgetsTagCloud(this);
d->cloud->setSortingType(dtkWidgetsTagCloud::Alpha);
d->cloud->setSortingOrder(dtkWidgetsTagCloud::Asc);
d->cloud->setFontSize(17);
d->cloud->setFontRange(15);
d->view = new dtkWidgetsTagCloudView(this);
d->controller = new dtkWidgetsTagCloudController;
d->controller->attach(d->scope);
d->controller->attach(d->view);
d->controller->attach(d->cloud);
d->controller->onUnionMode(false);
QSplitter *splitter = new QSplitter(this);
splitter->addWidget(d->cloud);
splitter->addWidget(d->view);
splitter->setOrientation(Qt::Vertical);
splitter->setHandleWidth(1);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(d->scope);
layout->addWidget(splitter);
layout->addWidget(d->view);
this->addNote();
}
......@@ -83,11 +69,12 @@ void dtkComposerNodeFactoryView::setFactory(dtkComposerNodeFactory *factory)
d->factory = factory;
const QHash<QString, dtkComposerNodeMetaData *>& meta_datas = factory->metaDatas();
QHash<QString, dtkComposerNodeMetaData *>::const_iterator cit = meta_datas.begin();
QHash<QString, dtkComposerNodeMetaData *>::const_iterator cend = meta_datas.end();
for(; cit != cend; ++cit) {
dtkComposerNodeMetaData *md = *cit;
// qDebug() << md->title() << md->description() << md->tags() << QString::number(md->kind()) << md->type();
d->controller->addItem(md->title(), md->description(), md->tags(), "node", md->type());
}
}
......@@ -95,9 +82,11 @@ void dtkComposerNodeFactoryView::setFactory(dtkComposerNodeFactory *factory)
void dtkComposerNodeFactoryView::addNote(void)
{
dtkComposerNodeMetaData *note_md = new dtkComposerNodeMetaData;
if(note_md->setFromFile(":dtkComposer/dtkComposerNote.json")) {
d->controller->addItem(note_md->title(), note_md->description(), note_md->tags(), "note", note_md->type());
}
delete note_md;
}
......@@ -112,11 +101,6 @@ dtkWidgetsTagCloudView *dtkComposerNodeFactoryView::itemView(void) const
return d->view;
}
dtkWidgetsTagCloud *dtkComposerNodeFactoryView::cloudView(void) const
{
return d->cloud;
}
dtkWidgetsTagCloudScope *dtkComposerNodeFactoryView::scopeView(void) const
{
return d->scope;
......@@ -128,9 +112,13 @@ void dtkComposerNodeFactoryView::onShowNodeDocumentation(dtkComposerSceneNode *n
return;
dtkComposerNode* wrapee = node->wrapee();
if(!wrapee)
return;
if (wrapee->nodeMetaData())
d->view->onItemClicked(wrapee->nodeMetaData()->description());
}
//
// dtkComposerNodeFactoryView.cpp ends here
/* dtkComposerNodeFactoryView.h ---
*
* Author: Thibaud Kloczko
* Created: Thu Apr 11 10:38:29 2013 (+0200)
* Version:
* Last-Updated: ven. janv. 9 10:13:20 2015 (+0100)
* By: Thibaud Kloczko
* Update #: 8
*/
/* Change Log:
*
*/
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
......@@ -48,10 +48,12 @@ public:
void setDark(void);
public:
dtkWidgetsTagCloud *cloudView(void) const;
dtkWidgetsTagCloudView *itemView(void) const;
dtkWidgetsTagCloudScope *scopeView(void) const;
private:
dtkComposerNodeFactoryViewPrivate *d;
};
//
// dtkComposerNodeFactoryView.h ends here
......@@ -34,9 +34,6 @@
#include "dtkComposerNodeControlMap.h"
#include "dtkComposerNodeFile.h"
#include "dtkComposerNodeInteger.h"
// #include "dtkComposerNodeLeafData.h"
// #include "dtkComposerNodeLeafProcess.h"
// #include "dtkComposerNodeLeafView.h"
#include "dtkComposerNodeReal.h"
#include "dtkComposerNodeString.h"
......@@ -72,12 +69,13 @@ dtkComposerSceneNodeEditorList::~dtkComposerSceneNodeEditorList(void)
QSize dtkComposerSceneNodeEditorList::sizeHint(void) const
{
return QSize(300, 50);
return QSize(300, 150);
}
void dtkComposerSceneNodeEditorList::addInputPort(dtkComposerScenePort *port)
{
dtkComposerSceneNodeEditorListItem *item = new dtkComposerSceneNodeEditorListItem(port, this);
port->isVisible() ? item->setCheckState(Qt::Checked) : item->setCheckState(Qt::Unchecked);
this->addItem(item);
......@@ -86,6 +84,7 @@ void dtkComposerSceneNodeEditorList::addInputPort(dtkComposerScenePort *port)
void dtkComposerSceneNodeEditorList::addOutputPort(dtkComposerScenePort *port)
{
dtkComposerSceneNodeEditorListItem *item = new dtkComposerSceneNodeEditorListItem(port, this);
port->isVisible() ? item->setCheckState(Qt::Checked) : item->setCheckState(Qt::Unchecked);
this->addItem(item);
......@@ -223,7 +222,7 @@ dtkComposerSceneNodeEditor::dtkComposerSceneNodeEditor(QWidget *parent) : QWidge
d->rem_loop_port->setVisible(false);
d->blocks = new dtkComposerSceneNodeEditorList(this);
d->blocks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
d->blocks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
d->blocks->setVisible(false);
d->add_block = new QPushButton("+", this);
......@@ -235,7 +234,7 @@ dtkComposerSceneNodeEditor::dtkComposerSceneNodeEditor(QWidget *parent) : QWidge
d->rem_block->setVisible(false);
d->input_ports = new dtkComposerSceneNodeEditorList(this);
d->input_ports->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
d->input_ports->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
d->input_ports->setVisible(false);
d->add_input_port = new QPushButton("+", this);
......@@ -417,7 +416,7 @@ dtkComposerSceneNodeEditor::dtkComposerSceneNodeEditor(QWidget *parent) : QWidge
p_layout->addLayout(op_layout);
QHBoxLayout *si_layout = new QHBoxLayout;
si_layout->setContentsMargins(0, 0, 0, 0);
si_layout->setContentsMargins(0, 5, 0, 5);
si_layout->setSpacing(0);
si_layout->addWidget(d->select_implementation);
......@@ -432,7 +431,7 @@ dtkComposerSceneNodeEditor::dtkComposerSceneNodeEditor(QWidget *parent) : QWidge
// d->layout_widg_edit->addWidget(d->bool_widget);
d->layout = new QVBoxLayout(this);
d->layout->setContentsMargins(5, 0, 5, 0);
d->layout->setContentsMargins(0, 0, 0, 0);
d->layout->setSpacing(0);
d->layout->addWidget(top);
d->layout->addLayout(si_layout);
......@@ -442,6 +441,7 @@ dtkComposerSceneNodeEditor::dtkComposerSceneNodeEditor(QWidget *parent) : QWidge
d->layout->addLayout(p_layout);
d->layout->addSpacing(10);
d->layout->addLayout(d->layout_widg_edit);
d->layout->addStretch(1);
connect(d->add_loop_port, SIGNAL(clicked()), this, SLOT(addLoopPort()));
connect(d->rem_loop_port, SIGNAL(clicked()), this, SLOT(removeLoopPort()));
......@@ -558,7 +558,7 @@ void dtkComposerSceneNodeEditor::setNode(dtkComposerSceneNode *node)
d->rem_output_port->setVisible(true);
foreach(dtkComposerSceneNodeComposite *block, c->blocks())
d->selector->addItem(block->title());
d->selector->addItem(block->title());
d->selector->blockSignals(false);
d->selector->setVisible(true);
......@@ -1335,20 +1335,6 @@ void dtkComposerSceneNodeEditor::onImplementationChanged(const QString& implemen
object = object_node->variant().value<QObject*>();
}
// if (dtkComposerNodeLeafData *data_node = dynamic_cast<dtkComposerNodeLeafData *>(d->node->wrapee())) {
// data_node->createData(implementation);
// object = reinterpret_cast<QObject *>(data_node->data());
// } else if (dtkComposerNodeLeafProcess *process_node = dynamic_cast<dtkComposerNodeLeafProcess *>(d->node->wrapee())) {
// process_node->createProcess(implementation);
// object = reinterpret_cast<QObject *>(process_node->process());
// } else if (dtkComposerNodeLeafView *view_node = dynamic_cast<dtkComposerNodeLeafView *>(d->node->wrapee())) {
// view_node->createView(implementation);
// object = reinterpret_cast<QObject *>(view_node->view());
// }
if (object) {
dtkToolBoxItem *item = dtkToolBoxItem::fromObject(object, 0);
item->setContentsMargins(0, 0, 0, 0);
......@@ -1376,7 +1362,6 @@ void dtkComposerSceneNodeEditor::onImplementationChanged(const QString& implemen
d->current_widget->setEnabled(true);
d->layout_widg_edit->addWidget(d->current_widget);
}
}
//
......
......@@ -36,6 +36,7 @@ set(${PROJECT_NAME}_HEADERS
dtkCorePluginFactoryTemplate
dtkCorePluginFactoryTemplate.h
dtkCorePluginManager
dtkCorePluginManagerBase.h
dtkCorePluginManager.h
dtkCorePluginManager.tpp
dtkCorePluginTuner
......@@ -57,6 +58,7 @@ set(${PROJECT_NAME}_SOURCES
dtkCoreApplication.cpp
dtkCoreSettings.cpp
dtkArrayData.cpp
dtkCorePluginManagerBase.cpp
)
## #################################################################
......
......@@ -21,7 +21,6 @@
#include <vector>
#include <string.h>
// ///////////////////////////////////////////////////////////////////
// Preallocated data area for quickly building small arrays on the stack without malloc overhead
// ///////////////////////////////////////////////////////////////////
......
......@@ -5,6 +5,7 @@
#include "dtkCorePluginFactory.h"
#include "dtkCorePluginFactoryTemplate.h"
#include "dtkCorePluginManager.h"
#include "dtkCorePluginManagerBase.h"
#include "dtkCorePluginTuner.h"
#include "dtkArrayData.h"
#include "dtkArray.h"
......
......@@ -101,3 +101,28 @@ inline bool dtkFileIsBinary(const QString& path)
return (c != EOF);
}
// compare versions. Use it to compare plugin version against version of his layer
inline bool checkVersion(const QString ref_version, const QString elem_version)
{
QStringList ve_ref_list = ref_version.split(".");
QStringList ve_elem_list = elem_version.split(".");
//if major level different return false
if(ve_ref_list.at(0).toInt() != ve_elem_list.at(0).toInt())
return false;
//if minor level of ref < elem return false
if(ve_ref_list.at(1).toInt() < ve_elem_list.at(1).toInt())
return false;
else {
//if same minor level, compare patch level
if((ve_ref_list.at(1).toInt() == ve_elem_list.at(1).toInt()) &&
(ve_ref_list.at(2).toInt() < ve_elem_list.at(2).toInt()))
return false;
//else minor level of elem < ref , then don't compare patch level
}
return true;
}
......@@ -14,7 +14,8 @@
#pragma once
#include <QtDebug>
#include "dtkCorePluginManagerBase.h"
#include "dtkCore.h"
#include <dtkLog>
......@@ -26,8 +27,7 @@
template <typename T> class dtkCorePluginManagerPrivate
{
public:
bool check(const QString& path);
bool checkVersion(const QString ref_version, const QString elem_version);
bool check(const QString& path, bool checkConcept = true);
public:
bool verboseLoading;
......@@ -35,63 +35,38 @@ public:
QString layerVersion = QString();
public:
QHash<QString, QVariant> concept;
QHash<QString, QVariantList> dependencies;
QHash<QString, QVariant> pluginsLayerVersion;
QHash<QString, QVariant> names;
QHash<QString, QVariant> versions;
QHash<QString, QVariantList> dependencies;
public:
QHash<QString, QPluginLoader *> loaders;
};
// ///////////////////////////////////////////////////////////////////
// dtkCorePluginManagerPrivate
// ///////////////////////////////////////////////////////////////////
//version of the plugin should match the version of his layer
//template <typename T> bool dtkCorePluginManagerPrivate<T>::checkVersion(const QString key, const QVariant ve_check)
template <typename T> bool dtkCorePluginManagerPrivate<T>::checkVersion(const QString ref_version, const QString elem_version)
{
QStringList ve_ref_list = ref_version.split(".");
QStringList ve_elem_list = elem_version.split(".");
//if major level different return false
if(ve_ref_list.at(0).toInt() != ve_elem_list.at(0).toInt())
return false;
//if minor level of ref < elem return false
if(ve_ref_list.at(1).toInt() < ve_elem_list.at(1).toInt())
return false;
else {
//if same minor level, compare patch level
if((ve_ref_list.at(1).toInt() == ve_elem_list.at(1).toInt()) &&
(ve_ref_list.at(2).toInt() < ve_elem_list.at(2).toInt()))
return false;
//else minor level of elem < ref , then don't compare patch level
}
return true;
}
template <typename T> bool dtkCorePluginManagerPrivate<T>::check(const QString& path)
template <typename T> bool dtkCorePluginManagerPrivate<T>::check(const QString& path, bool checkConcept)
{
bool status = true;
QString conceptName = QMetaType::typeName(qMetaTypeId<T*>());
conceptName.remove("Plugin*");
if (checkConcept) {
QString conceptName = QMetaType::typeName(qMetaTypeId<T*>());
conceptName.remove("Plugin*");
QString pluginConcept = this->concept.value(path).toString();
QString pluginConcept = dtkCorePluginManagerBase::instance()->concept(path).toString();
if (conceptName != pluginConcept) {
if (this->verboseLoading) {
dtkTrace() << "skip plugin: not an implementation of the current concept" << conceptName << ", current is " << pluginConcept;
if (conceptName != pluginConcept) {
if (this->verboseLoading) {
dtkTrace() << "skip plugin: not an implementation of the current concept" << conceptName << ", current is " << pluginConcept;
}
return false;
}
return false;
}
if (!layerVersion.isNull() && !this->checkVersion(layerVersion ,this->pluginsLayerVersion.value(path).toString())) {
if (!layerVersion.isNull() && !checkVersion(layerVersion ,this->pluginsLayerVersion.value(path).toString())) {
dtkWarn() << " Version mismatch: layer version " << layerVersion
<< " plugin compiled for layer version" << this->pluginsLayerVersion.value(path).toString()
<< " for plugin " << path;
......@@ -103,24 +78,24 @@ template <typename T> bool dtkCorePluginManagerPrivate<T>::check(const QString&
QVariantMap mitem = item.toMap();
QVariant na_mitem = mitem.value("name");
QVariant ve_mitem = mitem.value("version");
QString key = this->names.key(na_mitem);
QString key = dtkCorePluginManagerBase::instance()->pluginPath(na_mitem);
if(!this->names.values().contains(na_mitem)) {
if(!dtkCorePluginManagerBase::instance()->hasName(na_mitem)) {
dtkWarn() << " Missing dependency:" << na_mitem.toString() << "for plugin" << path;
status = false;
continue;
}
if (this->checkVersion(ve_mitem.toString(), this->versions.value(this->names.key(na_mitem)).toString())) {
dtkWarn() << " Version mismatch:" << na_mitem.toString() << "version" << this->versions.value(this->names.key(na_mitem)).toString() << "but" << ve_mitem.toString() << "required for plugin" << path;
if (checkVersion(ve_mitem.toString(), dtkCorePluginManagerBase::instance()->version(key).toString())) {
dtkWarn() << " Version mismatch:" << na_mitem.toString() << "version" << dtkCorePluginManagerBase::instance()->version(key).toString() << "but" << ve_mitem.toString() << "required for plugin" << path;
status = false;
continue;
}
if(!check(key)) {
if(!check(key, false)) {
dtkWarn() << "Corrupted dependency:" << na_mitem.toString() << "for plugin" << path;
status = false;
......@@ -181,9 +156,10 @@ template <typename T> void dtkCorePluginManager<T>::loadFromName(const QString &
{
QString full_name = plugin_name % "Plugin";
QHash<QString, QVariant>::const_iterator i = d->names.constBegin();
auto i = dtkCorePluginManagerBase::instance()->namesBegin();
auto e = dtkCorePluginManagerBase::instance()->namesEnd();
while (i != d->names.constEnd()) {
while (i != e) {
if(QString::compare(i.value().toString(), full_name) == 0) {
this->load(i.key());
return;
......@@ -192,7 +168,7 @@ template <typename T> void dtkCorePluginManager<T>::loadFromName(const QString &
}
dtkWarn() << Q_FUNC_INFO << plugin_name << " not found ";
dtkWarn() << Q_FUNC_INFO << "keys" << d->names.keys() << d->names.values();
dtkWarn() << Q_FUNC_INFO << "keys" << dtkCorePluginManagerBase::instance()->pluginPaths() << dtkCorePluginManagerBase::instance()->names();
}
// /////////////////////////////////////////////////////////////////
......@@ -246,9 +222,9 @@ template <typename T> void dtkCorePluginManager<T>::scan(const QString& path)
QPluginLoader *loader = new QPluginLoader(path);
d->names.insert(path, loader->metaData().value("MetaData").toObject().value("name").toVariant());
d->concept.insert(path, loader->metaData().value("MetaData").toObject().value("concept").toVariant());
d->versions.insert(path, loader->metaData().value("MetaData").toObject().value("version").toVariant());
dtkCorePluginManagerBase::instance()->insertName(path, loader->metaData().value("MetaData").toObject().value("name").toVariant());
dtkCorePluginManagerBase::instance()->insertVersion(path, loader->metaData().value("MetaData").toObject().value("version").toVariant());
dtkCorePluginManagerBase::instance()->insertConcept(path, loader->metaData().value("MetaData").toObject().value("concept").toVariant());
d->dependencies.insert(path, loader->metaData().value("MetaData").toObject().value("dependencies").toArray().toVariantList());
d->pluginsLayerVersion.insert(path, loader->metaData().value("MetaData").toObject().value("layerVersion").toVariant());
......
/* @(#)dtkCorePluginManagerBase.cpp ---
*
* Author: Nicolas Niclausse
* Copyright (C) 2016 - Nicolas Niclausse, Inria.
* Created: 2016/07/04 14:23:33
*/
/* Commentary:
*
*/
/* Change log:
*