fw4spl
fwServices::registry::ObjectService Class Reference

maintain the relation between objects and services More...

#include <ObjectService.hpp>

+ Inheritance diagram for fwServices::registry::ObjectService:
+ Collaboration diagram for fwServices::registry::ObjectService:

Public Types

typedef ::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.
 
typedef std::set< std::shared_ptr< const ::fwData::Object > > ObjectVectorType
 
typedef std::set< std::shared_ptr< ::fwServices::IService > > ServiceVectorType
 
typedef std::map< ::fwServices::IService::KeyType, std::weak_ptr< ::fwData::Object > > ObjectMapType
 
- Public Types inherited from fwCom::HasSignals
typedef std::shared_ptr< HasSignalssptr
 
typedef std::shared_ptr< const HasSignalscsptr
 

Public Member Functions

virtual bool isA (const std::string &type) const override
 
FWSERVICES_API ObjectService ()
 Constructor.
 
FWSERVICES_API std::string getRegistryInformation () const
 Return some informations contain in the registry.
 
Management of registrations
FWSERVICES_API void registerService (::fwServices::IService::sptr service)
 Register the service alone. More...
 
FWSERVICES_API void registerService (::fwData::Object::sptr object,::fwServices::IService::sptr service)
 Register the service (service) for the object (obj) It also updates IService::m_associatedObject of service to point to obj removal at obj destruction. More...
 
FWSERVICES_API void registerService (::fwData::Object::sptr object, const ::fwServices::IService::KeyType &objKey,::fwServices::IService::AccessType access,::fwServices::IService::sptr service)
 Register the service (service) for the object (obj) at the given service key. It also updates IService::m_associatedObject of service to point to obj removal at obj destruction. More...
 
