fw4spl
Bundles/core/memory/src/memory/Plugin.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/utils/GenericExecutableFactoryRegistrar.hpp>
8 #include <fwRuntime/operations.hpp>
9 #include <fwRuntime/helper.hpp>
10 
11 #include <fwCore/base.hpp>
12 #include <fwTools/System.hpp>
13 
14 #include <fwMemory/BufferManager.hpp>
15 #include <fwMemory/policy/AlwaysDump.hpp>
16 #include <fwMemory/policy/BarrierDump.hpp>
17 #include <fwMemory/policy/NeverDump.hpp>
18 #include <fwMemory/policy/ValveDump.hpp>
19 
20 #include "memory/Plugin.hpp"
21 
22 namespace memory
23 {
24 
25 static ::fwRuntime::utils::GenericExecutableFactoryRegistrar<Plugin> registrar("memory::Plugin");
26 
27 Plugin::~Plugin() noexcept
28 {
29 }
30 
31 //------------------------------------------------------------------------------
32 
34 {
35  ::fwMemory::BufferManager::sptr manager = ::fwMemory::BufferManager::getDefault();
36 
37  const std::string modeKey = "loading_mode";
38 
39  if ( this->getBundle()->hasParameter(modeKey) )
40  {
41  ::fwCore::mt::WriteLock lock( manager->getMutex() );
42  std::string mode = this->getBundle()->getParameterValue(modeKey);
43  if (mode == "lazy")
44  {
45  manager->setLoadingMode(::fwMemory::BufferManager::LAZY);
46  SLM_INFO("Enabled lazy loading mode");
47  }
48  else if (mode == "direct")
49  {
50  manager->setLoadingMode(::fwMemory::BufferManager::DIRECT);
51  SLM_INFO("Enabled direct loading mode");
52  }
53  else
54  {
55  SLM_ERROR("Unknown loading mode : '" + mode + "'");
56  }
57  }
58 
59 }
60 
61 //------------------------------------------------------------------------------
62 
63 void Plugin::stop() noexcept
64 {
65 }
66 
67 //------------------------------------------------------------------------------
68 
69 } // namespace memory
static FWMEMORY_API BufferManager::sptr getDefault()
Returns the current BufferManager instance.
::boost::unique_lock< ReadWriteMutex > WriteLock
Defines a lock of write type for read/write mutex.
#define SLM_ERROR(message)
Definition: spyLog.hpp:272
void start()
Start method. (does nothing)
FWRUNTIME_API std::shared_ptr< Bundle > getBundle() const noexcept override
Retrieves the bundle the executable originates from.
void stop() noexcept
Stop method. (does nothing)
The namespace memory contains tools to manage memory. It is used for dump. It allows to define the bu...
#define SLM_INFO(message)
Definition: spyLog.hpp:250