8 #include "fwAtomsPatch/infos/log.hpp" 9 #include "fwAtomsPatch/IStructuralCreator.hpp" 10 #include "fwAtomsPatch/StructuralCreatorDB.hpp" 15 StructuralCreatorDB::sptr StructuralCreatorDB::s_default = std::make_shared<StructuralCreatorDB>();
19 VersionIDType key = std::make_pair(creator->getObjectClassname(), creator->getObjectVersion());
21 m_creators[key] = creator;
27 const std::string& version)
32 CreatorsType::const_iterator it = m_creators.find(key);
33 if(it != m_creators.end())
39 return ::fwAtomsPatch::IStructuralCreator::sptr();
47 ::fwAtomsPatch::IStructuralCreator::sptr creator = this->
getCreator( classname, version );
48 OSLM_ASSERT(
"object creator of type '"<< classname <<
"' and version '"<< version <<
"' not found", creator );
49 fwAtomsPatchInfoLogMacro(
"Create '" + classname +
"|" + version +
"'");
50 ::fwAtoms::Object::sptr obj = creator->create();
59 return m_creators.size();
FWATOMSPATCH_API std::shared_ptr< ::fwAtomsPatch::IStructuralCreator > getCreator(const std::string &classname, const std::string &version)
Retrieves creator to create data revision.
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Contains base functionalities used to transform objects from a version to another.
::boost::unique_lock< ReadWriteMutex > WriteLock
Defines a lock of write type for read/write mutex.
FWATOMSPATCH_API void registerCreator(std::shared_ptr< ::fwAtomsPatch::IStructuralCreator > creator)
Registers a new creator.
::boost::shared_lock< ReadWriteMutex > ReadLock
Defines a lock of read type for read/write mutex.
FWATOMSPATCH_API size_t size() const
Returns the number of creators.
FWATOMSPATCH_API std::shared_ptr< ::fwAtoms::Object > create(const std::string &classname, const std::string &version)
Creates a new object instance with given classname and version.
std::pair< std::string, std::string > VersionIDType
Typedef used to store the pair classname/version of a data structure.