14 #ifndef BERRYISERVICELOCATOR_H_
15 #define BERRYISERVICELOCATOR_H_
62 const char* typeName = qobject_interface_iid<S*>();
63 if (typeName ==
nullptr)
65 BERRY_WARN <<
"Error getting service: Cannot get the interface id for type '" << Reflection::GetClassName<S>()
66 <<
"'. It is probably missing a Q_DECLARE_INTERFACE macro in its header.";
69 Object* obj = this->GetService(typeName);
70 S* service =
dynamic_cast<S*
>(obj);
71 if (obj !=
nullptr && service ==
nullptr)
73 BERRY_WARN <<
"Error getting service: Class '" << obj->
GetClassName() <<
"' cannot be cast to service interface "
74 <<
"'" << Reflection::GetClassName<S>() <<
"'";
94 return this->HasService(qobject_interface_iid<S*>());
Light weight base class for most BlueBerry classes.
virtual QString GetClassName() const
berryObjectMacro(berry::IServiceLocator, Object)
~IServiceLocator() override
virtual Object * GetService(const QString &api)=0
virtual bool HasService(const QString &api) const =0