fw4spl
include/fwData/PointList.hpp
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 #pragma once
8 
9 #include "fwData/config.hpp"
10 #include "fwData/factory/new.hpp"
11 #include "fwData/Object.hpp"
12 #include "fwData/Point.hpp"
13 
14 #include <fwCom/Signal.hpp>
15 #include <fwCom/Signals.hpp>
16 
17 #include <vector>
18 
19 fwCampAutoDeclareDataMacro((fwData)(PointList), FWDATA_API);
20 
21 namespace fwData
22 {
27 class FWDATA_CLASS_API PointList : public Object
28 {
29 
30 public:
32  (()), ::fwData::factory::New< PointList >);
33 
34  fwCampMakeFriendDataMacro((fwData)(PointList));
35 
36  typedef std::vector< ::fwData::Point::sptr > PointListContainer;
37 
42  FWDATA_API PointList(::fwData::Object::Key _key);
46  FWDATA_API virtual ~PointList();
50  FWDATA_API void shallowCopy( const Object::csptr& _source ) override;
54  FWDATA_API void cachedDeepCopy(const Object::csptr& _source, DeepCopyCacheType& cache) override;
59  PointListContainer& getPoints ();
64  const PointListContainer& getPoints () const;
69  void setPoints (const PointListContainer& _vPoints);
74  void pushBack(const ::fwData::Point::sptr& _p);
79  void remove(size_t _index);
83  void clear();
84 
92  typedef ::fwCom::Signal< void (::fwData::Point::sptr) > PointAddedSignalType;
93  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_POINT_ADDED_SIG;
97  typedef ::fwCom::Signal< void (::fwData::Point::sptr) > PointRemovedSignalType;
98  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_POINT_REMOVED_SIG;
103 protected:
104 
108  PointListContainer m_vPoints;
109 
110 }; // end class PointList
111 
112 //-----------------------------------------------------------------------------
113 
114 inline PointList::PointListContainer& PointList::getPoints ()
115 {
116  return this->m_vPoints;
117 }
118 
119 //-----------------------------------------------------------------------------
120 
121 inline const PointList::PointListContainer& PointList::getPoints () const
122 {
123  return this->m_vPoints;
124 }
125 
126 //-----------------------------------------------------------------------------
127 
128 inline void PointList::setPoints (const PointList::PointListContainer& _vPoints)
129 {
130  this->m_vPoints = _vPoints;
131 }
132 
133 //-----------------------------------------------------------------------------
134 
135 inline void PointList::pushBack(const ::fwData::Point::sptr& _p)
136 {
137  this->m_vPoints.push_back(_p);
138 }
139 
140 //-----------------------------------------------------------------------------
141 
142 inline void PointList::remove(size_t _index)
143 {
144  const auto it = m_vPoints.begin() + static_cast<ptrdiff_t>(_index);
145  this->m_vPoints.erase(it);
146 }
147 
148 //-----------------------------------------------------------------------------
149 
150 inline void PointList::clear()
151 {
152  this->m_vPoints.clear();
153 }
154 
155 } // end namespace fwData
PointListContainer & getPoints()
Gets point vector.
void setPoints(const PointListContainer &_vPoints)
Sets point vector.
::fwCom::Signal< void(::fwData::Point::sptr) > PointAddedSignalType
Signal emitted when a Point is added.
PointListContainer m_vPoints
Points container.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_ADDED_SIG
Signal emitted when a Point is added.
void clear()
Clears the list.
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
void pushBack(const ::fwData::Point::sptr &_p)
Adds a fwData::Point in the pointlist.
::fwCom::Signal< void(::fwData::Point::sptr) > PointRemovedSignalType
Signal emitted when a Point is removed.
Base class for each data object.
This class defines a list of points.
Contains the representation of the data objects used in the framework.
void remove(size_t _index)
: Deletes a point at the specified index
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_REMOVED_SIG
Signal emitted when a Point is added.