FWSERVICES_API void registerServiceInput (const ::fwData::Object::csptr &object, const ::fwServices::IService::KeyType &objKey, const ::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. More...
 
FWSERVICES_API void registerServiceOutput (::fwData::Object::sptr object, const ::fwServices::IService::KeyType &objKey,::fwServices::IService::sptr service)
 Emit the signal 'registered'. More...
 
Management of unregistrations
FWSERVICES_API void unregisterService (::fwServices::IService::sptr service)
 Remove the service (service) from the m_container. More...
 
FWSERVICES_API void unregisterService (const ::fwServices::IService::KeyType &objKey,::fwServices::IService::AccessType access,::fwServices::IService::sptr service)
 Remove an object key from a service. More...
 
FWSERVICES_API void unregisterServiceOutput (const ::fwServices::IService::KeyType &objKey,::fwServices::IService::sptr service)
 Emit the signal 'unregistered'. More...
 
FWSERVICES_API bool isRegistered (const ::fwServices::IService::KeyType &objKey,::fwServices::IService::AccessType access,::fwServices::IService::sptr service) const
 Return true if a key is registered for a given service. More...
 
FWSERVICES_API::fwData::Object::csptr getRegistered (const ::fwServices::IService::KeyType &objKey,::fwServices::IService::AccessType access, IService::sptr service) const
 Return the object pointer of a key of a given service. More...
 
Some useful getters
template<class SERVICE >
std::set< std::shared_ptr< SERVICE > > getServices () const
 Return a container with all services of type SERVICE registered in m_container. More...
 
template<class SERVICE >
std::set< std::shared_ptr< SERVICE > > getServices (::fwData::Object::sptr obj) const
 Return a container with all services of type SERVICE associated to obj in m_container. More...
 
FWSERVICES_API ServiceVectorType getServices (const std::string &serviceType) const
 Return registered services matching serviceType. More...
 
FWSERVICES_API ServiceVectorType getServices (::fwData::Object::sptr obj, const std::string &serviceType) const
 Return a container of services of type serviceType which are attached to obj. More...
 
FWSERVICES_API ServiceVectorType getServices (::fwData::Object::sptr obj) const
 return a vector containing all services associated with the object obj More...
 
template<class SERVICE >
ObjectVectorType getObjects () const
 Return a container with all objects associated with a service of type SERVICE in m_container.
 
FWSERVICES_API ObjectVectorType getObjects () const
 Return a container with all objects registered in m_container.
 
FWSERVICES_API bool has (::fwData::Object::sptr obj, const std::string &srvType) const
 return true if the object has at least one service of type srvType More...
 
Misc.
FWSERVICES_API void swapService (::fwData::Object::sptr objDst,::fwServices::IService::sptr service)
 Move service (service) to object objDst in the m_container. More...
 
- Public Member Functions inherited from fwCore::BaseObject
virtual const std::string & getLeafClassname () const
 return object's classname without its namespace, i.e. BaseObject
 
- Public Member Functions inherited from fwCom::HasSignals
std::shared_ptr< SignalBasesignal (const Signals::SignalKeyType &key) const
 
template<typename SignalType >
std::shared_ptr< SignalType > signal (const Signals::SignalKeyType &key) const
 
template<typename SignalType >
std::shared_ptr< SignalType > newSignal (const Signals::SignalKeyType &key)
 

Static Public Member Functions

static bool isTypeOf (const std::string &type)
 
- Static Public Member Functions inherited from fwCore::BaseObject
static bool isTypeOf (const std::string &type)
 
static const std::string & leafClassname ()
 return object's classname without its namespace, i.e. BaseObject
 
static const std::string & classname ()
 return object's classname without its namespace, i.e. BaseObject
 

Protected Attributes

ServiceContainerType m_container
 Object to service associations container. More...
 
mutable::fwCore::mt::ReadWriteMutex m_containerMutex
 
- Protected Attributes inherited from fwCom::HasSignals
Signals m_signals
 

Demangling methods

virtual const std::string & getClassname () const override
 return full object's classname with its namespace, i.e. fwCore::BaseObject
 
static const std::string & classname ()
 return full object's classname with its namespace, i.e. fwCore::BaseObject
 

Signals API

typedef ::fwCom::Signal< void(::fwData::Object::sptr, const std::string &) > RegisterSignalType
 Type of signal m_sigRenderRequested.
 
static FWSERVICES_APIconst::fwCom::Signals::SignalKeyType s_REGISTERED_SIG = "registered"
 Type of signal m_sigRenderRequested.
 
static FWSERVICES_APIconst::fwCom::Signals::SignalKeyType s_UNREGISTERED_SIG = "unregistered"
 Type of signal m_sigRenderRequested.
 

Additional Inherited Members

- Protected Member Functions inherited from fwCom::HasSignals
 HasSignals (const HasSignals &)
 Copy constructor forbidden.
 
HasSignalsoperator= (const HasSignals &)
 Copy operator forbidden.
 

Detailed Description

maintain the relation between objects and services

The API of ObjectService should not be directly invoked, fwServices/op methods (i.e. add, get,...) should be used instead

Definition at line 46 of file ObjectService.hpp.

Member Function Documentation

fwData::Object::csptr fwServices::registry::ObjectService::getRegistered ( const ::fwServices::IService::KeyType &  objKey,
::fwServices::IService::AccessType  access,
IService::sptr  service 
) const

Return the object pointer of a key of a given service.

Parameters
objKeyKey of the object
accessAccess (INPUT, INOUT, OUTPUT) of this key
serviceService where to look for the key

Definition at line 411 of file ObjectService.cpp.

References OSLM_ASSERT, SLM_ASSERT, and SLM_TRACE_FUNC.

template<class SERVICE >
std::set< std::shared_ptr< SERVICE > > fwServices::registry::ObjectService::getServices ( ) const

Return a container with all services of type SERVICE registered in m_container.

Note
Services may be associated to different object

Definition at line 61 of file ObjectService.hxx.

References SLM_DEBUG_IF, and SPTR.

template<class SERVICE >
std::set< std::shared_ptr< SERVICE > > fwServices::registry::ObjectService::getServices ( ::fwData::Object::sptr  obj) const

Return a container with all services of type SERVICE associated to obj in m_container.

Deprecated:
This method will be removed in 20.0

Definition at line 80 of file ObjectService.hxx.

References FW_DEPRECATED_MSG, and SPTR.

ObjectService::ServiceVectorType fwServices::registry::ObjectService::getServices ( const std::string &  serviceType) const

Return registered services matching serviceType.

Note
Should be optimized
Invoke getServices( ::fwData::Object::sptr , const std::string & ) for each registered object

Definition at line 557 of file ObjectService.cpp.

References SLM_DEBUG_IF.

ObjectService::ServiceVectorType fwServices::registry::ObjectService::getServices ( ::fwData::Object::sptr  obj,
const std::string &  serviceType 
) const

Return a container of services of type serviceType which are attached to obj.

Deprecated:
This method will be removed in 20.0

Definition at line 536 of file ObjectService.cpp.

References FW_DEPRECATED_MSG, and fwServices::OSR::getServices().

+ Here is the call graph for this function:

ObjectService::ServiceVectorType fwServices::registry::ObjectService::getServices ( ::fwData::Object::sptr  obj) const

return a vector containing all services associated with the object obj

Deprecated:
This method will be removed in 20.0

Definition at line 576 of file ObjectService.cpp.

References FW_DEPRECATED_MSG.

bool fwServices::registry::ObjectService::has ( ::fwData::Object::sptr  obj,
const std::string &  srvType 
) const

return true if the object has at least one service of type srvType

Parameters
objObject to add to the OSR
srvTypeType of the service

Definition at line 596 of file ObjectService.cpp.

References FW_DEPRECATED_MSG.

bool fwServices::registry::ObjectService::isRegistered ( const ::fwServices::IService::KeyType &  objKey,
::fwServices::IService::AccessType  access,
::fwServices::IService::sptr  service 
) const

Return true if a key is registered for a given service.

Parameters
objKeyKey of the object
accessAccess (INPUT, INOUT, OUTPUT) of this key
serviceService where to look for the key

Definition at line 390 of file ObjectService.cpp.

void fwServices::registry::ObjectService::registerService ( ::fwServices::IService::sptr  service)

Register the service alone.

Parameters
serviceService to add to the OSR

Definition at line 213 of file ObjectService.cpp.

void fwServices::registry::ObjectService::registerService ( ::fwData::Object::sptr  object,
::fwServices::IService::sptr  service 
)

Register the service (service) for the object (obj) It also updates IService::m_associatedObject of service to point to obj removal at obj destruction.

Parameters
objectObject to register
serviceService whose key should be added

Definition at line 221 of file ObjectService.cpp.

References FW_DEPRECATED_MSG.

void fwServices::registry::ObjectService::registerService ( ::fwData::Object::sptr  object,
const ::fwServices::IService::KeyType &  objKey,
::fwServices::IService::AccessType  access,
::fwServices::IService::sptr  service 
)

Register the service (service) for the object (obj) at the given service key. It also updates IService::m_associatedObject of service to point to obj removal at obj destruction.

Parameters
objectObject to register
objKeyKey of the object
accessAccess (INPUT, INOUT, OUTPUT) of this key
serviceService whose key should be added

Definition at line 232 of file ObjectService.cpp.

void fwServices::registry::ObjectService::registerServiceInput ( const ::fwData::Object::csptr &  object,
const ::fwServices::IService::KeyType &  objKey,
const ::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.

Parameters
objectObject to register
objKeyKey of the object
serviceService whose key should be added

Definition at line 241 of file ObjectService.cpp.

void fwServices::registry::ObjectService::registerServiceOutput ( ::fwData::Object::sptr  object,
const ::fwServices::IService::KeyType &  objKey,
::fwServices::IService::sptr  service 
)

Emit the signal 'registered'.

Parameters
objectObject to register
objKeyKey of the object
serviceService whose key should be added

Definition at line 251 of file ObjectService.cpp.

References OSLM_DEBUG_IF.

void fwServices::registry::ObjectService::swapService ( ::fwData::Object::sptr  objDst,
::fwServices::IService::sptr  service 
)

Move service (service) to object objDst in the m_container.

Deprecated:
Use service->swapKey(key, object)

Definition at line 270 of file ObjectService.cpp.

References FW_DEPRECATED_MSG, and OSLM_ASSERT.

void fwServices::registry::ObjectService::unregisterService ( ::fwServices::IService::sptr  service)

Remove the service (service) from the m_container.

Parameters
serviceService whose key should be removed

Definition at line 288 of file ObjectService.cpp.

References SLM_ASSERT.

void fwServices::registry::ObjectService::unregisterService ( const ::fwServices::IService::KeyType &  objKey,
::fwServices::IService::AccessType  access,
::fwServices::IService::sptr  service 
)

Remove an object key from a service.

Parameters
objKeyKey of the object
accessAccess (INPUT, INOUT, OUTPUT) of this key
serviceService whose key should be removed

Definition at line 303 of file ObjectService.cpp.

References SLM_ASSERT.

void fwServices::registry::ObjectService::unregisterServiceOutput ( const ::fwServices::IService::KeyType &  objKey,
::fwServices::IService::sptr  service 
)

Emit the signal 'unregistered'.

Parameters
objKeyKey of the object
serviceService whose key should be removed

Definition at line 374 of file ObjectService.cpp.

Member Data Documentation

ServiceContainerType fwServices::registry::ObjectService::m_container
protected

Object to service associations container.

Note
An object can be registered without services
Warning
Do not use smart pointers for fwData::Object, otherwise they will never destroy

Definition at line 291 of file ObjectService.hpp.


The documentation for this class was generated from the following files: