fw4spl
|
Defines a helper to modify field on a fwData::Object and create a message notifying this modification. More...
#include <Field.hpp>
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. | |
Defines a helper to modify field on a fwData::Object and create a message notifying this modification.
void fwDataTools::helper::Field::add | ( | const ::fwData::Object::FieldNameType & | _name, |
::fwData::Object::sptr | _obj | ||
) |
Add a field in the object.
[in] | _name | key of the field. |
[in] | _obj | object to add as a field |
fwData::Exception | if 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().
void fwDataTools::helper::Field::addOrSwap | ( | const ::fwData::Object::FieldNameType & | _name, |
::fwData::Object::sptr | _obj | ||
) |
Add or replace a field in the object.
[in] | _name | key of the field. |
[in] | _obj | object 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().
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().
void fwDataTools::helper::Field::remove | ( | const ::fwData::Object::FieldNameType & | _name | ) |
Remove a field from the object.
[in] | _name | key of the field. |
fwData::Exception | if 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().
void fwDataTools::helper::Field::removeField | ( | const ::fwData::Object::FieldNameType & | name | ) |
Removes field with specified name.
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.
[in] | name | Field name |
[in] | defaultValue | default return value if field was not found |
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().
void fwDataTools::helper::Field::swap | ( | const ::fwData::Object::FieldNameType & | _name, |
::fwData::Object::sptr | _obj | ||
) |
Replace a field in the object.
[in] | _name | key of the field. |
[in] | _obj | object to add as a field |
fwData::Exception | if 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().