fw4spl
Uninitializer.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
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 "fwRuntime/profile/Uninitializer.hpp"
8 
9 #include "fwRuntime/Bundle.hpp"
10 #include "fwRuntime/Runtime.hpp"
11 
12 #include <fwCore/base.hpp>
13 
14 namespace fwRuntime
15 {
16 
17 namespace profile
18 {
19 
20 //------------------------------------------------------------------------------
21 
22 Uninitializer::Uninitializer( const std::string& identifier, const Version& version ) :
23  m_identifier( identifier ),
24  m_version( version )
25 {
26 }
27 
28 //------------------------------------------------------------------------------
29 
31 {
32  std::shared_ptr< Bundle > bundle = Runtime::getDefault()->findEnabledBundle(m_identifier, m_version);
33  SLM_FATAL_IF("Unable to uninitialize bundle " + Bundle::getBundleStr(m_identifier, m_version) + ". Not found.",
34  bundle == 0);
35  try
36  {
37  bundle->uninitialize();
38  }
39  catch( const std::exception& e )
40  {
41  SLM_FATAL("Unable to uninitialize bundle " + Bundle::getBundleStr(m_identifier, m_version) + ". " + e.what());
42  }
43 }
44 
45 //------------------------------------------------------------------------------
46 
47 } // namespace profile
48 
49 } // namespace fwRuntime
static FWRUNTIME_API Runtime * getDefault()
Retrieves the default runtime instance.
Definition: Runtime.cpp:286
const std::string m_identifier
the bundle identifier
FWRUNTIME_API std::shared_ptr< Bundle > findEnabledBundle(const std::string &identifier, const Version &version=Version()) const
Retrieves the enabled bundle for the specified idenfier.
Definition: Runtime.cpp:270
FWRUNTIME_API Uninitializer(const std::string &identifier, const Version &version=Version())
Constructor.
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
#define SLM_FATAL(message)
Definition: spyLog.hpp:283
const Version m_version
the bundle version
#define SLM_FATAL_IF(message, cond)
Definition: spyLog.hpp:287
Holds version information for libraries and bundles.
void apply()
Applies the uninitializer on the bundle.