fw4spl
fwDataTools::helper::Field Class Reference

Defines a helper to modify field on a fwData::Object and create a message notifying this modification. More...

#include <Field.hpp>

+ Collaboration diagram for fwDataTools::helper::Field:

Public Member Functions

FWDATATOOLS_API Field (::fwData::Object::sptr object)
 Constructor. Initialize parameters.
 
FWDATATOOLS_API ~Field ()
 Destructor. Call notify if changes has been made.
 
template<typename DATA_TYPE >
std::shared_ptr< DATA_TYPE > setDefaultField (const ::fwData::Object::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...
 
FWDATATOOLS_API void setField (const ::fwData::Object::FieldNameType &name,::fwData::Object::sptr obj)
 Register field with specified name. If the name does already exist, the matching field will be replaced. More...
 
FWDATATOOLS_API void setFields (const ::fwData::Object::FieldMapType &newFields)
 Replace the field map content.
 
FWDATATOOLS_API void removeField (const ::fwData::Object::FieldNameType &name)
 Removes field with specified name. More...
 
FWDATATOOLS_API void add (const ::fwData::Object::FieldNameType &_name,::fwData::Object::sptr _obj)
 Add a field in the object. More...
 
FWDATATOOLS_API void swap (const ::fwData::Object::FieldNameType &_name,::fwData::Object::sptr _obj)
 Replace a field in the object. More...
 
FWDATATOOLS_API void addOrSwap (const ::fwData::Object::FieldNameType &_name,::fwData::Object::sptr _obj)
 Add or replace a field in the object. More...
 
FWDATATOOLS_API void remove (const ::fwData::Object::FieldNameType &_name)
 Remove a field from the object. More...
 
FWDATATOOLS_API void clear ()
 Clear all fields in the object. More...
 
FWDATATOOLS_API void notify ()
 Send the built message and clear the internal maps.
 
template<typename DATA_TYPE >
std::shared_ptr< DATA_TYPE > setDefaultField (const fwData::Object::FieldNameType &name, std::shared_ptr< DATA_TYPE > defaultValue)
 

Protected Member Functions

FWDATATOOLS_API void buildMessage (const ::fwData::Object::FieldMapType &oldFields, const ::fwData::Object::FieldMapType &newFields)
 

Protected Attributes

::fwData::Object::FieldsContainerType m_addedFields
 Map of added objects, send on notify.
 
::fwData::Object::FieldsContainerType m_newChangedFields
 Map of new changed objects, send on notify.
 
::fwData::Object::FieldsContainerType m_oldChangedFields
 Map of old changed objects, send on notify.
 
::fwData::Object::FieldsContainerType m_removedFields
 Map of removed objects, send on notify.
 
::fwData::Object::wptr m_object
 Composite to add/remove/change objects.
 

Detailed Description

Defines a helper to modify field on a fwData::Object and create a message notifying this modification.

Definition at line 22 of file Field.hpp.

Member Function Documentation

void fwDataTools::helper::Field::add ( const ::fwData::Object::FieldNameType &  _name,
::fwData::Object::sptr  _obj 
)

Add a field in the object.

Parameters
[in]_namekey of the field.
[in]_objobject to add as a field
Exceptions
fwData::Exceptionif the field already exists Prepare the message to announce the modification.

Definition at line 66 of file Field.cpp.

References m_addedFields, m_object, and SLM_ASSERT.

Referenced by ctrlSelection::SManage::clear().

+ Here is the caller graph for this function:

void fwDataTools::helper::Field::addOrSwap ( const ::fwData::Object::FieldNameType &  _name,
::fwData::Object::sptr  _obj 
)

Add or replace a field in the object.

Parameters
[in]_namekey of the field.
[in]_objobject to add as a field

Prepare the message to announce the modification.

Definition at line 97 of file Field.cpp.

References m_addedFields, m_newChangedFields, m_object, m_oldChangedFields, and SLM_ASSERT.

Referenced by ctrlSelection::SManage::addOrSwap(), uiMedDataQt::editor::SModelSeriesList::onCurrentItemChanged(), and setField().

+ Here is the caller graph for this function:

void fwDataTools::helper::Field::clear ( )

Clear all fields in the object.

Prepare the message to announce the modification.

Definition at line 132 of file Field.cpp.

References m_object, m_removedFields, and SLM_ASSERT.

Referenced by ctrlSelection::SManage::clear().

+ Here is the caller graph for this function:

void fwDataTools::helper::Field::remove ( const ::fwData::Object::FieldNameType &  _name)

Remove a field from the object.

Parameters
[in]_namekey of the field.
Exceptions
fwData::Exceptionif the field does not exist.

Prepare the message to announce the modification.

Definition at line 118 of file Field.cpp.

References m_object, m_removedFields, and SLM_ASSERT.

Referenced by ctrlSelection::SManage::remove(), and ctrlSelection::SManage::removeIfPresent().

+ Here is the caller graph for this function:

void fwDataTools::helper::Field::removeField ( const ::fwData::Object::FieldNameType &  name)

Removes field with specified name.

Deprecated:
use remove() instead

Definition at line 59 of file Field.cpp.

template<typename DATA_TYPE >
std::shared_ptr< DATA_TYPE > fwDataTools::helper::Field::setDefaultField ( const ::fwData::Object::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.

Parameters
[in]nameField name
[in]defaultValuedefault return value if field was not found
Returns
pointer to corresponding field.
void fwDataTools::helper::Field::setField ( const ::fwData::Object::FieldNameType &  name,
::fwData::Object::sptr  obj 
)

Register field with specified name. If the name does already exist, the matching field will be replaced.

Definition at line 41 of file Field.cpp.

References addOrSwap().

Referenced by fwDataTools::helper::Image::createTransferFunctionPool(), ctrlSelection::SAddField::updating(), and uiMedDataQt::editor::SOrganTransformation::updating().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fwDataTools::helper::Field::swap ( const ::fwData::Object::FieldNameType &  _name,
::fwData::Object::sptr  _obj 
)

Replace a field in the object.

Parameters
[in]_namekey of the field.
[in]_objobject to add as a field
Exceptions
fwData::Exceptionif the field does not exist.

Prepare the message to announce the modification.

Definition at line 81 of file Field.cpp.

References m_newChangedFields, m_object, m_oldChangedFields, and SLM_ASSERT.

Referenced by ctrlSelection::SManage::swap().

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: