diff Plugin/Plugin.cpp @ 58:b3259b9c6dfb

simplification
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 01 Aug 2015 19:54:12 +0200
parents 111689a2c177
children ab5218c18b7a
line wrap: on
line diff
--- a/Plugin/Plugin.cpp	Sat Aug 01 18:31:00 2015 +0200
+++ b/Plugin/Plugin.cpp	Sat Aug 01 19:54:12 2015 +0200
@@ -35,26 +35,30 @@
 class CacheContext
 {
 private:
-  std::auto_ptr<Orthanc::FilesystemStorage>  storage_;
-  std::auto_ptr<Orthanc::SQLite::Connection>  db_;
+  Orthanc::FilesystemStorage  storage_;
+  Orthanc::SQLite::Connection  db_;
+
   std::auto_ptr<OrthancPlugins::CacheManager>  cache_;
   std::auto_ptr<OrthancPlugins::CacheScheduler>  scheduler_;
 
 public:
-  CacheContext(const std::string& path)
+  CacheContext(const std::string& path) : storage_(path)
   {
     boost::filesystem::path p(path);
+    db_.Open((p / "cache.db").string());
 
-    storage_.reset(new Orthanc::FilesystemStorage(path));
-    db_.reset(new Orthanc::SQLite::Connection());
-    db_->Open((p / "cache.db").string());
-
-    cache_.reset(new OrthancPlugins::CacheManager(*db_, *storage_));
+    cache_.reset(new OrthancPlugins::CacheManager(db_, storage_));
     //cache_->SetSanityCheckEnabled(true);  // For debug
 
     scheduler_.reset(new OrthancPlugins::CacheScheduler(*cache_, 100));
   }
 
+  ~CacheContext()
+  {
+    scheduler_.reset(NULL);
+    cache_.reset(NULL);
+  }
+
   OrthancPlugins::CacheScheduler& GetScheduler()
   {
     return *scheduler_;