comparison 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
comparison
equal deleted inserted replaced
57:26a230647a73 58:b3259b9c6dfb
33 33
34 34
35 class CacheContext 35 class CacheContext
36 { 36 {
37 private: 37 private:
38 std::auto_ptr<Orthanc::FilesystemStorage> storage_; 38 Orthanc::FilesystemStorage storage_;
39 std::auto_ptr<Orthanc::SQLite::Connection> db_; 39 Orthanc::SQLite::Connection db_;
40
40 std::auto_ptr<OrthancPlugins::CacheManager> cache_; 41 std::auto_ptr<OrthancPlugins::CacheManager> cache_;
41 std::auto_ptr<OrthancPlugins::CacheScheduler> scheduler_; 42 std::auto_ptr<OrthancPlugins::CacheScheduler> scheduler_;
42 43
43 public: 44 public:
44 CacheContext(const std::string& path) 45 CacheContext(const std::string& path) : storage_(path)
45 { 46 {
46 boost::filesystem::path p(path); 47 boost::filesystem::path p(path);
47 48 db_.Open((p / "cache.db").string());
48 storage_.reset(new Orthanc::FilesystemStorage(path)); 49
49 db_.reset(new Orthanc::SQLite::Connection()); 50 cache_.reset(new OrthancPlugins::CacheManager(db_, storage_));
50 db_->Open((p / "cache.db").string());
51
52 cache_.reset(new OrthancPlugins::CacheManager(*db_, *storage_));
53 //cache_->SetSanityCheckEnabled(true); // For debug 51 //cache_->SetSanityCheckEnabled(true); // For debug
54 52
55 scheduler_.reset(new OrthancPlugins::CacheScheduler(*cache_, 100)); 53 scheduler_.reset(new OrthancPlugins::CacheScheduler(*cache_, 100));
54 }
55
56 ~CacheContext()
57 {
58 scheduler_.reset(NULL);
59 cache_.reset(NULL);
56 } 60 }
57 61
58 OrthancPlugins::CacheScheduler& GetScheduler() 62 OrthancPlugins::CacheScheduler& GetScheduler()
59 { 63 {
60 return *scheduler_; 64 return *scheduler_;