9 #include "fwServices/config.hpp" 10 #include "fwServices/IService.hpp" 12 #include <fwCom/HasSignals.hpp> 14 #include <fwCore/LogicStamp.hpp> 15 #include <fwCore/mt/types.hpp> 17 #include <fwTools/Failed.hpp> 18 #include <fwTools/Object.hpp> 20 #include <boost/bimap.hpp> 21 #include <boost/bimap/multiset_of.hpp> 22 #include <boost/bimap/unordered_set_of.hpp> 23 #include <boost/static_assert.hpp> 24 #include <boost/type_traits.hpp> 27 #include <unordered_map> 58 typedef ::boost::bimaps::bimap<
59 ::boost::bimaps::multiset_of< ::fwData::Object::cwptr, std::owner_less< ::fwData::Object::cwptr > >,
60 ::boost::bimaps::multiset_of< ::fwServices::IService::sptr >
63 typedef std::set< CSPTR( ::fwData::Object ) > ObjectVectorType;
64 typedef std::set< SPTR( ::fwServices::IService ) > ServiceVectorType;
66 typedef std::map< ::fwServices::IService::KeyType, WPTR( ::fwData::Object )> ObjectMapType;
72 typedef ::fwCom::Signal< void (::fwData::Object::sptr, const std::string&) >
RegisterSignalType;
83 FWSERVICES_API std::string getRegistryInformation()
const;
95 FWSERVICES_API
void registerService( ::fwServices::IService::sptr service );
105 FWSERVICES_API
void registerService( ::fwData::Object::sptr
object, ::fwServices::IService::sptr service );
117 FWSERVICES_API
void registerService(::fwData::Object::sptr
object, const ::fwServices::IService::KeyType& objKey,
118 ::fwServices::IService::AccessType access,
119 ::fwServices::IService::sptr service);
130 FWSERVICES_API
void registerServiceInput(const ::fwData::Object::csptr&
object,
131 const ::fwServices::IService::KeyType& objKey,
132 const ::fwServices::IService::sptr& service);
141 FWSERVICES_API
void registerServiceOutput(::fwData::Object::sptr
object,
142 const ::fwServices::IService::KeyType& objKey,
143 ::fwServices::IService::sptr service);
157 FWSERVICES_API
void unregisterService( ::fwServices::IService::sptr service );
166 FWSERVICES_API
void unregisterService( const ::fwServices::IService::KeyType& objKey,
167 ::fwServices::IService::AccessType access,
168 ::fwServices::IService::sptr service );
176 FWSERVICES_API
void unregisterServiceOutput( const ::fwServices::IService::KeyType& objKey,
177 ::fwServices::IService::sptr service );
186 FWSERVICES_API
bool isRegistered( const ::fwServices::IService::KeyType& objKey,
187 ::fwServices::IService::AccessType access,
188 ::fwServices::IService::sptr service)
const;
197 FWSERVICES_API ::fwData::Object::csptr getRegistered(const ::fwServices::IService::KeyType& objKey,
198 ::fwServices::IService::AccessType access,
199 IService::sptr service)
const;
212 template<
class SERVICE>
213 std::set< SPTR(SERVICE) > getServices()
const;
219 template<
class SERVICE>
220 std::set< SPTR(SERVICE) > getServices(::fwData::Object::sptr obj)
const;
228 FWSERVICES_API ServiceVectorType getServices(
const std::string& serviceType )
const;
234 FWSERVICES_API ServiceVectorType getServices( ::fwData::Object::sptr obj,
const std::string& serviceType )
const;
240 FWSERVICES_API ServiceVectorType getServices( ::fwData::Object::sptr obj )
const;
245 template<
class SERVICE>
246 ObjectVectorType getObjects()
const;
251 FWSERVICES_API ObjectVectorType getObjects()
const;
266 FWSERVICES_API
bool has( ::fwData::Object::sptr obj,
const std::string& srvType)
const;
280 FWSERVICES_API
void swapService( ::fwData::Object::sptr objDst, ::fwServices::IService::sptr service );
293 mutable ::fwCore::mt::ReadWriteMutex m_containerMutex;
303 void internalRegisterService( ::fwData::Object::sptr obj, ::fwServices::IService::sptr service,
304 const ::fwServices::IService::KeyType& objKey,
305 ::fwServices::IService::AccessType access);
313 void internalRegisterServiceInput( const ::fwData::Object::csptr& obj, const ::fwServices::IService::sptr& service,
314 const ::fwServices::IService::KeyType& objKey);
321 void removeFromContainer( ::fwServices::IService::sptr service );
335 FWSERVICES_API ::fwServices::registry::ObjectService::sptr
get();
340 FWSERVICES_API ::fwServices::registry::ObjectService::ObjectVectorType
getObjects();
350 template<
class SERVICE>
356 template<
class SERVICE>
357 std::set< SPTR(SERVICE) > getServices(::fwData::Object::sptr obj);
362 FWSERVICES_API ::fwServices::registry::ObjectService::ServiceVectorType getServices(
const std::string& serviceType );
367 FWSERVICES_API ::fwServices::registry::ObjectService::ServiceVectorType getServices( ::fwData::Object::sptr obj,
368 const std::string& serviceType );
373 FWSERVICES_API ::fwServices::registry::ObjectService::ServiceVectorType getServices( ::fwData::Object::sptr obj );
382 FWSERVICES_API
bool has( ::fwData::Object::sptr obj,
const std::string& srvType);
389 FWSERVICES_API
void registerService( ::fwServices::IService::sptr service );
402 FWSERVICES_API
void registerService( ::fwData::Object::sptr obj, ::fwServices::IService::sptr service );
414 FWSERVICES_API
void registerService(::fwData::Object::sptr obj, const ::fwServices::IService::KeyType& objKey,
415 ::fwServices::IService::AccessType access, ::fwServices::IService::sptr service);
426 FWSERVICES_API
void registerServiceInput(::fwData::Object::csptr obj, const ::fwServices::IService::KeyType& objKey,
427 ::fwServices::IService::sptr service);
436 FWSERVICES_API
void registerServiceOutput(::fwData::Object::sptr obj, const ::fwServices::IService::KeyType& objKey,
437 ::fwServices::IService::sptr service);
443 FWSERVICES_API
void swapService( ::fwData::Object::sptr objDst, ::fwServices::IService::sptr service );
459 FWSERVICES_API
void unregisterService( const ::fwServices::IService::KeyType& objKey,
460 ::fwServices::IService::AccessType access,
461 ::fwServices::IService::sptr service );
470 ::fwServices::IService::sptr service );
479 FWSERVICES_API
bool isRegistered(const ::fwServices::IService::KeyType& objKey,
480 ::fwServices::IService::AccessType access,
481 ::fwServices::IService::sptr service);
490 FWSERVICES_API ::fwData::Object::csptr
getRegistered( const ::fwServices::IService::KeyType& objKey,
491 ::fwServices::IService::AccessType access,
492 ::fwServices::IService::sptr service );
501 #include "fwServices/registry/ObjectService.hxx"
Contains fwAtomsFilter::registry details.
#define fwCoreNonInstanciableClassDefinitionsMacro(_classinfo_)
Generate common code for Non Instanciable classes (Interfaces, Abstract classes, ...)
std::set< std::shared_ptr< SERVICE > > getServices()
Wraps ObjectService::getServices.
FWSERVICES_API void unregisterService(::fwServices::IService::sptr service)
Remove the service (service) from the m_container.
Base class for all FW4SPL's classes.
Namespace fwServices is dedicated to (mimic) the dynamic affectation of methods to (pure data) object...
FWSERVICES_API void unregisterServiceOutput(const ::fwServices::IService::KeyType &objKey,::fwServices::IService::sptr service)
Emit the signal 'unregistered'.
FWSERVICES_API void swapService(::fwData::Object::sptr objDst,::fwServices::IService::sptr service)
Wraps ObjectService::swapService.
FWSERVICES_API std::string getRegistryInformation()
Wraps ObjectService::getRegistryInformation.
maintain the relation between objects and services
FWSERVICES_API::fwServices::registry::ObjectService::ObjectVectorType getObjects()
Wraps ObjectService::getObjects.
FWSERVICES_API::fwData::Object::csptr getRegistered(const ::fwServices::IService::KeyType &objKey,::fwServices::IService::AccessType access,::fwServices::IService::sptr service)
Return the object pointer of a key of a given service.
static FWSERVICES_APIconst::fwCom::Signals::SignalKeyType s_REGISTERED_SIG
Type of signal m_sigRenderRequested.
FWSERVICES_API void registerService(::fwServices::IService::sptr service)
Register the service alone.
ServiceContainerType m_container
Object to service associations container.
static FWSERVICES_APIconst::fwCom::Signals::SignalKeyType s_UNREGISTERED_SIG
Type of signal m_sigRenderRequested.
#define fwCoreAllowSharedFromThis()
Generate getSptr and getConstSptr methods.
FWSERVICES_API void registerServiceOutput(::fwData::Object::sptr obj, const ::fwServices::IService::KeyType &objKey,::fwServices::IService::sptr service)
Emit the signal 'registered'.
Contains the representation of the data objects used in the framework.
FWSERVICES_API void registerServiceInput(::fwData::Object::csptr obj, const ::fwServices::IService::KeyType &objKey,::fwServices::IService::sptr service)
Register the service (service) for the input object (obj) at the given service key. It also updates IService::m_associatedObject of service to point to obj removal at obj destruction.
FWSERVICES_API bool isRegistered(const ::fwServices::IService::KeyType &objKey,::fwServices::IService::AccessType access,::fwServices::IService::sptr service)
Return true if a key is registered for a given service.
::boost::bimaps::bimap< ::boost::bimaps::multiset_of< ::fwData::Object::cwptr, std::owner_less< ::fwData::Object::cwptr > >,::boost::bimaps::multiset_of< ::fwServices::IService::sptr > > ServiceContainerType
Service container keeps relation between objects identifiers and attached services.
This class proposes a mapping between a SignalKeyType and a SignalBase.