]> vaikene.ee Git - evaf/blob - src/libs/Common/registry.cpp
d93e469eaeea97185e39c9e61b7f9db0146fa261
[evaf] / src / libs / Common / registry.cpp
1 /**
2 * @file Common/registry.cpp
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 #include "registry.h"
21 #include "globals.h"
22 #include "version.h"
23
24 #include <QtCore>
25
26 //-------------------------------------------------------------------
27
28 using namespace eVaf::Common;
29
30 iRegistry * iRegistry::instance()
31 {
32 static Internal::Registry singleton;
33 return &singleton;
34 }
35
36
37 //-------------------------------------------------------------------
38
39 using namespace eVaf::Common::Internal;
40
41 Registry::Registry()
42 : iRegistry()
43 {
44 setObjectName(QString("%1-iRegistry").arg(VER_MODULE_NAME_STR));
45
46 // Register our own interface
47 registerInterface("iRegistry", this);
48 }
49
50 Registry::~Registry()
51 {
52 mInterfaces.clear();
53 }
54
55 bool Registry::registerInterface(QString const & name, QObject * obj)
56 {
57 mInterfaces.insert(name, QPointer<QObject>(obj));
58
59 return true;
60 }
61
62 QObject * Registry::queryInterface(QString const & name) const
63 {
64 QHash<QString, QPointer<QObject> >::const_iterator it = mInterfaces.constFind(name);
65 return it != mInterfaces.constEnd() ? *it : 0;
66 }