7 #include <boost/uuid/random_generator.hpp> 8 #include <boost/uuid/uuid_io.hpp> 10 #include "fwTools/UUID.hpp" 18 ::fwCore::mt::Mutex UUID::s_generateUUIDMutex;
32 UUID::UUIDContainer::iterator iter = UUID::s_uuidMap.find(m_uuid);
33 if( iter != UUID::s_uuidMap.end())
36 UUID::s_uuidMap.erase(iter);
45 return ( UUID::s_uuidMap.find(uuid) != UUID::s_uuidMap.end() );
50 const UUID::UUIDType&
UUID::get(::fwTools::Object::sptr
object)
54 UUID::sptr uuidObject =
object->m_uuid;
56 if(uuidObject->m_uuid.empty())
62 uuidObject->m_uuid = uuid;
66 UUID::s_uuidMap.insert(UUID::UUIDContainer::value_type(uuid,
object));
69 return uuidObject->m_uuid;
74 ::fwTools::Object::sptr
UUID::get(
const UUID::UUIDType & uuid )
77 ::fwTools::Object::sptr obj;
78 UUID::UUIDContainer::iterator iter = UUID::s_uuidMap.find(uuid);
79 if( iter != UUID::s_uuidMap.end() )
81 obj = iter->second.lock();
88 bool UUID::set(::fwTools::Object::sptr
object,
const UUID::UUIDType & uuid )
94 if(UUID::s_uuidMap.find(uuid) == UUID::s_uuidMap.end())
96 UUID::sptr uuidObject =
object->m_uuid;
100 uuidObject->m_uuid = uuid;
104 UUID::s_uuidMap.insert(UUID::UUIDContainer::value_type(uuid,
object));
116 static boost::uuids::random_generator gen;
117 ::fwCore::mt::ScopedLock lock(s_generateUUIDMutex);
118 ::boost::uuids::uuid uuid = gen();
119 return ::boost::uuids::to_string(uuid);
::boost::upgrade_lock< ReadWriteMutex > ReadToWriteLock
Defines an upgradable lock type for read/write mutex.
::boost::upgrade_to_unique_lock< ReadWriteMutex > UpgradeToWriteLock
Defines a write lock upgraded from ReadToWriteLock.
::boost::shared_mutex ReadWriteMutex
Defines a single writer, multiple readers mutex.
::boost::unique_lock< ReadWriteMutex > WriteLock
Defines a lock of write type for read/write mutex.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
::boost::shared_lock< ReadWriteMutex > ReadLock
Defines a lock of read type for read/write mutex.