fw4spl
SDumpAll.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
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 "monitor/action/SDumpAll.hpp"
8 
9 #include <fwCore/base.hpp>
10 
11 #include <fwGui/dialog/MessageDialog.hpp>
12 
13 #include <fwMemory/BufferManager.hpp>
14 #include <fwMemory/BufferInfo.hpp>
15 
16 #include <fwServices/macros.hpp>
17 
18 namespace monitor
19 {
20 namespace action
21 {
22 
23 fwServicesRegisterMacro( ::fwGui::IActionSrv, ::monitor::action::SDumpAll, ::fwData::Object );
24 
25 //------------------------------------------------------------------------------
26 
27 SDumpAll::SDumpAll( ) noexcept
28 {
29 }
30 
31 //------------------------------------------------------------------------------
32 
34 {
35 }
36 
37 //------------------------------------------------------------------------------
38 
40 {
41  size_t nbBuffDumped = 0;
42  ::fwMemory::BufferManager::BufferInfoMapType buffInfoMap;
43  ::fwMemory::BufferManager::sptr buffManager = ::fwMemory::BufferManager::getDefault();
44  if(buffManager)
45  {
46  buffInfoMap = buffManager->getBufferInfos().get();
47  }
48  for(::fwMemory::BufferManager::BufferInfoMapType::value_type elt : buffInfoMap)
49  {
50  ::fwMemory::BufferInfo dumpBuffInfo = elt.second;
51  bool loaded = dumpBuffInfo.loaded;
52  bool isLock = dumpBuffInfo.lockCount() > 0;
53  if(loaded && !isLock)
54  {
55  bool dumped = buffManager->dumpBuffer(elt.first).get();
56  if(dumped)
57  {
58  ++nbBuffDumped;
59  }
60  }
61  }
62  std::stringstream stream;
63  stream << nbBuffDumped << " buffer dumped (" << nbBuffDumped <<"/"<<buffInfoMap.size()<<").";
65  "Dump all",
66  stream.str(),
67  ::fwGui::dialog::IMessageDialog::INFO);
68 }
69 
70 //------------------------------------------------------------------------------
71 
73 {
75 }
76 
77 //------------------------------------------------------------------------------
78 
80 {
82 }
83 
84 //------------------------------------------------------------------------------
86 {
88 }
89 
90 //------------------------------------------------------------------------------
91 
92 } // namespace action
93 } // namespace monitor
FWGUI_API void actionServiceStarting()
Method called when the action service is starting.
Definition: IActionSrv.cpp:160
void updating() override
Dump all unlocked array/image etc.
Definition: SDumpAll.cpp:39
static FWGUI_API IMessageDialog::Buttons showMessageDialog(const std::string &title, const std::string &message,::fwGui::dialog::IMessageDialog::Icons icon=INFO)
static FWMEMORY_API BufferManager::sptr getDefault()
Returns the current BufferManager instance.
FWGUI_API void actionServiceStopping()
Method called when the action service is stopping.
Definition: IActionSrv.cpp:153
bool loaded
true if &#39;buffer&#39; is loaded
Definition: BufferInfo.hpp:42
Defines the service interface managing the menu items.
Definition: IActionSrv.hpp:24
void configuring() override
Calls classic IAction methods to configure.
Definition: SDumpAll.cpp:72
FWGUI_API void initialize()
Initialize the action.
Definition: IActionSrv.cpp:69
Base class for each data object.
void stopping() override
Calls classic IAction methods to stop.
Definition: SDumpAll.cpp:85
The namespace monitor contains tools for monitoring an application built with FW4SPL.
Definition: fwMetrics.hpp:14
void starting() override
Calls classic IAction methods to start.
Definition: SDumpAll.cpp:79
virtual MONITOR_API ~SDumpAll() noexcept
Does nothing.
Definition: SDumpAll.cpp:33
MONITOR_API SDumpAll() noexcept
Does nothing.
Implements an action that dump all buffer (if possible)
Definition: SDumpAll.hpp:20