fw4spl
SReadArray.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/SReadArray.hpp"
8 
9 #include <fwCom/Signal.hxx>
10 
11 #include <fwData/Array.hpp>
12 #include <fwData/mt/ObjectWriteLock.hpp>
13 
14 #include <fwDataTools/helper/Array.hpp>
15 
16 #include <fwServices/macros.hpp>
17 
19 
21 {
22 
23 //------------------------------------------------------------------------------
24 
25 SReadArray::SReadArray() noexcept
26 {
27 }
28 
29 //------------------------------------------------------------------------------
30 
31 SReadArray::~SReadArray() noexcept
32 {
33 }
34 
35 //------------------------------------------------------------------------------
36 
38 {
39 }
40 
41 //------------------------------------------------------------------------------
42 
44 {
45 }
46 
47 //------------------------------------------------------------------------------
48 
50 {
51  ::fwData::Array::sptr array = this->getInOut< ::fwData::Array >("array");
52  ::fwData::mt::ObjectWriteLock writeLock(array);
53  SLM_ASSERT("No array.", array);
54 
55  // Initialize the array size and type
56  const int arraySize = 10;
57  ::fwData::Array::SizeType size(1, arraySize);
58  array->resize("uint32", size, 1, true);
59 
60  // Fill the array values
61  ::fwDataTools::helper::Array arrayHelper(array);
62  unsigned int* buffer = static_cast< unsigned int* >( arrayHelper.getBuffer() );
63  for (unsigned int i = 0; i < arraySize; i++)
64  {
65  buffer[i] = i;
66  }
67 
68  // Notify that the array is modified
69  ::fwData::Object::ModifiedSignalType::sptr sig
71  sig->asyncEmit();
72 }
73 
74 //------------------------------------------------------------------------------
75 
77 {
78 
79 }
80 
81 //------------------------------------------------------------------------------
82 
83 } // namespace Tuto16MultithreadConsole
virtual void configuring() override
Do nothing.
Definition: SReadArray.cpp:76
std::vector< size_t > SizeType
Array size type.
This service initializes a fwData::Array with 10 values (0 to 9).
Definition: SReadArray.hpp:30
virtual void stopping() override
Do nothing.
Definition: SReadArray.cpp:43
virtual FWDATATOOLS_API void * getBuffer()
Getter for the array buffer.
A helper to lock object on exclusive mode.
Provides a way to manage a view on a multidimentionnal array.
This interface defines control service API. Does nothing particularly, can be considered as a default...
Definition: IController.hpp:23
#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
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_MODIFIED_SIG
Key in m_signals map of signal m_sigModified.
virtual void updating() override
Initialize the current fwData::Array with 10 values (0 to 9).
Definition: SReadArray.cpp:49
The namespace Tuto16MultithreadConsole contains services to run the Tuto16MultithreadConsole example...
virtual void starting() override
Do nothing.
Definition: SReadArray.cpp:37
Helper to manage array buffer. Lock the buffer before to modify it.