comparison Plugin/Cache/CacheManager.cpp @ 147:70d1fe6d6309

Avoid hard crash if not enough memory
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 09 Nov 2016 12:43:58 +0100
parents 3809121c3290
children 1a90184363f8
comparison
equal deleted inserted replaced
146:3cde3e806abe 147:70d1fe6d6309
124 }; 124 };
125 125
126 126
127 struct CacheManager::PImpl 127 struct CacheManager::PImpl
128 { 128 {
129 OrthancPluginContext* context_;
129 Orthanc::SQLite::Connection& db_; 130 Orthanc::SQLite::Connection& db_;
130 Orthanc::FilesystemStorage& storage_; 131 Orthanc::FilesystemStorage& storage_;
131 132
132 bool sanityCheck_; 133 bool sanityCheck_;
133 Bundles bundles_; 134 Bundles bundles_;
134 BundleQuota defaultQuota_; 135 BundleQuota defaultQuota_;
135 BundleQuotas quotas_; 136 BundleQuotas quotas_;
136 137
137 PImpl(Orthanc::SQLite::Connection& db, 138 PImpl(OrthancPluginContext* context,
139 Orthanc::SQLite::Connection& db,
138 Orthanc::FilesystemStorage& storage) : 140 Orthanc::FilesystemStorage& storage) :
141 context_(context),
139 db_(db), 142 db_(db),
140 storage_(storage), 143 storage_(storage),
141 sanityCheck_(false) 144 sanityCheck_(false)
142 { 145 {
143 } 146 }
276 } 279 }
277 } 280 }
278 281
279 282
280 283
281 CacheManager::CacheManager(Orthanc::SQLite::Connection& db, 284 CacheManager::CacheManager(OrthancPluginContext* context,
285 Orthanc::SQLite::Connection& db,
282 Orthanc::FilesystemStorage& storage) : 286 Orthanc::FilesystemStorage& storage) :
283 pimpl_(new PImpl(db, storage)) 287 pimpl_(new PImpl(context, db, storage))
284 { 288 {
285 Open(); 289 Open();
286 ReadBundleStatistics(); 290 ReadBundleStatistics();
291 }
292
293
294 OrthancPluginContext* CacheManager::GetPluginContext() const
295 {
296 return pimpl_->context_;
287 } 297 }
288 298
289 299
290 void CacheManager::SetSanityCheckEnabled(bool enabled) 300 void CacheManager::SetSanityCheckEnabled(bool enabled)
291 { 301 {