Last active
October 29, 2017 11:15
-
-
Save estan/25d3acabe990a4798a8b91f26116291d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PluginSystem::PluginMock | |
PluginSystem::Plugin | |
QObject | |
QObject(0x0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "pluginsystem_export.h" | |
#include <QObject> | |
#include <QtPlugin> | |
namespace PluginSystem { | |
class PluginData; | |
class PLUGINSYSTEM_EXPORT Plugin : public QObject | |
{ | |
Q_OBJECT | |
public: | |
Plugin(); | |
virtual ~Plugin(); | |
virtual bool initialize() = 0; | |
virtual void start() = 0; | |
virtual PluginData *data() const; | |
virtual void setData(PluginData *data); | |
private: | |
PluginData *m_data = nullptr; | |
}; | |
} // namespace PluginSystem | |
Q_DECLARE_INTERFACE(PluginSystem::Plugin, "com.orexplore.Insight.PluginInterface") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "Plugin.h" | |
#include <gmock/gmock.h> | |
namespace PluginSystem { | |
class PluginMock : public Plugin | |
{ | |
Q_OBJECT | |
public: | |
MOCK_METHOD0(initialize, bool()); | |
MOCK_METHOD0(start, void()); | |
MOCK_CONST_METHOD0(data, PluginData *()); | |
MOCK_METHOD1(setData, void(PluginData *)); | |
}; | |
} // namespace PluginSystem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Print inheritance hierarchy. | |
const QMetaObject *metaObject = instance->metaObject(); | |
while (metaObject) { | |
qDebug() << metaObject->className(); | |
metaObject = metaObject->superClass(); | |
} | |
// Try qobject_cast to Plugin *. | |
auto plugin = qobject_cast<Plugin *>(instance); | |
qDebug() << plugin; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment