fw4spl
SShowArray.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 "Tuto16MultithreadConsole/SShowArray.hpp"
8 
9 #include <fwData/Array.hpp>
10 #include <fwData/mt/ObjectReadLock.hpp>
11 
12 #include <fwDataTools/helper/ArrayGetter.hpp>
13 
14 #include <fwServices/macros.hpp>
15 
16 #include <sstream>
17 
19 
21 {
22 
23 //------------------------------------------------------------------------------
24 
25 SShowArray::SShowArray() noexcept
26 {
27 }
28 
29 //------------------------------------------------------------------------------
30 
31 SShowArray::~SShowArray() noexcept
32 {
33 }
34 
35 //------------------------------------------------------------------------------
36 
38 {
39 }
40 
41 //------------------------------------------------------------------------------
42 
44 {
45 }
46 
47 //------------------------------------------------------------------------------
48 
50 {
51  ::fwData::Array::csptr array = this->getInput< ::fwData::Array >("array");
52  ::fwData::mt::ObjectReadLock readLock(array);
53  SLM_ASSERT("No array.", array);
54 
55  ::fwDataTools::helper::ArrayGetter arrayHelper(array);
56  const unsigned int* buffer = static_cast< const unsigned int* >( arrayHelper.getBuffer() );
57 
58  std::stringstream str;
59  std::ostream_iterator<unsigned int> coutIter(str, ", ");
60  std::copy(buffer, buffer+10, coutIter );
61  SLM_INFO("Buffer : " + str.str());
62 }
63 
64 //------------------------------------------------------------------------------
65 
67 {
68 }
69 
70 //------------------------------------------------------------------------------
71 
72 } // namespace Tuto16MultithreadConsole
virtual void starting() override
Do nothing.
Definition: SShowArray.cpp:37
virtual FWDATATOOLS_API const void * getBuffer() const
Getter for the array buffer.
Definition: ArrayGetter.cpp:30
A helper to lock object on read mode.
virtual void configuring() override
Do nothing.
Definition: SShowArray.cpp:66
Provides a way to manage a view on a multidimentionnal array.
Helper to manage array buffer. Lock the buffer before to modify it.
Definition: ArrayGetter.hpp:28
This interface defines control service API. Does nothing particularly, can be considered as a default...
Definition: IController.hpp:23
This service displays the array values in the log.
Definition: SShowArray.hpp:36
#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
virtual void stopping() override
Do nothing.
Definition: SShowArray.cpp:43
#define SLM_INFO(message)
Definition: spyLog.hpp:250
The namespace Tuto16MultithreadConsole contains services to run the Tuto16MultithreadConsole example...
virtual void updating() override
Display the array values.
Definition: SShowArray.cpp:49