7 #ifndef __FWDATA_VECTOR_HPP__ 8 #define __FWDATA_VECTOR_HPP__ 10 #include "fwData/config.hpp" 11 #include "fwData/factory/new.hpp" 12 #include "fwData/Object.hpp" 14 #include <fwCom/Signal.hpp> 15 #include <fwCom/Signals.hpp> 24 fwCampAutoDeclareDataMacro((
fwData)(Vector), FWDATA_API);
42 typedef std::vector< Object::sptr > ContainerType;
44 typedef ContainerType::value_type ValueType;
45 typedef ContainerType::reference ReferenceType;
46 typedef ContainerType::const_reference ConstReferenceType;
47 typedef ContainerType::iterator IteratorType;
48 typedef ContainerType::const_iterator ConstIteratorType;
49 typedef ContainerType::reverse_iterator ReverseIteratorType;
50 typedef ContainerType::const_reverse_iterator ConstReverseIteratorType;
51 typedef ContainerType::size_type SizeType;
60 FWDATA_API
virtual ~
Vector();
75 ConstIteratorType begin()
const;
76 ConstIteratorType end()
const;
78 ReverseIteratorType rbegin();
79 ReverseIteratorType rend();
80 ConstReverseIteratorType rbegin()
const;
81 ConstReverseIteratorType rend()
const;
84 SizeType size()
const;
86 ValueType front()
const;
87 ValueType back()
const;
89 ReferenceType operator[] ( size_type n );
90 ConstReferenceType operator[] ( size_type n )
const;
92 ReferenceType at ( SizeType n );
93 ConstReferenceType at ( SizeType n )
const;
98 ContainerType& getContainer();
99 const ContainerType& getContainer ()
const;
100 void setContainer (
const ContainerType& val);
104 FWDATA_API
void shallowCopy(
const Object::csptr& _source )
override;
107 FWDATA_API
void cachedDeepCopy(
const Object::csptr& _source, DeepCopyCacheType& cache)
override;
110 template<
class DATATYPE >
111 void setDataContainer(
const std::vector<
SPTR(DATATYPE) >& vec );
114 template<
class DATATYPE >
115 std::vector< SPTR(DATATYPE) > getDataContainer()
const;
134 ContainerType m_container;
141 return m_container.begin();
148 return m_container.end();
155 return m_container.begin();
162 return m_container.end();
169 return m_container.rbegin();
176 return m_container.rend();
183 return m_container.rbegin();
190 return m_container.rend();
197 return m_container.empty();
204 return m_container.size();
211 return m_container.front();
218 return m_container.back();
225 return this->m_container[n];
232 return this->m_container[n];
239 return m_container.at(n);
244 inline Vector::ConstReferenceType
Vector::at(Vector::SizeType n)
const 246 return m_container.at(n);
272 template<
class DATATYPE >
276 std::copy( vec.begin(), vec.end(), std::back_inserter(this->getContainer()) );
281 template<
class DATATYPE >
284 std::vector< SPTR(DATATYPE) > vec;
285 vec.reserve( this->size() );
286 SPTR(DATATYPE) castedData;
287 for(const ::fwData::Object::sptr& data : this->getContainer() )
289 castedData = std::dynamic_pointer_cast<DATATYPE>( data );
291 vec.push_back( castedData );
ContainerType::iterator iterator
void setContainer(const ContainerType &val)
get/set the vector of fwData::Object
std::vector< std::shared_ptr< DATATYPE > > getDataContainer() const
Method to get a std::vector from fwData::Vector.
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
ContainerType::const_iterator const_iterator
ContainerType::value_type value_type
::fwCom::Signal< void(ContainerType) > RemovedObjectsSignalType
Type of signal when objects are removed.
void setDataContainer(const std::vector< std::shared_ptr< DATATYPE > > &vec)
Method to initialize a fwData::Vector from a std::vector.
ContainerType::size_type size_type
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_OBJECTS_SIG
Type of signal when objects are added.
ReferenceType operator[](size_type n)
This class defines a vector of objects.
ContainerType::reverse_iterator reverse_iterator
ReverseIteratorType rbegin()
ReverseIteratorType rend()
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
Type demangler. Use Demangler class to get a demangled string for the type T.
Base class for each data object.
ReferenceType at(SizeType n)
ContainerType & getContainer()
get/set the vector of fwData::Object
Contains the representation of the data objects used in the framework.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_REMOVED_OBJECTS_SIG
Type of signal when objects are added.
ContainerType::const_reverse_iterator const_reverse_iterator