fw4spl
|
Provides a way to manage a view on a multidimentionnal array. More...
#include <Array.hpp>
Public Types | |
typedef std::vector< size_t > | SizeType |
Array size type. | |
typedef std::vector< size_t > | OffsetType |
Offset type. | |
typedef OffsetType | IndexType |
Index type. | |
Public Types inherited from fwData::Object | |
typedef ::fwData::factory::Key | Key |
typedef std::string | FieldNameType |
typedef std::vector< FieldNameType > | FieldNameVectorType |
typedef ::std::unordered_map< FieldNameType,::fwData::Object::sptr > | FieldMapType |
typedef ::std::unordered_map< ::fwData::Object::csptr,::fwData::Object::sptr > | DeepCopyCacheType |
typedef ::fwCom::Signal< void() > | ModifiedSignalType |
Type of signal m_sigModified. | |
typedef std::map< std::string,::fwData::Object::sptr > | FieldsContainerType |
Type of signal m_sigModified. | |
typedef ::fwCom::Signal< void(FieldsContainerType) > | AddedFieldsSignalType |
Type of signal when objects are added. | |
typedef ::fwCom::Signal< void(FieldsContainerType, FieldsContainerType) > | ChangedFieldsSignalType |
Type of signal when objects are changed (newObjects, oldObjects) | |
typedef ::fwCom::Signal< void(FieldsContainerType) > | RemovedFieldsSignalType |
Type of signal when objects are removed. | |
Public Types inherited from fwCom::HasSignals | |
typedef std::shared_ptr< HasSignals > | sptr |
typedef std::shared_ptr< const HasSignals > | csptr |
Public Member Functions | |
virtual bool | isA (const std::string &type) const override |
FWDATA_API | Array (::fwData::Object::Key key) |
Constructor. More... | |
FWDATA_API void | cachedDeepCopy (const Object::csptr &_source, DeepCopyCacheType &cache) override |
Defines deep copy. | |
virtual FWDATA_API size_t | resize (const ::fwTools::Type &type, const SizeType &size, size_t nbOfComponents, bool reallocate=false) |
Resizes and allocate (if needed) the array. More... | |
virtual FWDATA_API size_t | resize (const std::string &type, const SizeType &size, size_t nbOfComponents, bool reallocate=false) |
Aliases to the resize method. | |
virtual FWDATA_API size_t | resize (const SizeType &size, size_t nbOfComponents, bool reallocate=false) |
virtual FWDATA_API size_t | resize (const SizeType &size, bool reallocate=false) |
virtual FWDATA_API void | clear () |
Clear this array. Size, type, nbOfComponents are reset, buffer is released. | |
virtual FWDATA_API bool | empty () const |
Test whether array is empty. More... | |
virtual FWDATA_API size_t | getElementSizeInBytes () const |
Get the size of one element of the array, ie. sizeof type * nbOfComponents. More... | |
virtual FWDATA_API size_t | getNumberOfElements () const |
Get the number of elements of type <getType()> in the array. More... | |
virtual FWDATA_API size_t | getSizeInBytes () const |
Getter for the array view size. More... | |
virtual FWDATA_API const SizeType & | getSize () const |
Getter for the array size. More... | |
virtual FWDATA_API const OffsetType & | getStrides () const |
Getter for the array strides. More... | |
virtual FWDATA_API void | setNumberOfComponents (size_t nb) |
Setter for array's number of components If the array has a buffer and owns it, the buffer will be reallocated. More... | |
virtual FWDATA_API size_t | getNumberOfComponents () const |
Getter for number of components. More... | |
virtual FWDATA_API size_t | getNumberOfDimensions () const |
Getter for number of dimensions, ie. getSize().size() More... | |
virtual FWDATA_API void | setIsBufferOwner (const bool own) |
Set array's buffer ownership. More... | |
virtual FWDATA_API bool | getIsBufferOwner () const |
Getter for array's buffer ownership. More... | |
virtual FWDATA_API void | setType (const std::string &type) |
Setter for array's type. More... | |
virtual FWDATA_API void | setType (const ::fwTools::Type &type) |
virtual FWDATA_API::fwTools::Type | getType () const |
Getter for array's type. More... | |
FWDATA_API size_t | getBufferOffset (const ::fwData::Array::IndexType &id, size_t component, size_t sizeOfType) const |
Compute offset in buffer for given parameters of type. More... | |
::fwMemory::BufferObject::sptr | getBufferObject () const |
void | setBufferObject (const ::fwMemory::BufferObject::sptr &val) |
FWDATA_API void | swap (Array::sptr _source) |
Exchanges the content of the Array with the content of _source. | |
Public Member Functions inherited from fwData::Object | |
FWDATA_API::fwData::Object::sptr | getField (const FieldNameType &name,::fwData::Object::sptr defaultValue=::fwData::Object::sptr()) const |
Returns a pointer of corresponding field (null if non exist). More... | |
template<typename DATA_TYPE > | |
std::shared_ptr< DATA_TYPE > | getField (const FieldNameType &name) const |
Returns a pointer of corresponding field. More... | |
template<typename DATA_TYPE > | |
std::shared_ptr< DATA_TYPE > | getField (const FieldNameType &name, std::shared_ptr< DATA_TYPE > defaultValue) const |
Returns a pointer of corresponding field. More... | |
template<typename DATA_TYPE > | |
std::shared_ptr< DATA_TYPE > | setDefaultField (const FieldNameType &name, std::shared_ptr< DATA_TYPE > defaultValue) |
Returns a pointer of corresponding field. If field did not exist, it is set to defaultValue if defaultValue is not null. More... | |
FWDATA_API::fwData::Object::csptr | getConstField (const FieldNameType &name) const |
Returns a pointer of corresponding field (null if non exist). More... | |
FWDATA_API const FieldMapType & | getFields () const |
Returns fields map. | |
FWDATA_API FieldNameVectorType | getFieldNames () const |
Returns vector of field names. | |
FWDATA_API void | setField (const FieldNameType &name,::fwData::Object::sptr obj) |
Register field with specified name. If the name does already exist, the matching field will be replaced. More... | |
FWDATA_API void | setFields (const FieldMapType &fieldMap) |
Replace the field map content. | |
FWDATA_API void | removeField (const FieldNameType &name) |
Removes field with specified name. More... | |
virtual FWDATA_API void | shallowCopy (const ::fwData::Object::csptr &source) |
A shallow copy of fields (objects in m_children) More... | |
FWDATA_API void | deepCopy (const ::fwData::Object::csptr &source) |
Make a deep copy from the source Calling this method may invalidate any DumpLock, RescursiveLock or helper on the object. Prefer using fwData::Object::copy instead. | |
FWDATA_API void | fieldShallowCopy (const ::fwData::Object::csptr &source) |
A shallow copy of fields (objects in m_children) More... | |
FWDATA_API void | fieldDeepCopy (const ::fwData::Object::csptr &source) |
A deep copy of fields (objects in m_children) More... | |
::fwCore::mt::ReadWriteMutex & | getMutex () const |
Returns the object's mutex. | |
Public Member Functions inherited from fwTools::Object | |
Public Member Functions inherited from fwCore::BaseObject | |
Public Member Functions inherited from fwCom::HasSignals | |
std::shared_ptr< SignalBase > | signal (const Signals::SignalKeyType &key) const |
template<typename SignalType > | |
std::shared_ptr< SignalType > | signal (const Signals::SignalKeyType &key) const |
template<typename SignalType > | |
std::shared_ptr< SignalType > | newSignal (const Signals::SignalKeyType &key) |
Static Public Member Functions | |
static bool | isTypeOf (const std::string &type) |
static FWDATA_API OffsetType | computeStrides (SizeType size, size_t nbOfComponents, size_t sizeOfType) |
Compute strides for given parameters. More... | |
Static Public Member Functions inherited from fwData::Object | |
static bool | isTypeOf (const std::string &type) |
static FWDATA_API::fwData::Object::sptr | copy (const ::fwData::Object::csptr &source) |
return a copy of the source. if source is a null pointer, return a null pointer. | |
template<typename DATA_TYPE > | |
static std::shared_ptr< DATA_TYPE > | copy (const std::shared_ptr< const DATA_TYPE > &source) |
return a copy of the source. if source is a null pointer, return a null pointer. | |
template<typename DATA_TYPE > | |
static std::shared_ptr< DATA_TYPE > | copy (const std::shared_ptr< DATA_TYPE > &source) |
return a copy of the source. if source is a null pointer, return a null pointer. | |
static const std::string & | classname () |
return full object's classname with its namespace, i.e. fwCore::BaseObject | |
Static Public Member Functions inherited from fwTools::Object | |
static bool | isTypeOf (const std::string &type) |
static const std::string & | classname () |
return full object's classname with its namespace, i.e. fwCore::BaseObject | |
Static Public Member Functions inherited from fwCore::BaseObject | |
static bool | isTypeOf (const std::string &type) |
static const std::string & | leafClassname () |
return object's classname without its namespace, i.e. BaseObject | |
static const std::string & | classname () |
return object's classname without its namespace, i.e. BaseObject | |
Protected Member Functions | |
Array (const Array &) | |
Not implemented. | |
const Array & | operator= (const Array &) |
Protected Member Functions inherited from fwData::Object | |
FWDATA_API void | fieldDeepCopy (const ::fwData::Object::csptr &source, DeepCopyCacheType &cache) |
Internal-use methods to implement Object's deepCopy. | |
virtual FWDATA_API void | cachedDeepCopy (const ::fwData::Object::csptr &source, DeepCopyCacheType &cache)=0 |
Internal-use methods to implement Object's deepCopy. | |
Protected Member Functions inherited from fwTools::fwID | |
FWTOOLS_API bool | hasID () const |
Return true if the object has an id set. More... | |
FWTOOLS_API IDType | getID (Policy policy=GENERATE) const |
Returns the id of the object. If it is not set and the policy value is. More... | |
virtual FWTOOLS_API void | setID (IDType newID) |
Set a newID for the object, (newID must not exist in fwID), the oldest one is released. More... | |
FWTOOLS_API void | resetID () |
Release the id for the object. More... | |
fwID () | |
Constructor : does nothing. | |
Protected Member Functions inherited from fwCom::HasSignals | |
HasSignals (const HasSignals &) | |
Copy constructor forbidden. | |
HasSignals & | operator= (const HasSignals &) |
Copy operator forbidden. | |
Protected Attributes | |
OffsetType | m_strides |
::fwTools::Type | m_type |
::fwMemory::BufferObject::sptr | m_bufferObject |
SizeType | m_size |
size_t | m_nbOfComponents |
bool | m_isBufferOwner |
Protected Attributes inherited from fwData::Object | |
FieldMapType | m_fields |
Fields. | |
mutable::fwCore::mt::ReadWriteMutex | m_mutex |
Mutex to protect object access. | |
Protected Attributes inherited from fwTools::Object | |
std::shared_ptr< ::fwTools::UUID > | m_uuid |
UUID used to identify the object, notably for serialization. | |
Protected Attributes inherited from fwCom::HasSignals | |
Signals | m_signals |
Friends | |
template<class , class , class > | |
class | ::fwTools::ClassFactory |
class | ::fwTools::Factory |
Demangling methods | |
virtual const std::string & | getLeafClassname () const override |
return object's classname without its namespace, i.e. BaseObject | |
virtual const std::string & | getClassname () const override |
return full object's classname with its namespace, i.e. fwCore::BaseObject | |
static const std::string & | leafClassname () |
return object's classname without its namespace, i.e. BaseObject | |
static const std::string & | classname () |
return object's classname without its namespace, i.e. BaseObject | |
Additional Inherited Members | |
Static Public Attributes inherited from fwData::Object | |
static FWDATA_APIconst::fwCom::Signals::SignalKeyType | s_MODIFIED_SIG = "modified" |
Key in m_signals map of signal m_sigModified. | |
static FWDATA_APIconst::fwCom::Signals::SignalKeyType | s_ADDED_FIELDS_SIG = "addedFields" |
Type of signal m_sigModified. | |
static FWDATA_APIconst::fwCom::Signals::SignalKeyType | s_CHANGED_FIELDS_SIG = "changedFields" |
Type of signal m_sigModified. | |
static FWDATA_APIconst::fwCom::Signals::SignalKeyType | s_REMOVED_FIELDS_SIG = "removedFields" |
Type of signal m_sigModified. | |
Protected Types inherited from fwTools::fwID | |
enum | Policy { EMPTY = 1, GENERATE, MUST_EXIST } |
typedef std::string | IDType |
Static Protected Member Functions inherited from fwData::Object | |
static FWDATA_API::fwData::Object::sptr | copy (const ::fwData::Object::csptr &source, DeepCopyCacheType &cache) |
Internal-use methods to implement Object's deepCopy. | |
template<typename DATA_TYPE > | |
static std::shared_ptr< DATA_TYPE > | copy (const std::shared_ptr< const DATA_TYPE > &source, DeepCopyCacheType &cache) |
Internal-use methods to implement Object's deepCopy. | |
template<typename DATA_TYPE > | |
static std::shared_ptr< DATA_TYPE > | copy (const std::shared_ptr< DATA_TYPE > &source, DeepCopyCacheType &cache) |
Internal-use methods to implement Object's deepCopy. | |
Static Protected Member Functions inherited from fwTools::fwID | |
static bool | isTypeOf (const std::string &type) |
static FWTOOLS_API bool | exist (IDType _id) |
static FWTOOLS_API std::shared_ptr< ::fwTools::Object > | getObject (IDType requestID) |
Retrieve the object attached to the given id. Return a null sptr if no correspondence exist. More... | |
static const std::string & | leafClassname () |
return object's classname without its namespace, i.e. BaseObject | |
static const std::string & | classname () |
return object's classname without its namespace, i.e. BaseObject | |
Provides a way to manage a view on a multidimentionnal array.
If the array own his buffer, it will perform the allocation, reallocation, destruction of the buffer. Else, this class will provide an array "view" of the buffer
Definition at line 32 of file include/fwData/Array.hpp.
fwData::Array::Array | ( | ::fwData::Object::Key | key | ) |
Constructor.
key | Private construction key |
Definition at line 54 of file src/fwData/Array.cpp.
References clear().
|
static |
Compute strides for given parameters.
size | Array size |
nbOfComponents | number of components |
sizeOfType | size of a component |
Definition at line 38 of file src/fwData/Array.cpp.
Referenced by resize().
|
virtual |
Test whether array is empty.
Definition at line 194 of file src/fwData/Array.cpp.
size_t fwData::Array::getBufferOffset | ( | const ::fwData::Array::IndexType & | id, |
size_t | component, | ||
size_t | sizeOfType | ||
) | const |
Compute offset in buffer for given parameters of type.
id | Item id |
component | Item component id |
sizeOfType | size of a component |
Definition at line 305 of file src/fwData/Array.cpp.
References OSLM_ASSERT.
|
virtual |
Get the size of one element of the array, ie. sizeof type * nbOfComponents.
Definition at line 201 of file src/fwData/Array.cpp.
References fwTools::Type::sizeOf().
|
virtual |
Getter for array's buffer ownership.
Definition at line 271 of file src/fwData/Array.cpp.
|
virtual |
Getter for number of components.
Definition at line 250 of file src/fwData/Array.cpp.
|
virtual |
Getter for number of dimensions, ie. getSize().size()
Definition at line 257 of file src/fwData/Array.cpp.
|
virtual |
Get the number of elements of type <getType()> in the array.
Definition at line 208 of file src/fwData/Array.cpp.
|
virtual |
Getter for the array size.
Definition at line 223 of file src/fwData/Array.cpp.
|
virtual |
Getter for the array view size.
Definition at line 215 of file src/fwData/Array.cpp.
References fwTools::Type::sizeOf().
|
virtual |
Getter for the array strides.
Definition at line 230 of file src/fwData/Array.cpp.
|
virtual |
|
virtual |
Resizes and allocate (if needed) the array.
If no buffer is allocated and reallocate is true, this method will allocate a buffer and take it ownership.
If the combination of type, size and components parameters do not match anymore the size of the previously allocated buffer, a reallocation is needed. In this case :
type | Type of the array view |
size | Size of the array view |
nbOfComponents | Number of components of the array view, Min value : 1 |
reallocate | If true, allow buffer reallocation |
fwData::Exception |
Definition at line 117 of file src/fwData/Array.cpp.
References computeStrides().
Referenced by cachedDeepCopy(), resize(), setNumberOfComponents(), and setType().
|
virtual |
Set array's buffer ownership.
own | New ownership value |
Definition at line 264 of file src/fwData/Array.cpp.
|
virtual |
Setter for array's number of components If the array has a buffer and owns it, the buffer will be reallocated.
nb | number of components |
Definition at line 237 of file src/fwData/Array.cpp.
References resize().
|
virtual |
Setter for array's type.
type | new array type |
Definition at line 278 of file src/fwData/Array.cpp.
References resize().