/** * @file Common/registry.h * @brief Common registry implementation * @author Enar Vaikene * * Copyright (c) 2011-2019 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. */ #ifndef __COMMON_REGISTRY_H #define __COMMON_REGISTRY_H #include "iregistry.h" #include #include #include namespace eVaf { namespace Common { namespace Internal { /** * iRegistry interface implementation. * * This class implements the global registry for interfaces. Interfaces are stored in a QHash container * and quarded with QWeakPointer. */ class Registry : public iRegistry { Q_OBJECT public: Registry(); virtual ~Registry(); /* iRegistry interface */ virtual bool registerInterface(QString const & name, QObject * obj); virtual QObject * queryInterface(QString const & name) const; private: /// All the registered interfaces typedef QHash Interfaces; Interfaces mInterfaces; private slots: /// Interface object destroyed /// We need to remove the interface from the list of registered interfaces void interfaceDestroyed(QObject * obj = nullptr); }; } // namespace eVaf::Common::Internal } // namespace eVaf::Common } // namespace eVaf #endif // registry.h