- Fixed: using Qt5 plugin system based on Q_PLUGIN_METADATA

This commit is contained in:
Mathew Sutcliffe
2013-07-05 23:22:11 +01:00
parent 7564973b14
commit 126ea9b8ac
5 changed files with 60 additions and 66 deletions

View File

@@ -1,6 +1,9 @@
FILE(GLOB SRC *.cpp)
SET(HEADERS server.h)
ADD_LIBRARY(sample_plugin MODULE ${SRC})
QT4_WRAP_CPP(HEADERS_MOC ${HEADERS})
ADD_LIBRARY(sample_plugin MODULE ${SRC} ${HEADERS_MOC})
TARGET_LINK_LIBRARIES(sample_plugin blackmisc ${QT_LIBRARIES})
SET_TARGET_PROPERTIES(sample_plugin PROPERTIES PROJECT_LABEL "Samples - Plugin")

View File

@@ -3,28 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "blackmisc/plugins.h"
#include "plugin.h"
#include <iostream>
class CPlugin : public BlackMisc::IPlugin
{
public:
CPlugin(BlackMisc::IPluginFactory &factory, BlackMisc::IContext &context);
virtual ~CPlugin();
virtual bool isValid() const { return m_ctorOK; }
virtual BlackMisc::IPluginFactory &getFactory() { return m_factory; }
private:
bool m_ctorOK;
BlackMisc::IPluginFactory &m_factory;
BlackMisc::IContext &m_context;
};
MAKE_BLACK_PLUGIN(sample_plugin, CPlugin, "An example minimal plugin")
CPlugin::CPlugin(BlackMisc::IPluginFactory &factory, BlackMisc::IContext &context)
: m_ctorOK(false),
m_factory(factory),

36
samples/plugin/plugin.h Normal file
View File

@@ -0,0 +1,36 @@
/* Copyright (C) 2013 VATSIM Community / authors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef SAMPLE_PLUGIN_H
#define SAMPLE_PLUGIN_H
#include "blackmisc/plugins.h"
class CPlugin : public BlackMisc::IPlugin
{
public:
CPlugin(BlackMisc::IPluginFactory &factory, BlackMisc::IContext &context);
virtual ~CPlugin();
virtual bool isValid() const { return m_ctorOK; }
virtual BlackMisc::IPluginFactory &getFactory() { return m_factory; }
private:
bool m_ctorOK;
BlackMisc::IPluginFactory &m_factory;
BlackMisc::IContext &m_context;
};
class CPluginFactory : public QObject, public BlackMisc::IPluginFactory
{
Q_OBJECT
Q_INTERFACES(BlackMisc::IPluginFactory)
Q_PLUGIN_METADATA(IID BLACKMISC_IPLUGINFACTORY_IID)
BLACKMISC_IMPLEMENT_IPLUGINFACTORY(CPlugin, "sample_plugin", "An example minimal plugin")
};
#endif //SAMPLE_PLUGIN_H

View File

@@ -9,6 +9,7 @@ DEPENDPATH += . ../../src
INCLUDEPATH += . ../../src
SOURCES += *.cpp
HEADERS += *.h
LIBS += -L../../lib -lblackmisc