22 #ifndef USMODULECONTEXT_H_
23 #define USMODULECONTEXT_H_
27 #include "usListenerFunctors_p.h"
39 class ModuleContextPrivate;
107 Module* GetModule()
const;
116 Module* GetModule(
long id)
const;
124 Module* GetModule(
const std::string& name);
136 std::vector<Module*> GetModules()
const;
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));
587 void* GetService(
const ServiceReferenceBase& reference);
614 const ServiceReferenceBase& baseRef = reference;
615 return reinterpret_cast<S*
>(GetService(baseRef));
679 bool UngetService(
const ServiceReferenceBase& reference);
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));
825 std::string GetDataFile(
const std::string&
filename)
const;
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< I1, I2 > RegisterService(ServiceFactory *factory, const ServiceProperties &properties=ServiceProperties())
ServiceReference< void > ServiceReferenceU
ServiceRegistration< I1, I2 > RegisterService(Impl *impl, const ServiceProperties &properties=ServiceProperties())
ServiceReference< S > GetServiceReference()
std::vector< ServiceReference< S > > GetServiceReferences(const std::string &filter=std::string())
std::map< std::string, void * > InterfaceMap
void AddServiceListener(R *receiver, void(R::*callback)(const ServiceEvent), const std::string &filter=std::string())
US_MODULE_LISTENER_FUNCTOR ModuleListener
S * GetService(const ServiceReference< S > &reference)
static const std::string filename
void RemoveServiceListener(R *receiver, void(R::*callback)(const ServiceEvent))
void AddModuleListener(R *receiver, void(R::*callback)(const ModuleEvent))
void RemoveModuleListener(R *receiver, void(R::*callback)(const ModuleEvent))
ServiceRegistration< void > ServiceRegistrationU
ServiceRegistration< S > RegisterService(S *service, const ServiceProperties &properties=ServiceProperties())
US_BEGIN_NAMESPACE typedef US_SERVICE_LISTENER_FUNCTOR ServiceListener
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
ServiceRegistration< I1, I2, I3 > RegisterService(ServiceFactory *factory, const ServiceProperties &properties=ServiceProperties())
ServiceRegistration< S > RegisterService(ServiceFactory *factory, const ServiceProperties &properties=ServiceProperties())
ServiceRegistration< I1, I2, I3 > RegisterService(Impl *impl, const ServiceProperties &properties=ServiceProperties())
ServiceObjects< S > GetServiceObjects(const ServiceReference< S > &reference)