Commit 810aad5168d498cb0d8142751ffe049df8720478

  • avatar
  • Julien Wintz <julien.wintz @m…me.com>
  • Tue Jan 15 16:48:59 GMT 2013
  • Tree SHA1: 3eb8933
  • Parent SHA1: b463744 (Initial revision: using the new Qt5 macros for plugins interface and implementations. Use JSON to retrieve attributes without even loading the plugin.)
  • raw diff | raw patch
Populating example plugins.
plugins/CMakeLists.txt
(5 / 2)
  
44## Copyright (C) 2008-2011 - Julien Wintz, Inria.
55## Created: Tue Jan 15 16:50:43 2013 (+0100)
66## Version: $Id$
7## Last-Updated: Tue Jan 15 16:50:57 2013 (+0100)
7## Last-Updated: Tue Jan 15 17:45:45 2013 (+0100)
88## By: Julien Wintz
9## Update #: 2
9## Update #: 4
1010######################################################################
1111##
1212### Commentary:
1818######################################################################
1919
2020add_subdirectory(tstPluginA)
21add_subdirectory(tstPluginB)
22add_subdirectory(tstPluginC)
23add_subdirectory(tstPluginD)
plugins/tstPluginB/CMakeLists.txt
(36 / 0)
  
1### CMakeLists.txt ---
2##
3## Author: Julien Wintz
4## Copyright (C) 2008-2011 - Julien Wintz, Inria.
5## Created: Tue Jan 15 16:51:15 2013 (+0100)
6## Version: $Id$
7## Last-Updated: Tue Jan 15 17:04:44 2013 (+0100)
8## By: Julien Wintz
9## Update #: 17
10######################################################################
11##
12### Commentary:
13##
14######################################################################
15##
16### Change log:
17##
18######################################################################
19
20project(tstPluginB)
21
22set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
23set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
24set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
25
26add_definitions(-DQT_PLUGIN)
27
28add_library(${PROJECT_NAME} SHARED
29 tstPluginB.h
30 tstPluginB.cpp)
31
32qt5_use_modules(${PROJECT_NAME} Core)
33qt5_use_modules(${PROJECT_NAME} Gui)
34qt5_use_modules(${PROJECT_NAME} Widgets)
35
36target_link_libraries(${PROJECT_NAME} tstCore)
plugins/tstPluginB/tstPluginB.cpp
(22 / 0)
  
1/* tstPluginB.cpp ---
2 *
3 * Author: Julien Wintz
4 * Copyright (C) 2008-2011 - Julien Wintz, Inria.
5 * Created: Tue Jan 15 16:54:04 2013 (+0100)
6 * Version: $Id$
7 * Last-Updated: Tue Jan 15 17:23:54 2013 (+0100)
8 * By: Julien Wintz
9 * Update #: 23
10 */
11
12/* Commentary:
13 *
14 */
15
16/* Change log:
17 *
18 */
19
20#include "tstPluginB.h"
21
22Q_PLUGIN_METADATA(IID "fr.inria.tstPlugin")
plugins/tstPluginB/tstPluginB.h
(36 / 0)
  
1/* tstPluginB.h ---
2 *
3 * Author: Julien Wintz
4 * Copyright (C) 2008-2011 - Julien Wintz, Inria.
5 * Created: Tue Jan 15 16:52:52 2013 (+0100)
6 * Version: $Id$
7 * Last-Updated: Tue Jan 15 17:25:26 2013 (+0100)
8 * By: Julien Wintz
9 * Update #: 43
10 */
11
12/* Commentary:
13 *
14 */
15
16/* Change log:
17 *
18 */
19
20#pragma once
21
22#include <tstCore/tstPlugin.h>
23
24#include <QtCore>
25#include <QtDebug>
26
27class tstPluginB : public tstPlugin
28{
29 Q_INTERFACES(tstPlugin)
30 Q_OBJECT
31 Q_PLUGIN_METADATA(IID "fr.inria.tstPlugin" FILE "tstPluginB.json")
32
33public:
34 tstPluginB(void) {}
35 ~tstPluginB(void) {}
36};
plugins/tstPluginB/tstPluginB.json
(5 / 0)
  
1{
2 "name" : "tstPluginB",
3 "version" : "0.0.1",
4 "dependencies" : []
5}
plugins/tstPluginC/CMakeLists.txt
(36 / 0)
  
1### CMakeLists.txt ---
2##
3## Author: Julien Wintz
4## Copyright (C) 2008-2011 - Julien Wintz, Inria.
5## Created: Tue Jan 15 16:51:15 2013 (+0100)
6## Version: $Id$
7## Last-Updated: Tue Jan 15 17:04:44 2013 (+0100)
8## By: Julien Wintz
9## Update #: 17
10######################################################################
11##
12### Commentary:
13##
14######################################################################
15##
16### Change log:
17##
18######################################################################
19
20project(tstPluginC)
21
22set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
23set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
24set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
25
26add_definitions(-DQT_PLUGIN)
27
28add_library(${PROJECT_NAME} SHARED
29 tstPluginC.h
30 tstPluginC.cpp)
31
32qt5_use_modules(${PROJECT_NAME} Core)
33qt5_use_modules(${PROJECT_NAME} Gui)
34qt5_use_modules(${PROJECT_NAME} Widgets)
35
36target_link_libraries(${PROJECT_NAME} tstCore)
plugins/tstPluginC/tstPluginC.cpp
(22 / 0)
  
