7 #include "fwAtomsPatch/infos/log.hpp" 8 #include "fwAtomsPatch/helper/functions.hpp" 9 #include "fwAtomsPatch/helper/Object.hpp" 29 ::fwAtoms::Base::sptr value,
30 conditions::Abstract::sptr condition)
32 if(m_object->getAttributes().find(name) == m_object->getAttributes().end())
34 if(condition->test(value))
36 m_object->setAttribute(name, value);
37 fwAtomsPatchAddAttributeLogMacro(
"'" 44 fwAtomsPatchErrorLogMacro(
"Attribute '" + name +
"' already exists");
51 ::fwAtoms::Base::sptr value,
52 conditions::Abstract::sptr condition)
54 if(m_object->getAttributes().find(name) != m_object->getAttributes().end())
56 m_object->eraseAttribute(name);
57 fwAtomsPatchEraseAttributeLogMacro(
"'" 62 if(condition->test(value))
64 m_object->setAttribute(name, value);
65 fwAtomsPatchAddAttributeLogMacro(
"'" 74 conditions::Abstract::sptr condition)
76 ::fwAtoms::Object::AttributesType::const_iterator it = m_object->getAttributes().find(name);
78 if(it != m_object->getAttributes().end())
80 if(condition->test(it->second))
82 m_object->eraseAttribute(name);
83 fwAtomsPatchEraseAttributeLogMacro(
"'" 90 fwAtomsPatchErrorLogMacro(
"Missing attribute '" + name +
"'");
97 ::fwAtoms::Base::sptr newValue,
98 conditions::Abstract::sptr condition)
100 ::fwAtoms::Object::AttributesType::const_iterator cIt = m_object->getAttributes().find(name);
102 if(cIt != m_object->getAttributes().end())
104 fwAtomsPatchReplaceAttributeLogMacro(
"'" 108 if(condition->test(cIt->second, newValue))
110 m_object->setAttribute(name, newValue);
114 m_object->setAttribute(name, condition->getDefaultValue());
115 fwAtomsPatchOutOfRangeLogMacro(
"Value '" + name
116 +
"' is out of range, using default value : '" 117 + condition->getDefaultValue()->getString() +
"'");
122 fwAtomsPatchErrorLogMacro(
"Missing attribute '" + name +
"'");
129 conditions::Abstract::sptr condition)
131 ::fwAtoms::Object::AttributesType::const_iterator it = m_object->getAttributes().find(name);
133 if(it != m_object->getAttributes().end())
135 if(condition->test(it->second))
137 ::fwAtoms::Base::sptr base = m_object->getAttribute(name);
138 fwAtomsPatchEraseAttributeLogMacro(
"'" 141 fwAtomsPatchAddAttributeLogMacro(
"'" 144 m_object->setAttribute(newName, base);
145 m_object->eraseAttribute(name);
150 fwAtomsPatchErrorLogMacro(
"Missing attribute '" + name +
"'");
FWATOMSPATCH_API ~Object()
Destructor.
FWATOMSPATCH_API std::string getClassname(const ::fwAtoms::Object::sptr &obj)
Get classname of an object.
FWATOMSPATCH_API void renameAttribute(const std::string &name, const std::string &newName, conditions::Abstract::sptr condition=conditions::Abstract::New())
Renames an attribute.
FWATOMSPATCH_API void removeAttribute(const std::string &name, conditions::Abstract::sptr condition=conditions::Abstract::New())
Removes an attribute.
FWATOMSPATCH_API Object(::fwAtoms::Object::sptr metaObject)
Constructor.
Contains base functionalities used to transform objects from a version to another.
FWATOMSPATCH_API void replaceAttribute(const std::string &name,::fwAtoms::Base::sptr newValue, conditions::Abstract::sptr condition=conditions::Abstract::New())
Replaces an attribute.
FWATOMSPATCH_API::fwAtoms::Object::sptr getObject() const
Atom::Object getter.
FWATOMSPATCH_API void addAttribute(const std::string &name,::fwAtoms::Base::sptr value, conditions::Abstract::sptr condition=conditions::Abstract::New())
Adds a new attribute in the current object.
FWATOMSPATCH_API std::string getVersion(const ::fwAtoms::Object::sptr &obj)
Get version of an object.
FWATOMSPATCH_API void addOrReplaceAttribute(const std::string &name,::fwAtoms::Base::sptr value, conditions::Abstract::sptr condition=conditions::Abstract::New())
Adds or replaces an attribute in the current object.