13 #ifndef USMODULECONTEXT_H_
14 #define USMODULECONTEXT_H_
18 #include <usListenerFunctors_p.h>
30 class ModuleContextPrivate;
227 return RegisterService(servicePointers, properties);
257 template<
class I1,
class I2,
class Impl>
261 return RegisterService(servicePointers, properties);
286 template<
class I1,
class I2,
class I3,
class Impl>
290 return RegisterService(servicePointers, properties);
323 return RegisterService(servicePointers, properties);
351 template<
class I1,
class I2>
355 return RegisterService(servicePointers, properties);
380 template<
class I1,
class I2,
class I3>
384 return RegisterService(servicePointers, properties);
432 std::vector<ServiceReferenceU>
GetServiceReferences(
const std::string& clazz,
const std::string& filter = std::string());
460 std::string clazz = us_service_interface_iid<S>();
461 if (clazz.empty())
throw ServiceException(
"The service interface class has no US_DECLARE_SERVICE_INTERFACE macro");
462 typedef std::vector<ServiceReferenceU> BaseVectorT;
463 BaseVectorT serviceRefs = GetServiceReferences(clazz, filter);
464 std::vector<ServiceReference<S> > result;
465 for(BaseVectorT::const_iterator i = serviceRefs.begin(); i != serviceRefs.end(); ++i)
524 std::string clazz = us_service_interface_iid<S>();
525 if (clazz.empty())
throw ServiceException(
"The service interface class has no US_DECLARE_SERVICE_INTERFACE macro");
616 return reinterpret_cast<S*
>(GetService(baseRef));
692 const std::string& filter = std::string());
774 const std::string& filter = std::string())
776 AddServiceListener(ServiceListenerMemberFunctor(receiver, callback),
777 static_cast<void*
>(receiver), filter);
798 RemoveServiceListener(ServiceListenerMemberFunctor(receiver, callback),
799 static_cast<void*
>(receiver));
822 AddModuleListener(ModuleListenerMemberFunctor(receiver, callback),
823 static_cast<void*
>(receiver));
844 RemoveModuleListener(ModuleListenerMemberFunctor(receiver, callback),
845 static_cast<void*
>(receiver));
865 friend class ModulePrivate;
874 const std::string& filter);
875 void RemoveServiceListener(
const ServiceListener& delegate,
void* data);
877 void AddModuleListener(
const ModuleListener& delegate,
void* data);
878 void RemoveModuleListener(
const ModuleListener& delegate,
void* data);
880 ModuleContextPrivate *
const d;
#define MITKCPPMICROSERVICES_EXPORT
void * GetService(const ServiceReferenceBase &reference)
Returns the service object referenced by the specified ServiceReferenceBase object.
std::vector< ServiceReferenceU > GetServiceReferences(const std::string &clazz, const std::string &filter=std::string())
Returns a list of ServiceReference objects. The returned list contains services that were registered ...
ServiceReferenceU GetServiceReference(const std::string &clazz)
Returns a ServiceReference object for a service that implements and was registered under the specifie...
void RemoveServiceListener(const ServiceListener &delegate)
Removes the specified service listener from the context module's list of listeners.
void AddModuleListener(const ModuleListener &delegate)
Adds the specified module listener to the context module's list of listeners.
ServiceRegistration< I1, I2 > RegisterService(ServiceFactory *factory, const ServiceProperties &properties=ServiceProperties())
Registers the specified service factory as a service with the specified properties using the specifie...
Module * GetModule(const std::string &name)
Get the module that with the specified module name.
ServiceRegistration< S > RegisterService(S *service, const ServiceProperties &properties=ServiceProperties())
Registers the specified service object with the specified properties using the specified template arg...
ServiceRegistration< S > RegisterService(ServiceFactory *factory, const ServiceProperties &properties=ServiceProperties())
Registers the specified service factory as a service with the specified properties using the specifie...
void RemoveModuleListener(const ModuleListener &delegate)
Removes the specified module listener from the context module's list of listeners.
ServiceRegistration< I1, I2, I3 > RegisterService(Impl *impl, const ServiceProperties &properties=ServiceProperties())
Registers the specified service object with the specified properties using the specified template arg...
bool UngetService(const ServiceReferenceBase &reference)
Releases the service object referenced by the specified ServiceReference object. If the context modul...
ServiceRegistrationU RegisterService(const InterfaceMap &service, const ServiceProperties &properties=ServiceProperties())
Registers the specified service object with the specified properties under the specified class names ...
ServiceObjects< S > GetServiceObjects(const ServiceReference< S > &reference)
Returns the ServiceObjects object for the service referenced by the specified ServiceReference object...
void AddServiceListener(const ServiceListener &delegate, const std::string &filter=std::string())
Adds the specified service listener with the specified filter to the context module's list of listene...
ServiceReference< S > GetServiceReference()
Returns a ServiceReference object for a service that implements and was registered under the specifie...
~ModuleContext()
Destructor.
InterfaceMap GetService(const ServiceReferenceU &reference)
Returns the service interface map for the service referenced by the specified ServiceReferenceU objec...
ServiceRegistration< I1, I2, I3 > RegisterService(ServiceFactory *factory, const ServiceProperties &properties=ServiceProperties())
Registers the specified service factory as a service with the specified properties using the specifie...
S * GetService(const ServiceReference< S > &reference)
Returns the service object referenced by the specified ServiceReference object.
void RemoveModuleListener(R *receiver, void(R::*callback)(const ModuleEvent))
Removes the specified callback from the context module's list of listeners.
Module * GetModule() const
Returns the Module object associated with this ModuleContext. This module is called the context modul...
std::string GetDataFile(const std::string &filename) const
Get the absolute path for a file or directory in the persistent storage area provided for the module....
std::vector< ServiceReference< S > > GetServiceReferences(const std::string &filter=std::string())
Returns a list of ServiceReference objects. The returned list contains services that were registered ...
void RemoveServiceListener(R *receiver, void(R::*callback)(const ServiceEvent))
Removes the specified callback from the context module's list of listeners.
ServiceRegistration< I1, I2 > RegisterService(Impl *impl, const ServiceProperties &properties=ServiceProperties())
Registers the specified service object with the specified properties using the specified template arg...
void AddServiceListener(R *receiver, void(R::*callback)(const ServiceEvent), const std::string &filter=std::string())
Adds the specified callback with the specified filter to the context modules's list of listeners....
Module * GetModule(long id) const
Returns the module with the specified identifier.
void AddModuleListener(R *receiver, void(R::*callback)(const ModuleEvent))
Adds the specified callback to the context modules's list of listeners. Listeners are notified when a...
std::vector< Module * > GetModules() const
Returns a list of all known modules.
An event from the Micro Services framework describing a module lifecycle change.
Represents a CppMicroServices module.
Allows multiple service objects for a service to be obtained.
std::map< std::string, void * > InterfaceMap
A map containing interfaces ids and their corresponding service object pointers.
std::unordered_map< std::string, Any > ServiceProperties
US_MODULE_LISTENER_FUNCTOR ModuleListener
US_SERVICE_LISTENER_FUNCTOR ServiceListener
Helper class for constructing InterfaceMap instances based on service implementations or service fact...