22 #ifndef USMODULECONTEXT_H_
23 #define USMODULECONTEXT_H_
27 #include "usListenerFunctors_p.h"
39 class ModuleContextPrivate;
234 InterfaceMap servicePointers = MakeInterfaceMap<S>(service);
235 return RegisterService(servicePointers, properties);
265 template<
class I1,
class I2,
class Impl>
268 InterfaceMap servicePointers = MakeInterfaceMap<I1, I2>(impl);
269 return RegisterService(servicePointers, properties);
294 template<
class I1,
class I2,
class I3,
class Impl>
297 InterfaceMap servicePointers = MakeInterfaceMap<I1, I2, I3>(impl);
298 return RegisterService(servicePointers, properties);
330 InterfaceMap servicePointers = MakeInterfaceMap<S>(factory);
331 return RegisterService(servicePointers, properties);
359 template<
class I1,
class I2>
362 InterfaceMap servicePointers = MakeInterfaceMap<I1,I2>(factory);
363 return RegisterService(servicePointers, properties);
388 template<
class I1,
class I2,
class I3>
391 InterfaceMap servicePointers = MakeInterfaceMap<I1,I2,I3>(factory);
392 return RegisterService(servicePointers, properties);
440 std::vector<ServiceReferenceU>
GetServiceReferences(
const std::string& clazz,
const std::string& filter = std::string());
468 std::string clazz = us_service_interface_iid<S>();
469 if (clazz.empty())
throw ServiceException(
"The service interface class has no US_DECLARE_SERVICE_INTERFACE macro");
470 typedef std::vector<ServiceReferenceU> BaseVectorT;
471 BaseVectorT serviceRefs = GetServiceReferences(clazz, filter);
472 std::vector<ServiceReference<S> > result;
473 for(BaseVectorT::const_iterator i = serviceRefs.begin(); i != serviceRefs.end(); ++i)
475 result.push_back(ServiceReference<S>(*i));
532 std::string clazz = us_service_interface_iid<S>();
533 if (clazz.empty())
throw ServiceException(
"The service interface class has no US_DECLARE_SERVICE_INTERFACE macro");
534 return ServiceReference<S>(GetServiceReference(clazz));
614 const ServiceReferenceBase& baseRef = reference;
615 return reinterpret_cast<S*
>(GetService(baseRef));
682 const std::string& filter = std::string());
740 const std::string& filter = std::string())
742 AddServiceListener(ServiceListenerMemberFunctor(receiver, callback),
743 static_cast<void*
>(receiver), filter);
764 RemoveServiceListener(ServiceListenerMemberFunctor(receiver, callback),
765 static_cast<void*
>(receiver));
788 AddModuleListener(ModuleListenerMemberFunctor(receiver, callback),
789 static_cast<void*
>(receiver));
810 RemoveModuleListener(ModuleListenerMemberFunctor(receiver, callback),
811 static_cast<void*
>(receiver));
831 friend class ModulePrivate;
840 const std::string& filter);
841 void RemoveServiceListener(
const ServiceListener& delegate,
void* data);
843 void AddModuleListener(
const ModuleListener& delegate,
void* data);
844 void RemoveModuleListener(
const ModuleListener& delegate,
void* data);
846 ModuleContextPrivate *
const d;
ServiceRegistration< S > RegisterService(S *service, const ServiceProperties &properties=ServiceProperties())
Module * GetModule(const std::string &name)
ServiceRegistration< I1, I2 > RegisterService(ServiceFactory *factory, const ServiceProperties &properties=ServiceProperties())
std::vector< Module * > GetModules() const
void RemoveServiceListener(R *receiver, void(R::*callback)(const ServiceEvent))
bool UngetService(const ServiceReferenceBase &reference)
InterfaceMap GetService(const ServiceReferenceU &reference)
void AddServiceListener(const ServiceListener &delegate, const std::string &filter=std::string())
void RemoveModuleListener(const ModuleListener &delegate)
ServiceRegistration< I1, I2, I3 > RegisterService(Impl *impl, const ServiceProperties &properties=ServiceProperties())
void RemoveModuleListener(R *receiver, void(R::*callback)(const ModuleEvent))
ServiceReference< S > GetServiceReference()
std::vector< ServiceReferenceU > GetServiceReferences(const std::string &clazz, const std::string &filter=std::string())
ServiceRegistration< I1, I2, I3 > RegisterService(ServiceFactory *factory, const ServiceProperties &properties=ServiceProperties())
ServiceRegistration< I1, I2 > RegisterService(Impl *impl, const ServiceProperties &properties=ServiceProperties())
void * GetService(const ServiceReferenceBase &reference)
void AddModuleListener(R *receiver, void(R::*callback)(const ModuleEvent))
ServiceRegistrationU RegisterService(const InterfaceMap &service, const ServiceProperties &properties=ServiceProperties())
S * GetService(const ServiceReference< S > &reference)
void AddModuleListener(const ModuleListener &delegate)
Module * GetModule(long id) const
ServiceObjects< S > GetServiceObjects(const ServiceReference< S > &reference)
ServiceRegistration< S > RegisterService(ServiceFactory *factory, const ServiceProperties &properties=ServiceProperties())
void AddServiceListener(R *receiver, void(R::*callback)(const ServiceEvent), const std::string &filter=std::string())
Module * GetModule() const
std::vector< ServiceReference< S > > GetServiceReferences(const std::string &filter=std::string())
void RemoveServiceListener(const ServiceListener &delegate)
std::string GetDataFile(const std::string &filename) const
ServiceReferenceU GetServiceReference(const std::string &clazz)
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
ServiceRegistration< void > ServiceRegistrationU
std::map< std::string, void * > InterfaceMap
ServiceReference< void > ServiceReferenceU
#define US_BEGIN_NAMESPACE
US_MODULE_LISTENER_FUNCTOR ModuleListener
US_BEGIN_NAMESPACE typedef US_SERVICE_LISTENER_FUNCTOR ServiceListener