fw4spl
ExecutableFactoryRegistrar.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
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/ExecutableFactoryRegistrar.hpp"
8 
9 #include "fwRuntime/Bundle.hpp"
10 #include "fwRuntime/Runtime.hpp"
11 
12 
13 
14 namespace fwRuntime
15 {
16 
17 
18 
19 ExecutableFactoryRegistrar::ExecutableFactoryRegistrar( std::shared_ptr< ExecutableFactory > factory )
20 {
21  // Pre-condition
22  SLM_ASSERT("No bundle bundle currently loaded", Bundle::getLoadingBundle() != 0 );
23 
24  // Retrieves the bundle that is currently loading.
25  std::shared_ptr< Bundle > loadingBundle( Bundle::getLoadingBundle() );
26  Runtime* runtime( Runtime::getDefault() );
27 
28  // Stores the factory into that bundle and the default runtime instance.
29  loadingBundle->addExecutableFactory( factory );
30  runtime->addExecutableFactory( factory );
31 }
32 
33 
34 
35 } // namespace fwRuntime
static FWRUNTIME_API Runtime * getDefault()
Retrieves the default runtime instance.
Definition: Runtime.cpp:286
Defines the runtime class.
Definition: Runtime.hpp:37
FWRUNTIME_API ExecutableFactoryRegistrar(std::shared_ptr< ExecutableFactory > factory)
Constructor.
Contains fwAtomsFilter::factory utilities.
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
#define SLM_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:308
FWRUNTIME_API void addExecutableFactory(std::shared_ptr< ExecutableFactory > factory)
Adds a new executable factory instance to the runtime system.
Definition: Runtime.cpp:147
static std::shared_ptr< Bundle > getLoadingBundle()
Retrieves the pointer to the bundle that is currently loading its dynamic libraries.
Definition: Bundle.cpp:37