Restructured main with new KwApplication and plugin manager to use it
[kworship.git] / kworship / KwPlugin.h
blobf5f91dfb6821ff4982debbec0eaceb93084256a8
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * KWorship is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * KWorship is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef _KwPlugin_h_
21 #define _KwPlugin_h_
23 /**
24 * @file KwPlugin.h
25 * @brief An abstract KWorship plugin.
26 * @author James Hogan <james@albanarts.com>
29 #include <QObject>
30 #include <QString>
32 class KwPluginManager;
34 class QDockWidget;
36 /// An abstract KWorship plugin.
37 class KwPlugin : public QObject
39 Q_OBJECT
41 public:
44 * Constructors + destructor
47 /** Primary constructor.
48 * @param id Short unique untranslated id.
49 * @param name Translated name of plugin.
50 * @param description Translated description of plugin.
52 KwPlugin(const QString& id, const QString& name, const QString& description);
54 /// Destructor.
55 virtual ~KwPlugin();
58 * Basic information accessors
61 /// Get the id.
62 const QString& id() const;
64 /// Get the name.
65 const QString& name() const;
67 /// Get the description.
68 const QString& description() const;
70 /// Get whether the plugin is loaded.
71 bool isLoaded() const;
74 * Loading and unloading
77 /** Set the manager.
78 * This should only be called by the manager class itself.
79 * @pre Manager must not have already been set.
80 * @param manager New manager object.
82 void setManager(KwPluginManager* manager);
84 /** Load the plugin.
85 * @pre Manager must have been set.
87 void load();
89 /// Unload the plugin.
90 void unload();
92 protected:
95 * Loading and unloading virtual interface
98 /** Load the plugin.
99 * @pre !isLoaded()
101 virtual void _load() = 0;
103 /** Unload the plugin.
104 * @pre isLoaded()
106 virtual void _unload() = 0;
108 private:
111 * Constants
114 /// Short unique untranslated id.
115 QString m_id;
117 /// Translated name.
118 QString m_name;
120 /// Translated description.
121 QString m_description;
124 * Variables
127 /// The current plugin manager.
128 KwPluginManager* m_manager;
130 /// Whether the plugin is loaded.
131 bool m_loaded;
135 #endif // _KwPlugin_h_