Receptacle
 All Classes Files Functions Variables Pages
util_collection.h
1 /*
2 
3 Copyright 2014 William Wedler
4 
5 This file is part of Receptacle
6 
7 Receptacle is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Receptacle is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License
18 along with Receptacle. If not, see <http://www.gnu.org/licenses/>.
19 
20 */
21 
22 
23 #ifndef UTIL_COLLECTION_H
24 #define UTIL_COLLECTION_H
25 
26 
27 #include <QDir>
28 #include <QHash>
29 #include <QString>
30 #include <QStringList>
31 
32 #include "util_interface.h"
33 
35 public:
37  ~UtilCollection();
38 
39  /*
40  * All plugins loaded as utils in the collection
41  */
42  QHashIterator<QString, QObject*> plugins();
43 
44  /*
45  * List of commands for each util
46  */
47  QStringList command_list();
48 
49  /*
50  * Plugin corresponding to the give command
51  */
52  QObject* util(QString command);
53 
54  /*
55  * Add a plugin as a util to the collection
56  */
57  bool insert_util(QObject *util_obj);
58 
59  /*
60  * Test if the given command is recognized in the command list
61  */
62  bool has_command(QString commmand);
63 
64 protected:
65  QDir pluginsDir;
66  void loadPlugins();
67  bool populateUtil(QObject *plugin);
68 
69  QHash<QString, QObject*> util_hash;
70 };
71 
72 #endif // UTIL_COLLECTION_H
Definition: util_collection.h:34