8 #include "fwData/registry/macros.hpp" 9 #include "fwData/Exception.hpp" 10 #include "fwData/StructureTraitsDictionary.hpp" 12 #include <fwCore/base.hpp> 36 SLM_ASSERT(
"Structure of type '" + type +
"' not found",
37 m_structureTraitsMap.find(type) != m_structureTraitsMap.end());
38 return m_structureTraitsMap[type];
45 std::string type = structureTraits->getType();
47 std::string attachment = structureTraits->getAttachmentType();
49 FW_RAISE_IF(
"Structure of type '" << type <<
"' already exist",
50 m_structureTraitsMap.find(type) != m_structureTraitsMap.end());
52 FW_RAISE_IF(
"Structure of class '" << structClass <<
"' can not have attachment",
53 !(attachment.empty() || structClass == StructureTraits::LESION || structClass ==
54 StructureTraits::FUNCTIONAL) );
56 FW_RAISE_IF(
"Structure attachment '" << attachment <<
"' not found in dictionary",
57 !(attachment.empty() || m_structureTraitsMap.find(attachment) != m_structureTraitsMap.end() ) );
59 FW_RAISE_IF(
"Structure attachment '" << attachment <<
"' must be of class ORGAN",
60 !(attachment.empty() || m_structureTraitsMap[attachment]->getClass() == StructureTraits::ORGAN ) );
62 FW_RAISE_IF(
"Structure must have at least one category",
63 structureTraits->getCategories().empty());
65 FW_RAISE_IF(
"Wrong structure type '" << type<<
"', a type cannot contain space",
66 structureTraits->getType().find(
" ") != std::string::npos );
68 m_structureTraitsMap[type] = structureTraits;
75 StructureTypeNameContainer vectNames;
76 std::transform( m_structureTraitsMap.begin(), m_structureTraitsMap.end(),
77 std::back_inserter(vectNames),
78 std::bind(&StructureTraitsMapType::value_type::first, std::placeholders::_1) );
86 StructureTraitsDictionary::csptr other = StructureTraitsDictionary::dynamicConstCast(source);
88 "Unable to copy" + (source ? source->getClassname() : std::string(
"<NULL>"))
91 m_structureTraitsMap = other->m_structureTraitsMap;
98 StructureTraitsDictionary::csptr other = StructureTraitsDictionary::dynamicConstCast(source);
100 "Unable to copy" + (source ? source->getClassname() : std::string(
"<NULL>"))
103 m_structureTraitsMap.clear();
104 for(
const StructureTraitsMapType::value_type& elt : other->m_structureTraitsMap)
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Defines shallow copy.
virtual const std::string & getClassname() const override
return full object's classname with its namespace, i.e. fwCore::BaseObject
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
StructureClass
Defines structure class.
Implements data exception class.
FWDATA_API StructureTraitsDictionary(::fwData::Object::Key key)
Constructor.
This class defines a dictionary of structure traits.
FWDATA_API StructureTypeNameContainer getStructureTypeNames() const
Return all array names stock in the structureTraits-map.
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
FWDATA_API StructureTraits::sptr getStructure(std::string type)
Return the structure traits for given type.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
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.
virtual FWDATA_API ~StructureTraitsDictionary()
Destructor. Does nothing.
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
Contains the representation of the data objects used in the framework.
FWDATA_API void fieldShallowCopy(const ::fwData::Object::csptr &source)
A shallow copy of fields (objects in m_children)
FWDATA_API void addStructure(StructureTraits::sptr structureTraits)
Add a structure in dictionary.