File: pluginmanager.h

package info (click to toggle)
cutecom 0.51.0-1.1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 2,280 kB
  • sloc: cpp: 4,228; python: 240; makefile: 54; sh: 9
file content (90 lines) | stat: -rw-r--r-- 3,145 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 * Copyright (c) 208 Dimitris Tassopoulos <dimtass@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * For more information on the GPL, please go to:
 * http://www.gnu.org/copyleft/gpl.html
 */

/**
 * The plugin manager handles the application plugins. The mainwindow form
 * has an empty dedicated QVBoxLayout that can be used from plugins to show
 * them selves in the main form. If a plugin requires a lot of space then
 * you can use a dedicated window and only add a very small ui element that
 * spawns that dialog. Finaly, the element from the mainwindow that is also
 * used from the plugin manager is the the 'Plugins' dropbox menu item. Every
 * plugin has an action on that menu and every time that the action then a
 * new plugin object will be added; therefore, try to write plugins in a way
 * that multiple instances can be loaded!
 *
 * The pluging manager provides plugins with the finctionality to be able to
 * change the content of the serial cmd string before it's send on the serial
 * port by using the function `processCmd()`. Because there can be several
 * plugins that may be able to modify this string, be aware that the priority
 * order is the same with the index of the plugin in the plugin QList (m_list).
 * Also every pluging can send a serial command with the `sendCmd()` signal.
 *
 * Make sure that plugins clean up themselves properly when unloaded.
 */

#ifndef PLUGINMANAGER_H
#define PLUGINMANAGER_H

#include "counterplugin.h"
#include "macroplugin.h"
#include "netproxyplugin.h"
#include "plugin.h"
#include "settings.h"
#include <QDebug>
#include <QFrame>
#include <QObject>
#include <QVBoxLayout>

class PluginManager : public QObject
{
    Q_OBJECT

public:
    /* Every plug in has its own type */
    enum en_plugin_type {
        PLUGIN_TYPE_MACROS,
        PLUGIN_TYPE_NET_PROXY,
        PLUGIN_TYPE_BYTE_COUNTER,
    };
    PluginManager(QFrame *parent, QVBoxLayout *layout, Settings *settings);
    virtual ~PluginManager();
    void processCmd(QString *text);

public slots:
    void addPluginType(en_plugin_type);
    void removePlugin(Plugin *);

signals:
    void recvCmd(QByteArray); /* mainwindow -> manager */
    void sendCmd(QByteArray); /* manager -> mainwindow */

protected:
    void addPlugin(Plugin *item);

private:
    QFrame *m_parent;
    QVBoxLayout *m_layout;
    QList<Plugin *> m_list;
    Settings *m_settings;
    /* Supported plugins */
    MacroPlugin *m_macro_plugin;
};
#endif // PLUGINMANAGER_H