Commit 547e3301 authored by Julien Wintz's avatar Julien Wintz

Merge pull request #24 from d-tk/core_without_qwidget

Core without qwidget
parents 43437735 9618d4ee
......@@ -115,6 +115,7 @@ option(DTK_BUILD_COMPOSER "Build composer layer" false)
option(DTK_BUILD_DISTRIBUTED "Build distributed layer" true)
option(DTK_BUILD_SCRIPT "Build script layer" false)
option(DTK_BUILD_WRAPPERS "Build wrappers" false)
option(DTK_BUILD_WIDGETS "Build widgets" true)
option(DTK_BUILD_SUPPORT_CORE "Build support layer" false)
option(DTK_BUILD_SUPPORT_CONTAINER "Build support layer" false)
option(DTK_BUILD_SUPPORT_COMPOSER "Build support layer" false)
......@@ -386,6 +387,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/dtkMath)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/dtkMeta)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/dtkScript)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/dtkTest)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/dtkWidgets)
## ###################################################################
## Input
......
......@@ -21,7 +21,7 @@
int main(int argc, char **argv)
{
dtkApplication *application = dtkApplication::create(argc, argv);
dtkCoreApplication *application = dtkCoreApplication::create(argc, argv);
application->setApplicationName("dtkDistributedServer");
application->setApplicationVersion("1.0.0");
application->setOrganizationName("inria");
......
......@@ -29,6 +29,7 @@ target_link_libraries(${PROJECT_NAME}
dtkCore
dtkDistributed
dtkLog
dtkWidgets
)
target_link_libraries(${PROJECT_NAME} Qt5::Core)
......
......@@ -18,6 +18,7 @@
#include <dtkDistributed>
#include <dtkLog>
#include <dtkWidgets/dtkDistributedGuiApplication.h>
#include <QtCore>
......@@ -58,7 +59,7 @@ public:
int main(int argc, char **argv)
{
dtkDistributedApplication *app = dtkDistributed::create(argc, argv);
dtkDistributedGuiApplication *app = dtkDistributedGuiApplication::create(argc, argv);
app->setApplicationName("dtkDistributedSlave");
app->setApplicationVersion("1.0.0");
app->setOrganizationName("inria");
......
......@@ -31,8 +31,6 @@ set(dtk_INCLUDE_DIRS
"@CMAKE_CURRENT_SOURCE_DIR@/src/dtkMath"
"@CMAKE_CURRENT_SOURCE_DIR@/src/dtkMeta"
"@CMAKE_CURRENT_SOURCE_DIR@/src/dtkTest"
"@CMAKE_CURRENT_SOURCE_DIR@/src/dtkWidgets"
"@CMAKE_CURRENT_SOURCE_DIR@/src/dtkComposer"
"@CMAKE_CURRENT_BINARY_DIR@")
include("@CMAKE_BINARY_DIR@/dtkDepends.cmake")
......@@ -58,6 +56,7 @@ set(DTK_BUILD_DISTRIBUTED @DTK_BUILD_DISTRIBUTED@)
set(DTK_BUILD_COMPOSER @DTK_BUILD_COMPOSER@)
set(DTK_BUILD_SCRIPT @DTK_BUILD_SCRIPT@)
set(DTK_BUILD_WRAPPERS @DTK_BUILD_WRAPPERS@)
set(DTK_BUILD_WIDGETS @DTK_BUILD_WIDGETS@)
set(DTK_BUILD_SUPPORT_CORE @DTK_BUILD_SUPPORT_CORE@)
set(DTK_BUILD_SUPPORT_CONTAINER @DTK_BUILD_SUPPORT_CONTAINER@)
set(DTK_BUILD_SUPPORT_COMPOSER @DTK_BUILD_SUPPORT_COMPOSER@)
......@@ -80,5 +79,10 @@ if(DTK_BUILD_COMPOSER)
"@CMAKE_CURRENT_SOURCE_DIR@/src/dtkComposer")
endif(DTK_BUILD_COMPOSER)
if(DTK_BUILD_WIDGETS)
set(dtk_INCLUDE_DIRS ${dtk_INCLUDE_DIRS}
"@CMAKE_CURRENT_SOURCE_DIR@/src/dtkWidgets")
endif(DTK_BUILD_WIDGETS)
######################################################################
### dtkConfig.cmake.in ends here
......@@ -28,7 +28,8 @@ set(dtk_INCLUDE_DIRS
"@CMAKE_INSTALL_PREFIX@/include/dtkLog"
"@CMAKE_INSTALL_PREFIX@/include/dtkMath"
"@CMAKE_INSTALL_PREFIX@/include/dtkMeta"
"@CMAKE_INSTALL_PREFIX@/include/dtkTest")
"@CMAKE_INSTALL_PREFIX@/include/dtkTest"
"@CMAKE_INSTALL_PREFIX@/include/dtkWidgets")
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH} "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/cmake/dtk/")
......@@ -57,6 +58,7 @@ set(DTK_BUILD_DISTRIBUTED @DTK_BUILD_DISTRIBUTED@)
set(DTK_BUILD_COMPOSER @DTK_BUILD_COMPOSER@)
set(DTK_BUILD_SCRIPT @DTK_BUILD_SCRIPT@)
set(DTK_BUILD_WRAPPERS @DTK_BUILD_WRAPPERS@)
set(DTK_BUILD_WIDGETS @DTK_BUILD_WIDGETS@)
set(DTK_BUILD_SUPPORT_CORE @DTK_BUILD_SUPPORT_CORE@)
set(DTK_BUILD_SUPPORT_CONTAINER @DTK_BUILD_SUPPORT_CONTAINER@)
set(DTK_BUILD_SUPPORT_COMPOSER @DTK_BUILD_SUPPORT_COMPOSER@)
......@@ -79,6 +81,11 @@ if(DTK_BUILD_COMPOSER)
"@CMAKE_INSTALL_PREFIX@/include/dtkComposer")
endif(DTK_BUILD_COMPOSER)
if(DTK_BUILD_WIDGETS)
set(dtk_INCLUDE_DIRS ${dtk_INCLUDE_DIRS}
"@CMAKE_INSTALL_PREFIX@/include/dtkWidgets")
endif(DTK_BUILD_WIDGETS)
## ###################################################################
## Always full RPATH
## ###################################################################
......
......@@ -35,7 +35,10 @@ add_subdirectory(dtkLog)
add_subdirectory(dtkMath)
add_subdirectory(dtkMeta)
add_subdirectory(dtkTest)
if(DTK_BUILD_WIDGETS)
add_subdirectory(dtkWidgets)
endif(DTK_BUILD_WIDGETS)
## #################################################################
## Essential target
......@@ -59,7 +62,10 @@ endif(DTK_BUILD_SCRIPT)
set(DTK_TARGETS ${DTK_TARGETS} dtkLog)
set(DTK_TARGETS ${DTK_TARGETS} dtkMath)
set(DTK_TARGETS ${DTK_TARGETS} dtkMeta)
if(DTK_BUILD_WIDGETS)
set(DTK_TARGETS ${DTK_TARGETS} dtkWidgets)
endif(DTK_BUILD_WIDGETS)
## #################################################################
## Support layer
......
......@@ -29,6 +29,7 @@ static const QString DTK_INSTALL_PREFIX = "@CMAKE_INSTALL_PREFIX@";
#cmakedefine DTK_BUILD_DISTRIBUTED
#cmakedefine DTK_BUILD_SCRIPT
#cmakedefine DTK_BUILD_WRAPPERS
#cmakedefine DTK_BUILD_WIDGETS
#cmakedefine DTK_BUILD_SUPPORT_CORE
#cmakedefine DTK_BUILD_SUPPORT_COMPOSER
......
......@@ -19,7 +19,7 @@ project(dtkCore)
## #################################################################
set(${PROJECT_NAME}_HEADERS
dtkApplication.h
dtkApplicationPrivate.h
dtkArray
dtkArray.h
dtkArray.tpp
......@@ -27,6 +27,7 @@ set(${PROJECT_NAME}_HEADERS
dtkArrayData.h
dtkCore
dtkCore.h
dtkCoreApplication.h
dtkCorePlugin
dtkCorePlugin.h
dtkCorePluginFactory
......@@ -46,14 +47,14 @@ set(${PROJECT_NAME}_HEADERS
dtkSpinLock.h
dtkStaticArray
dtkStaticArray.h
dtkCoreWidgetFactory.h
)
set(${PROJECT_NAME}_SOURCES
dtkApplication.cpp
dtkApplicationPrivate.cpp
dtkCoreApplication.cpp
dtkCoreSettings.cpp
dtkArrayData.cpp
dtkCoreWidgetFactory.cpp)
)
## #################################################################
## Deps
......@@ -90,7 +91,6 @@ endif (DTK_HAVE_ZLIB)
target_link_libraries(${PROJECT_NAME} dtkMeta dtkLog)
target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
## #################################################################
## Target properties
......
/* dtkApplication.cpp ---
/* dtkApplicationPrivate.h ---
*
* Author: Nicolas Niclausse
* Copyright (C) 2015 - Nicolas Niclausse, Inria.
* Created: 2015/02/04 12:03:44
* Copyright (C) 2016 - Nicolas Niclausse, Inria.
* Created: 2016/04/25 08:53:17
*/
/* Commentary:
......@@ -13,49 +13,29 @@
*
*/
#include "dtkApplication.h"
#include "dtkApplicationPrivate.h"
#include <dtkLog>
class dtkApplicationPrivate
dtkApplicationPrivate::dtkApplicationPrivate(void)
{
public:
QSettings *settings;
QCommandLineParser parser;
};
dtkApplication::dtkApplication(int &argc, char **argv): QApplication(argc, argv)
{
d = new dtkApplicationPrivate;
d->settings = NULL;
d->parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
}
dtkApplication::~dtkApplication(void)
{
if (d->settings)
delete d->settings;
delete d;
d = NULL;
}
QSettings *dtkApplication::settings(void)
{
return d->settings;
settings = NULL;
app = NULL;
parser = new QCommandLineParser;
parser->setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
}
bool dtkApplication::noGui(void)
dtkApplicationPrivate::~dtkApplicationPrivate(void)
{
return !(qApp && qobject_cast<QGuiApplication *>(qApp) && (QGuiApplication::platformName() != "minimal")) ;
if (settings)
delete settings;
}
QCommandLineParser *dtkApplication::parser(void)
void dtkApplicationPrivate::setApplication(QCoreApplication *q)
{
return &(d->parser);
app = q;
}
void dtkApplication::initialize(void)
void dtkApplicationPrivate::initialize(void)
{
// unset QT_PLUGIN_PATH, otherwise, kde plugins can change the qmetatype ids
qputenv("QT_PLUGIN_PATH", "1");
......@@ -67,56 +47,58 @@ void dtkApplication::initialize(void)
setlocale(LC_NUMERIC, "C");
#endif
d->parser.addHelpOption();
d->parser.addVersionOption();
parser->addHelpOption();
parser->addVersionOption();
QCommandLineOption settingsOption("settings", "main settings file", "filename");
d->parser.addOption(settingsOption);
parser->addOption(settingsOption);
QCommandLineOption verboseOption("verbose", QCoreApplication::translate("main", "verbose plugin initialization"));
d->parser.addOption(verboseOption);
parser->addOption(verboseOption);
QCommandLineOption nonguiOption(QStringList() << "nw" << "no-window", QCoreApplication::translate("main", "non GUI application (no window)"));
d->parser.addOption(nonguiOption);
parser->addOption(nonguiOption);
QString verbosity = "info";
QCommandLineOption loglevelOption("loglevel", "log level used by dtkLog (default is info), available: trace|debug|info|warn|error|fatal", "level", verbosity);
d->parser.addOption(loglevelOption);
parser->addOption(loglevelOption);
QCoreApplication *q = dynamic_cast<QCoreApplication *>(this);
QCommandLineOption logfileOption("logfile", qPrintable(QString("log file used by dtkLog; default is: ").append(dtkLogPath(q))),"filename | console",dtkLogPath(q));
d->parser.addOption(logfileOption);
QCommandLineOption logfileOption("logfile", qPrintable(QString("log file used by dtkLog; default is: ").append(dtkLogPath(app))),"filename | console",dtkLogPath(app));
parser->addOption(logfileOption);
QCommandLineOption logfileMaxSizeOption("logfilemax", "log file max size (in MB); default is: 3072 (3GB)","size");
d->parser.addOption(logfileMaxSizeOption);
parser->addOption(logfileMaxSizeOption);
d->parser.process(*q);
parser->process(*app);
if(d->parser.isSet(settingsOption)) {
d->settings = new QSettings(d->parser.value(settingsOption), QSettings::IniFormat);
if(parser->isSet(settingsOption)) {
settings = new QSettings(parser->value(settingsOption), QSettings::IniFormat);
} else {
d->settings = new QSettings(q->organizationName(), q->applicationName());
settings = new QSettings(app->organizationName(), app->applicationName());
}
if (d->settings->contains("log_level")) {
dtkLogger::instance().setLevel(d->settings->value("log_level").toString());
if (settings->contains("log_level")) {
dtkLogger::instance().setLevel(settings->value("log_level").toString());
} else {
if (d->parser.isSet(loglevelOption)) {
verbosity= d->parser.value(loglevelOption);
if (parser->isSet(loglevelOption)) {
verbosity= parser->value(loglevelOption);
}
dtkLogger::instance().setLevel(verbosity);
}
qlonglong max_size = 1024L*1024L*1024L;
if (d->parser.isSet(logfileMaxSizeOption)) {
max_size = d->parser.value(logfileMaxSizeOption).toLongLong() * 1024 * 1024;
if (parser->isSet(logfileMaxSizeOption)) {
max_size = parser->value(logfileMaxSizeOption).toLongLong() * 1024 * 1024;
}
if (d->parser.isSet(logfileOption)) {
if (d->parser.value(logfileOption) == "console") {
if (parser->isSet(logfileOption)) {
if (parser->value(logfileOption) == "console") {
dtkLogger::instance().attachConsole();
} else {
dtkLogger::instance().attachFile(d->parser.value(logfileOption), max_size);
dtkLogger::instance().attachFile(parser->value(logfileOption), max_size);
}
} else {
dtkLogger::instance().attachFile(dtkLogPath(q), max_size);
dtkLogger::instance().attachFile(dtkLogPath(app), max_size);
}
}
/* dtkApplicationPrivate.h ---
*
* Author: Nicolas Niclausse
* Copyright (C) 2016 - Nicolas Niclausse, Inria.
* Created: 2016/04/25 08:53:17
*/
/* Commentary:
*
*/
/* Change log:
*
*/
#pragma once
#include "dtkCoreExport.h"
#include <QtCore>
class DTKCORE_EXPORT dtkApplicationPrivate
{
public:
dtkApplicationPrivate(void);
virtual ~dtkApplicationPrivate(void);
public:
QSettings *settings;
QCommandLineParser *parser;
QCoreApplication *app;
public:
virtual void initialize(void);
void setApplication(QCoreApplication *app);
};
#include "dtkApplication.h"
#include "dtkApplicationPrivate.h"
#include "dtkCore.h"
#include "dtkCoreApplication.h"
#include "dtkCorePlugin.h"
#include "dtkCorePluginFactory.h"
#include "dtkCorePluginFactory.tpp"
......@@ -11,4 +12,3 @@
#include "dtkArray.tpp"
#include "dtkIterator.h"
#include "dtkStaticArray.h"
#include "dtkCoreWidgetFactory.h"
/* dtkCoreApplication.cpp ---
*
* Author: Nicolas Niclausse
* Copyright (C) 2015 - Nicolas Niclausse, Inria.
* Created: 2015/02/04 12:03:44
*/
/* Commentary:
*
*/
/* Change log:
*
*/
#include "dtkCoreApplication.h"
#include "dtkApplicationPrivate.h"
dtkCoreApplication::dtkCoreApplication(int &argc, char **argv): QCoreApplication(argc, argv)
{
d = new dtkApplicationPrivate;
d->setApplication(this);
}
dtkCoreApplication::~dtkCoreApplication(void)
{
delete d;
d = NULL;
}
QSettings *dtkCoreApplication::settings(void)
{
return d->settings;
}
QCommandLineParser *dtkCoreApplication::parser(void)
{
return d->parser;
}
void dtkCoreApplication::initialize(void)
{
d->initialize();
}
/* dtkApplication.h ---
/* dtkCoreApplication.h ---
*
* Author: Nicolas Niclausse
* Copyright (C) 2015 - Nicolas Niclausse, Inria.
......@@ -18,37 +18,30 @@
#include "dtkCoreExport.h"
#include <dtkLog>
#include <QApplication>
#include <QCoreApplication>
class dtkApplicationPrivate;
class DTKCORE_EXPORT dtkApplication: public QApplication
class DTKCORE_EXPORT dtkCoreApplication: public QCoreApplication
{
public:
dtkApplication(int &argc, char **argv);
virtual ~dtkApplication(void);
dtkCoreApplication(int &argc, char **argv);
virtual ~dtkCoreApplication(void);
public:
virtual void initialize(void);
public:
virtual bool noGui(void);
public:
static dtkApplication *create(int &argc, char *argv[])
static dtkCoreApplication *create(int &argc, char *argv[])
{
for (int i = 0; i < argc; i++)
if(!qstrcmp(argv[i], "-nw") ||!qstrcmp(argv[i], "--nw") || !qstrcmp(argv[i], "-no-window")|| !qstrcmp(argv[i], "--no-window") || !qstrcmp(argv[i], "-h") || !qstrcmp(argv[i], "--help")|| !qstrcmp(argv[i], "--version")) {
qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("minimal"));
}
return new dtkApplication(argc, argv);
return new dtkCoreApplication(argc, argv);
}
public:
QCommandLineParser *parser(void);
QSettings *settings(void);
private:
protected:
dtkApplicationPrivate *d;
};
......
......@@ -17,7 +17,6 @@
#include "dtkCorePluginManager"
#include "dtkCorePluginFactory"
#include "dtkCoreWidgetFactory.h"
#include "dtkCoreExport.h"
// ///////////////////////////////////////////////////////////////////
......@@ -72,13 +71,6 @@ public:
#define DTK_DECLARE_PLUGIN_MANAGER(type,Export) \
class Export type##PluginManager : public dtkCorePluginManager<type##Plugin> {};
// ///////////////////////////////////////////////////////////////////
// DTK_DECLARE_WIDGET_FACTORY
// ///////////////////////////////////////////////////////////////////
#define DTK_DECLARE_WIDGET_FACTORY(type,Export) \
class Export type##WidgetFactory : public dtkCoreWidgetFactory{}; \
template <typename T> QWidget *type##WidgetCreator() { return new T; };
// ///////////////////////////////////////////////////////////////////
// DTK_DEFINE_PLUGIN
......
......@@ -22,6 +22,7 @@ set(${PROJECT_NAME}_HEADERS
dtkDistributed
dtkDistributed.h
dtkDistributedApplication.h
dtkDistributedApplicationPrivate.h
dtkDistributedArray
dtkDistributedArray.h
dtkDistributedArray.tpp
......@@ -65,6 +66,7 @@ set(${PROJECT_NAME}_HEADERS
set(${PROJECT_NAME}_SOURCES
dtkDistributed.cpp
dtkDistributedApplication.cpp
dtkDistributedApplicationPrivate.cpp
dtkDistributedArray.cpp
dtkDistributedBufferManager.cpp
dtkDistributedCommunicator.cpp
......
......@@ -16,23 +16,13 @@
#include "dtkDistributed.h"
#include "dtkDistributedApplication.h"
#include "dtkDistributedApplicationPrivate.h"
#include "dtkDistributedCommunicator"
#include "dtkDistributedSettings.h"
#include "dtkDistributedPolicy.h"
#include <dtkLog>
class dtkDistributedApplicationPrivate
{
public:
dtkDistributedPolicy policy;
bool spawned;
bool nospawn;
QString wrapper;
QString smp;
};
/*!
......@@ -42,104 +32,23 @@ public:
*/
dtkDistributedApplication::dtkDistributedApplication(int &argc, char **argv): dtkApplication(argc, argv)
dtkDistributedApplication::dtkDistributedApplication(int &argc, char **argv): dtkCoreApplication(argc, argv)
{
d = new dtkDistributedApplicationPrivate;
d->spawned = false;
d->nospawn = false;
}
dtkDistributedApplication::~dtkDistributedApplication(void)
{
if (d->spawned)
this->unspawn();
delete d;
d = NULL;
}
void dtkDistributedApplication::initialize(void)
{
QCommandLineParser *parser = dtkDistributedApplication::parser();
QString policyType = "qthread";
QCommandLineOption policyOption("policy", "dtkDistributed policy (default is qthread)", "qthread|mpi|mpi3", policyType);
parser->addOption(policyOption);
QCommandLineOption npOption("np","number of processes","int","1");
parser->addOption(npOption);
QCommandLineOption nsOption("no-spawn","disable spawning");
parser->addOption(nsOption);
QCommandLineOption ntOption("nt","number of threads (for hybrid plugins)","int", "1");
parser->addOption(ntOption);
QCommandLineOption wrapperOption("wrapper","use wrapper command when spawning processes","command", "");
parser->addOption(wrapperOption);
QCommandLineOption smpOption("smp", "smp option (disabled by default)", "single|funneled|serialized|multiple","");
parser->addOption(smpOption);
QCommandLineOption hostsOption("hosts","hosts (multiple hosts can be specified)","hostname", "localhost");
parser->addOption(hostsOption);
QCommandLineOption DSsettingsOption("distributed-settings", "dtkDistributed settings file", "filename");
parser->addOption(DSsettingsOption);
dtkApplication::initialize();
QSettings *settings;
if(parser->isSet(DSsettingsOption)) {
settings = new QSettings(parser->value(DSsettingsOption), QSettings::IniFormat);
} else {
settings = new dtkDistributedSettings;
}
if(parser->isSet(nsOption)) {
d->nospawn = true;
}