fw4spl
Get.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwServices/op/Get.hpp"
8 
9 #include "fwServices/IService.hpp"
10 
11 #include <vector>
12 
13 namespace fwServices
14 {
15 
16 //------------------------------------------------------------------------------
17 
18 ::fwServices::IService::sptr get( ::fwData::Object::sptr obj, std::string serviceType )
19 {
20  FW_DEPRECATED_MSG("'fwServices::get(object, srvType)' is deprecated.", "20.0");
21 
22  ::fwServices::IService::sptr service;
23  auto services = ::fwServices::OSR::getServices( obj, serviceType );
24  OSLM_ASSERT("Service "<<serviceType<<" is not unique, registered "<<services.size()<<" times",
25  services.size() == 1);
26  return *services.begin();
27 }
28 
29 //------------------------------------------------------------------------------
30 
31 ::fwServices::IService::sptr get( std::string uid )
32 {
33  OSLM_ASSERT("service does not exist with uid "<<uid, ::fwTools::fwID::exist(uid ));
34  return ::fwServices::IService::dynamicCast( ::fwTools::fwID::getObject( uid ) );
35 }
36 
37 //------------------------------------------------------------------------------
38 
39 }
#define OSLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:310
static FWTOOLS_API bool exist(IDType _id)
Definition: fwID.cpp:33
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.
Definition: spyLog.hpp:360
static FWTOOLS_API std::shared_ptr< ::fwTools::Object > getObject(IDType requestID)
Retrieve the object attached to the given id. Return a null sptr if no correspondence exist...
Definition: fwID.cpp:117