00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef COMMAND_PLUGIN_H
00024 #define COMMAND_PLUGIN_H
00025
00026 #include <QtPlugin>
00027 #include <Command.h>
00028 #include <QStringList>
00029 #include <QHash>
00030 #include <QVariant>
00031
00032 class CommandInterface
00033 {
00034 public:
00035 virtual ~CommandInterface() {}
00036 virtual Command* create(QObject* obj, const QString& command, QVariantList arguments) = 0;
00037 };
00038
00039 Q_DECLARE_INTERFACE(CommandInterface, "org.traversodaw.Command.CommandInterface/1.0");
00040
00041
00048 class CommandPlugin : public QObject, public CommandInterface
00049 {
00050 Q_OBJECT
00051 Q_INTERFACES(CommandInterface);
00052
00053 public:
00054 virtual ~CommandPlugin() {}
00063 virtual Command* create(QObject* obj, const QString& command, QVariantList arguments) = 0;
00064
00065 virtual QStringList commands() const {
00066 return QStringList(m_dict.keys());
00067 }
00068
00069 virtual bool implements(const QString& command) const {
00070 return m_dict.contains(command);
00071 }
00072
00073 protected:
00074 QHash<QString, int> m_dict;
00075 };
00076
00077 #endif
00078
00079