8 #include "fwAtomsPatch/SemanticPatchDB.hpp" 9 #include "fwAtomsPatch/ISemanticPatch.hpp" 15 SemanticPatchDB::sptr SemanticPatchDB::s_default = std::make_shared<SemanticPatchDB>();
39 VersionIDType origin = std::make_pair(patch->getOriginClassname(), patch->getOriginVersion());
41 m_patches[origin].push_back(patch);
47 const std::string& context,
48 const std::string& originVersion,
49 const std::string& targetVersion,
50 const std::string& objOriginClassname,
51 const std::string& objOriginVersion)
const 53 VersionIDType origin = std::make_pair(objOriginClassname, objOriginVersion);
56 PatchesType::const_iterator it = m_patches.find(origin);
57 if(it != m_patches.end())
59 PatchVectorType::const_iterator itVec;
60 for(itVec = it->second.begin(); itVec != it->second.end(); ++itVec)
62 if((*itVec)->isApplicable(context, originVersion, targetVersion))
69 return ::fwAtomsPatch::ISemanticPatch::sptr();
77 return m_patches.size();
FWATOMSPATCH_API void registerPatch(std::shared_ptr< ::fwAtomsPatch::ISemanticPatch > patch)
Registers a new patch.
Contextual patch database. All contextual patches are stored in this database.
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.
std::pair< std::string, std::string > VersionIDType
Typedef used to store the pair type/version of a data structure.
::boost::shared_lock< ReadWriteMutex > ReadLock
Defines a lock of read type for read/write mutex.
FWATOMSPATCH_API std::shared_ptr< ::fwAtomsPatch::ISemanticPatch > getPatch(const std::string &context, const std::string &originVersion, const std::string &targetVersion, const std::string &objOriginClassname, const std::string &objOriginVersion) const
Retrieves a patch allowing to go to specified data type/version target.
FWATOMSPATCH_API SemanticPatchDB()
Constructor. Does nothing.
virtual FWATOMSPATCH_API ~SemanticPatchDB()
Destructor. Does nothing.
static FWATOMSPATCH_API SemanticPatchDB::sptr getDefault()
Return default instance of SemanticPatchDB.
FWATOMSPATCH_API size_t size() const
Returns the number of patches.