fw4spl
BundleElement.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 "fwRuntime/BundleElement.hpp"
8 
9 #include "fwRuntime/Bundle.hpp"
10 
11 namespace fwRuntime
12 {
13 
15  m_bundle( Bundle::getLoadingBundle() ),
16  m_enable(true)
17 {
18  // Post-condition
19  SLM_ASSERT("bundle '" << m_bundle.lock()->getIdentifier() << "' not initialized", m_bundle.lock() != nullptr );
20 }
21 
22 //------------------------------------------------------------------------------
23 
24 BundleElement::BundleElement( std::shared_ptr< Bundle > bundle ) :
25  m_bundle( bundle ),
26  m_enable(true)
27 {
28  // Post-condition
29  SLM_ASSERT("bundle '" << m_bundle.lock()->getIdentifier() << "' not initialized", m_bundle.lock() != nullptr );
30 }
31 
32 //------------------------------------------------------------------------------
33 
34 std::shared_ptr<Bundle> BundleElement::getBundle() const
35 {
36  return m_bundle.lock();
37 }
38 
39 //------------------------------------------------------------------------------
40 
42 {
43  // Pre-condition.
44  SLM_ASSERT("bundle '" << m_bundle.lock()->getIdentifier() << "' not initialized", m_bundle.lock() != nullptr );
45  return m_bundle.lock()->isEnable() && m_enable;
46 }
47 
48 //------------------------------------------------------------------------------
49 
50 void BundleElement::setEnable(const bool enable)
51 {
52  m_enable = enable;
53 }
54 
55 } // namespace fwRuntime
FWRUNTIME_API void setEnable(const bool enable)
Set if the element is enabled or not.
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
BundleElement()
Constructor.
#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 std::shared_ptr< Bundle > getBundle() const
Retrieves the bundle that owns the extension.
Defines the bundle class.
Definition: Bundle.hpp:45
FWRUNTIME_API bool isEnable() const
Tells if the element is enabled or not.