Commit c343727c authored by Tobias WEBER's avatar Tobias WEBER
Browse files

pol plugin test

parent 7b1678c1
......@@ -8,6 +8,7 @@
project(pol)
cmake_minimum_required(VERSION 3.0)
set(CMAKE_VERBOSE_MAKEFILE TRUE)
set(BUILD_LIB TRUE)
find_package(Boost REQUIRED)
......@@ -26,10 +27,10 @@ if(BUILD_LIB)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
add_definitions(-DBUILD_LIB)
add_library(pol SHARED
add_library(pol SHARED
pol.cpp ../glplot/glplot.cpp ../glplot/glplot.h)
else()
add_executable(pol
add_executable(pol
pol.cpp ../glplot/glplot.cpp ../glplot/glplot.h)
endif()
......
......@@ -542,18 +542,25 @@ int main(int argc, char** argv)
#include <boost/dll/alias.hpp>
std::shared_ptr<QDialog>
//QDialog*
create(QWidget *pParent)
bool init()
{
//std::cout << "In " << __FUNCTION__ << std::endl;
set_gl_format(1, _GL_MAJ_VER, _GL_MIN_VER, 8);
set_locales();
return true;
}
//return new PolDlg(pParent);
std::shared_ptr<QDialog> create(QWidget *pParent)
{
//std::cout << "In " << __FUNCTION__ << std::endl;
return std::make_shared<PolDlg>(pParent);
}
BOOST_DLL_ALIAS(create, create);
BOOST_DLL_ALIAS(init, tl_init);
BOOST_DLL_ALIAS(create, tl_create);
#endif
......
......@@ -3,8 +3,9 @@
* @author Tobias Weber <tweber@ill.fr>
* @date Nov-2018
* @license GPLv3, see 'LICENSE' file
*
*
* g++-8 -std=c++17 -I/usr/local/include -L/usr/local/lib -o runplugin runplugin.cpp -F/usr/local/opt/qt5/lib -framework QtCore -framework QtWidgets -lboost_filesystem -lboost_system
* g++ -std=c++17 -I/usr/local/include -I/usr/include/qt5 -L/usr/local/lib -fPIC -o runplugin runplugin.cpp -lQt5Core -lQt5Widgets -lboost_filesystem -lboost_system -ldl
*/
#include <QtWidgets/QApplication>
......@@ -44,20 +45,26 @@ int main(int argc, char** argv)
std::cerr << "Plugin " << dll->location() << " loaded." << std::endl;
if(!dll->has("create"))
if(!dll->has("tl_init") || !dll->has("tl_create"))
{
std::cerr << "Plugin does not have the \"create\" function." << std::endl;
std::cerr << "Plugin does not have the \"tl_init\" or \"tl_create\" functions." << std::endl;
return -1;
}
if(auto initDlg = dll->get<bool(*)()>("tl_init"); initDlg)
initDlg();
auto app = std::make_unique<QApplication>(argc, argv);
//auto createDlg = dll->get<QDialog*(*)(QWidget*)>("create");
auto createDlg = dll->get<std::shared_ptr<QDialog>(*)(QWidget*)>("create");
auto dlg = createDlg(nullptr);
if(dlg)
dlg->show();
if(auto createDlg = dll->get<std::shared_ptr<QDialog>(*)(QWidget*)>("tl_create"); createDlg)
{
if(auto dlg = createDlg(nullptr); dlg)
{
dlg->show();
dlg->activateWindow();
}
}
return app->exec();
}
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