| 1 |
// SPDX-FileCopyrightText: 2017 - 2022 UnionTech Software Technology Co., Ltd. |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-3.0-or-later |
| 4 |
|
| 5 |
#ifndef DEXPORTEDINTERFACE_H |
| 6 |
#define DEXPORTEDINTERFACE_H |
| 7 |
|
| 8 |
#include <dtkcore_global.h> |
| 9 |
#include <dobject.h> |
| 10 |
|
| 11 |
#include <QObject> |
| 12 |
|
| 13 |
#include <functional> |
| 14 |
|
| 15 |
DCORE_BEGIN_NAMESPACE |
| 16 |
|
| 17 |
namespace DUtil { |
| 18 |
class DExportedInterfacePrivate; |
| 19 |
class LIBDTKCORESHARED_EXPORT DExportedInterface : public QObject, public DObject |
| 20 |
{ |
| 21 |
Q_OBJECT |
| 22 |
public: |
| 23 |
explicit DExportedInterface(QObject *parent = nullptr); |
| 24 |
~DExportedInterface(); |
| 25 |
|
| 26 |
void registerAction(const QString &action, const QString &description, const std::function<QVariant(QString)> handler = nullptr); |
| 27 |
virtual QVariant invoke(const QString &action, const QString ¶meters) const; |
| 28 |
private: |
| 29 |
D_DECLARE_PRIVATE(DExportedInterface) |
| 30 |
}; |
| 31 |
} |
| 32 |
|
| 33 |
DCORE_END_NAMESPACE |
| 34 |
|
| 35 |
#endif |