7 #include "fwAtomsPatch/helper/functions.hpp" 8 #include "fwAtomsPatch/types.hpp" 10 #include <fwTools/UUID.hpp> 21 return obj->getMetaInfo( ::fwAtomsPatch::s_OBJ_CLASSNAME );
26 void setClassname( const ::fwAtoms::Object::sptr & obj,
const std::string & newClassname )
28 obj->setMetaInfo( ::fwAtomsPatch::s_OBJ_CLASSNAME, newClassname );
33 std::string
getVersion( const ::fwAtoms::Object::sptr & obj )
35 return obj->getMetaInfo( ::fwAtomsPatch::s_OBJ_VERSION );
40 void setVersion( const ::fwAtoms::Object::sptr & obj,
const std::string & newVersion )
42 obj->setMetaInfo( ::fwAtomsPatch::s_OBJ_VERSION, newVersion );
56 obj->setAttribute(
"fields", ::fwAtoms::Map::New());
61 void changeUID( const ::fwAtoms::Object::sptr & obj )
63 for( const ::fwAtoms::Object::AttributesType::value_type& elem : obj->getAttributes() )
67 switch ( elem.second->type() )
69 case ::fwAtoms::Base::SEQUENCE:
71 changeSeqUID( ::fwAtoms::Sequence::dynamicCast( elem.second ) );
74 case ::fwAtoms::Base::MAP:
76 changeMapUID( ::fwAtoms::Map::dynamicCast( elem.second ) );
79 case ::fwAtoms::Base::OBJECT:
81 changeUID( ::fwAtoms::Object::dynamicCast( elem.second ) );
90 ::fwAtomsPatch::helper::generateID( obj );
97 for( ::fwAtoms::Map::ValueType elem : map->getValue() )
101 switch ( elem.second->type() )
103 case ::fwAtoms::Base::SEQUENCE:
105 changeSeqUID( ::fwAtoms::Sequence::dynamicCast( elem.second ) );
108 case ::fwAtoms::Base::MAP:
110 changeMapUID( ::fwAtoms::Map::dynamicCast( elem.second ) );
113 case ::fwAtoms::Base::OBJECT:
115 changeUID( ::fwAtoms::Object::dynamicCast( elem.second ) );
129 for( ::fwAtoms::Base::sptr elem : seq->getValue() )
133 switch ( elem->type() )
135 case ::fwAtoms::Base::SEQUENCE:
137 changeSeqUID( ::fwAtoms::Sequence::dynamicCast( elem ) );
140 case ::fwAtoms::Base::MAP:
145 case ::fwAtoms::Base::OBJECT:
147 changeUID( ::fwAtoms::Object::dynamicCast( elem ) );
FWATOMSPATCH_API void setVersion(const ::fwAtoms::Object::sptr &obj, const std::string &newVersion)
Set version of an object.
FWATOMSPATCH_API std::string getClassname(const ::fwAtoms::Object::sptr &obj)
Get classname of an object.
FWATOMSPATCH_API void cleanFields(const ::fwAtoms::Object::sptr &obj)
Cleans object fields (also creates them if they are missing)
FWATOMSPATCH_API void changeSeqUID(const ::fwAtoms::Sequence::sptr &seq)
Generates new UUID for seq objects and child objects.
FWATOMSPATCH_API void generateID(const ::fwAtoms::Object::sptr &obj)
Generates new id for the object (also creates it if it is missing )
Contains base functionalities used to transform objects from a version to another.
FWATOMSPATCH_API void changeMapUID(const ::fwAtoms::Map::sptr &map)
Generates new UUID for map objects and child objects.
FWATOMSPATCH_API void changeUID(const ::fwAtoms::Object::sptr &obj)
Generates new UUID for object and child objects.
FWATOMSPATCH_API std::string getVersion(const ::fwAtoms::Object::sptr &obj)
Get version of an object.
FWATOMSPATCH_API void setClassname(const ::fwAtoms::Object::sptr &obj, const std::string &newClassname)
Set classname of an object.