]> vaikene.ee Git - evaf/blob - src/libs/Common/registry.h
1046c485c798f8da67a8315d89a549306c7a39d0
[evaf] / src / libs / Common / registry.h
1 /**
2 * @file Common/registry.h
3 * @brief Common registry implementation
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
20 #ifndef __COMMON_REGISTRY_H
21 #define __COMMON_REGISTRY_H
22
23 #include "iregistry.h"
24
25 #include <QObject>
26 #include <QString>
27 #include <QPointer>
28 #include <QHash>
29
30 namespace eVaf {
31 namespace Common {
32 namespace Internal {
33
34 /**
35 * iRegistry interface implementation.
36 *
37 * This class implements the global registry for interfaces. Interfaces are stored in a QHash container
38 * and quarded with QPointer.
39 */
40 class Registry : public iRegistry
41 {
42 Q_OBJECT
43
44 public:
45
46 Registry();
47
48 virtual ~Registry();
49
50 /*
51 iRegistry interface
52 */
53
54 virtual bool registerInterface(QString const & name, QObject * obj);
55
56 virtual QObject * queryInterface(QString const & name) const;
57
58
59 private:
60
61 /// All the registered interfaces
62 QHash<QString, QPointer<QObject> > mInterfaces;
63
64 };
65
66 } // namespace eVaf::Common::Internal
67 } // namespace eVaf::Common
68 } // namespace eVaf
69
70 #endif // registry.h