+
+
+//--------------------------------------------------------------------
+template<class ImageType>
+void AnatomicalFeatureDatabase::
+SetImage(TagType tag, std::string f, typename ImageType::Pointer image, bool write)
+{
+ SetImageFilename(tag, f);
+ m_MapOfImage[tag] = &(*image);
+ // I add a reference count because the cache is not a smartpointer
+ image->SetReferenceCount(image->GetReferenceCount()+1);
+ if (write) {
+ writeImage<ImageType>(image, f);
+ }
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class ImageType>
+void AnatomicalFeatureDatabase::
+ReleaseImage(std::string tag)
+{
+ if (m_MapOfTag.find(tag) == m_MapOfTag.end()) {
+ clitkExceptionMacro("Could not find the tag <" << tag << "> of type Image Filename in the DB");
+ }
+ else {
+ typename ImageType::Pointer image = GetImage<ImageType>(tag);
+ image->SetReferenceCount(image->GetReferenceCount()-1);
+ m_MapOfImage.erase(tag);
+ }
+}
+//--------------------------------------------------------------------