1/* tstPluginC.cpp ---
2 *
3 * Author: Julien Wintz
4 * Copyright (C) 2008-2011 - Julien Wintz, Inria.
5 * Created: Tue Jan 15 16:54:04 2013 (+0100)
6 * Version: $Id$
7 * Last-Updated: Tue Jan 15 17:23:54 2013 (+0100)
8 * By: Julien Wintz
9 * Update #: 23
10 */
11
12/* Commentary:
13 *
14 */
15
16/* Change log:
17 *
18 */
19
20#include "tstPluginC.h"
21
22Q_PLUGIN_METADATA(IID "fr.inria.tstPlugin")
plugins/tstPluginC/tstPluginC.h
(36 / 0)
  
1/* tstPluginC.h ---
2 *
3 * Author: Julien Wintz
4 * Copyright (C) 2008-2011 - Julien Wintz, Inria.
5 * Created: Tue Jan 15 16:52:52 2013 (+0100)
6 * Version: $Id$
7 * Last-Updated: Tue Jan 15 17:25:26 2013 (+0100)
8 * By: Julien Wintz
9 * Update #: 43
10 */
11
12/* Commentary:
13 *
14 */
15
16/* Change log:
17 *
18 */
19
20#pragma once
21
22#include <tstCore/tstPlugin.h>
23
24#include <QtCore>
25#include <QtDebug>
26
27class tstPluginC : public tstPlugin
28{
29 Q_INTERFACES(tstPlugin)
30 Q_OBJECT
31 Q_PLUGIN_METADATA(IID "fr.inria.tstPlugin" FILE "tstPluginC.json")
32
33public:
34 tstPluginC(void) {}
35 ~tstPluginC(void) {}
36};
plugins/tstPluginC/tstPluginC.json
(5 / 0)
  
1{
2 "name" : "tstPluginC",
3 "version" : "0.0.1",
4 "dependencies" : []
5}
plugins/tstPluginD/CMakeLists.txt
(36 / 0)
  
1### CMakeLists.txt ---
2##
3## Author: Julien Wintz
4## Copyright (C) 2008-2011 - Julien Wintz, Inria.
5## Created: Tue Jan 15 16:51:15 2013 (+0100)
6## Version: $Id$
7## Last-Updated: Tue Jan 15 17:04:44 2013 (+0100)
8## By: Julien Wintz
9## Update #: 17
10######################################################################
11##
12### Commentary:
13##
14######################################################################
15##
16### Change log:
17##
18######################################################################
19
20project(tstPluginD)
21
22set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
23set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
24set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
25
26add_definitions(-DQT_PLUGIN)
27
28add_library(${PROJECT_NAME} SHARED
29 tstPluginD.h
30 tstPluginD.cpp)
31
32qt5_use_modules(${PROJECT_NAME} Core)
33qt5_use_modules(${PROJECT_NAME} Gui)
34qt5_use_modules(${PROJECT_NAME} Widgets)
35
36target_link_libraries(${PROJECT_NAME} tstCore)
plugins/tstPluginD/tstPluginD.cpp
(22 / 0)
  
1/* tstPluginD.cpp ---
2 *
3 * Author: Julien Wintz
4 * Copyright (C) 2008-2011 - Julien Wintz, Inria.
5 * Created: Tue Jan 15 16:54:04 2013 (+0100)
6 * Version: $Id$
7 * Last-Updated: Tue Jan 15 17:23:54 2013 (+0100)
8 * By: Julien Wintz
9 * Update #: 23
10 */
11
12/* Commentary:
13 *
14 */
15
16/* Change log:
17 *
18 */
19
20#include "tstPluginD.h"
21
22Q_PLUGIN_METADATA(IID "fr.inria.tstPlugin")
plugins/tstPluginD/tstPluginD.h
(36 / 0)
  
1/* tstPluginD.h ---
2 *
3 * Author: Julien Wintz
4 * Copyright (C) 2008-2011 - Julien Wintz, Inria.
5 * Created: Tue Jan 15 16:52:52 2013 (+0100)
6 * Version: $Id$
7 * Last-Updated: Tue Jan 15 17:25:26 2013 (+0100)
8 * By: Julien Wintz
9 * Update #: 43
10 */
11
12/* Commentary:
13 *
14 */
15
16/* Change log:
17 *
18 */
19
20#pragma once
21
22#include <tstCore/tstPlugin.h>
23
24#include <QtCore>
25#include <QtDebug>
26
27class tstPluginD : public tstPlugin
28{
29 Q_INTERFACES(tstPlugin)
30 Q_OBJECT
31 Q_PLUGIN_METADATA(IID "fr.inria.tstPlugin" FILE "tstPluginD.json")
32
33public:
34 tstPluginD(void) {}
35 ~tstPluginD(void) {}
36};
plugins/tstPluginD/tstPluginD.json
(5 / 0)
  
1{
2 "name" : "tstPluginD",
3 "version" : "0.0.1",
4 "dependencies" : []
5}
src/tstCore/tstPluginManager.cpp
(5 / 3)
  
44 * Copyright (C) 2008-2011 - Julien Wintz, Inria.
55 * Created: Tue Jan 15 16:25:00 2013 (+0100)
66 * Version: $Id$
7 * Last-Updated: Tue Jan 15 17:37:46 2013 (+0100)
7 * Last-Updated: Tue Jan 15 17:46:48 2013 (+0100)
88 * By: Julien Wintz
9 * Update #: 124
9 * Update #: 129
1010 */
1111
1212/* Commentary:
7171
7272 QPluginLoader *loader = new QPluginLoader(path);
7373
74 if(!(tstPlugin *plugin = qobject_cast<tstPlugin *>(loader->instance()))) {
74 if(tstPlugin *plugin = qobject_cast<tstPlugin *>(loader->instance())) {
75 /// Do something smart
76 } else {
7577 qDebug() << Q_FUNC_INFO << "Unable to retrieve plugin interface in" << path;
7678 return;
7779 }

Comments

Add a new comment:

Login or create an account to post a comment

Add your comment