changeset 58:b3259b9c6dfb

simplification
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 01 Aug 2015 19:54:12 +0200
parents 26a230647a73
children 733d1a162baf
files Orthanc/Core/SQLite/Connection.cpp Orthanc/Core/SQLite/FunctionContext.cpp Orthanc/Core/SQLite/Statement.cpp Plugin/Plugin.cpp
diffstat 4 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Orthanc/Core/SQLite/Connection.cpp	Sat Aug 01 18:31:00 2015 +0200
+++ b/Orthanc/Core/SQLite/Connection.cpp	Sat Aug 01 19:54:12 2015 +0200
@@ -44,13 +44,14 @@
 
 #include <memory>
 #include <cassert>
-#include <sqlite3.h>
 #include <string.h>
 
 #if ORTHANC_SQLITE_STANDALONE != 1
 #include <glog/logging.h>
 #endif
 
+#include "sqlite3.h"
+
 
 namespace Orthanc
 {
--- a/Orthanc/Core/SQLite/FunctionContext.cpp	Sat Aug 01 18:31:00 2015 +0200
+++ b/Orthanc/Core/SQLite/FunctionContext.cpp	Sat Aug 01 19:54:12 2015 +0200
@@ -39,9 +39,10 @@
 #include "FunctionContext.h"
 #include "OrthancSQLiteException.h"
 
-#include <sqlite3.h>
 #include <string>
 
+#include "sqlite3.h"
+
 namespace Orthanc
 {
   namespace SQLite
--- a/Orthanc/Core/SQLite/Statement.cpp	Sat Aug 01 18:31:00 2015 +0200
+++ b/Orthanc/Core/SQLite/Statement.cpp	Sat Aug 01 19:54:12 2015 +0200
@@ -42,7 +42,6 @@
 #include "Statement.h"
 #include "Connection.h"
 
-#include <sqlite3.h>
 #include <string.h>
 #include <stdio.h>
 #include <algorithm>
@@ -51,6 +50,8 @@
 #include <glog/logging.h>
 #endif
 
+#include "sqlite3.h"
+
 #if defined(_MSC_VER)
 #define snprintf _snprintf
 #endif
--- 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_;