/** * @file Common/registry.cpp * @brief Common registry implementation * @author Enar Vaikene * * Copyright (c) 2011 Enar Vaikene * * This file is part of the eVaf C++ cross-platform application development framework. * * This file can be used under the terms of the GNU General Public License * version 3.0 as published by the Free Software Foundation and appearing in * the file LICENSE included in the packaging of this file. Please review the * the following information to ensure the GNU General Public License version * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. * * Alternatively, this file may be used in accordance with the Commercial License * Agreement provided with the Software. */ #include "registry.h" #include "globals.h" #include "version.h" #include //------------------------------------------------------------------- using namespace eVaf::Common; iRegistry * iRegistry::instance() { static Internal::Registry singleton; return &singleton; } //------------------------------------------------------------------- using namespace eVaf::Common::Internal; Registry::Registry() : iRegistry() { setObjectName(QString("%1-iRegistry").arg(VER_MODULE_NAME_STR)); // Register our own interface registerInterface("iRegistry", this); } Registry::~Registry() { mInterfaces.clear(); } bool Registry::registerInterface(QString const & name, QObject * obj) { mInterfaces.insert(name, QWeakPointer(obj)); return true; } QObject * Registry::queryInterface(QString const & name) const { QHash >::const_iterator it = mInterfaces.constFind(name); return it != mInterfaces.constEnd() ? (*it).data() : 0; }