9 #include "fwServices/IService.hpp" 10 #include "fwServices/registry/ObjectService.hpp" 11 #include "fwServices/registry/ServiceFactory.hpp" 18 template<
class SERVICE>
19 SPTR(SERVICE)
add( ::
fwData::Object::csptr _obj, const
std::
string& _implType, const
std::
string& _id)
21 FW_DEPRECATED_MSG(
"'fwServices::add(object, srvImpl[,uid])' is deprecated.",
"20.0");
25 auto const notConstObj = ::fwData::Object::constCast(_obj);
26 ::fwServices::IService::sptr service = ::fwServices::add( notConstObj, serviceType, _implType, _id );
27 SLM_ASSERT(
"Failed to add " + _implType, service );
28 SPTR(SERVICE) castedService = std::dynamic_pointer_cast< SERVICE >( service );
29 SLM_ASSERT(
"DynamicCast failed", castedService );
35 template<
class SERVICE>
38 ::fwServices::IService::sptr genericSrv = ::fwServices::add( _implType, _id );
39 auto srv = std::dynamic_pointer_cast< SERVICE >(genericSrv);
40 FW_RAISE_IF(
"Failed to cast service from factory type '" + _implType +
"' into '" +
Namespace fwServices is dedicated to (mimic) the dynamic affectation of methods to (pure data) object...
#define FW_DEPRECATED_MSG(message, version)
Use this macro when deprecating a function to warn the developer.
Type demangler. Use Demangler class to get a demangled string for the type T.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Contains the representation of the data objects used in the framework.
FWSERVICES_API::fwServices::IService::sptr add(::fwData::Object::sptr obj, const std::string &serviceType, const std::string &_implType, const std::string &_id="")
Create and attach to the object obj a service of type serviceType, implementation _implementationId w...