eVaf
iregistry.h
Go to the documentation of this file.
1 
20 #ifndef __COMMON_IREGISTRY_H
21 #define __COMMON_IREGISTRY_H
22 
23 #include "libcommon.h"
24 
25 #include <QObject>
26 #include <QString>
27 
28 namespace eVaf {
29 namespace Common {
30 
68 {
69  Q_OBJECT
70 
71 public:
72 
74  iRegistry() : QObject() {}
75 
77  virtual ~iRegistry() {}
78 
87  static iRegistry * instance();
88 
100  virtual bool registerInterface(QString const & name, QObject * obj) = 0;
101 
113  virtual QObject * queryInterface(QString const & name) const = 0;
114 
115 };
116 
117 } // namespace eVaf::Common
118 } // namespace eVaf
119 
136 template<typename T>
137 inline T * evafQueryInterface(QString const & name)
138 {
139  return qobject_cast<T *>(eVaf::Common::iRegistry::instance()->queryInterface(name));
140 }
141 
142 #endif // iregistry.h
#define COMMON_EXPORT
Definition: libcommon.h:27
virtual QObject * queryInterface(QString const &name) const =0
Returns the interface by its name.
iRegistry()
Interface constructor.
Definition: iregistry.h:74
T * evafQueryInterface(QString const &name)
Helper function for querying interfaces.
Definition: iregistry.h:137
Global eVaf namespace.
Definition: engine.h:37
Common registry for interfaces.
Definition: iregistry.h:67
virtual ~iRegistry()
Empty virtual destructor.
Definition: iregistry.h:77
static iRegistry * instance()
Returns the iRegistry interface instance.