comparison OrthancServer/Sources/Database/IDatabaseWrapper.h @ 5455:176bc05f85f4 pg-transactions

DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
author Alain Mazy <am@osimis.io>
date Thu, 07 Dec 2023 12:04:11 +0100
parents f22c8fac764b
children dceed5e3d6a9
comparison
equal deleted inserted replaced
5454:099d45f49fe1 5455:176bc05f85f4
37 namespace Orthanc 37 namespace Orthanc
38 { 38 {
39 class DatabaseConstraint; 39 class DatabaseConstraint;
40 class ResourcesContent; 40 class ResourcesContent;
41 41
42 class OrthancPluginDatabaseV3;
43 class OrthancPluginDatabaseV4;
42 44
43 class IDatabaseWrapper : public boost::noncopyable 45 class IDatabaseWrapper : public boost::noncopyable
44 { 46 {
45 public: 47 public:
48
49 struct Capabilities
50 {
51 friend OrthancPluginDatabaseV3;
52 friend OrthancPluginDatabaseV4;
53
54 protected:
55 bool hasFlushToDisk_;
56 bool hasRevisionsSupport_;
57 bool hasLabelsSupport_;
58 bool hasAtomicIncrementGlobalProperty_;
59
60 public:
61 Capabilities(bool hasFlushToDisk,
62 bool hasRevisionsSupport,
63 bool hasLabelsSupport,
64 bool hasAtomicIncrementGlobalProperty)
65 : hasFlushToDisk_(hasFlushToDisk),
66 hasRevisionsSupport_(hasRevisionsSupport),
67 hasLabelsSupport_(hasLabelsSupport),
68 hasAtomicIncrementGlobalProperty_(hasAtomicIncrementGlobalProperty)
69 {
70 }
71
72 bool HasFlushToDisk() const
73 {
74 return hasFlushToDisk_;
75 }
76
77 bool HasRevisionsSupport() const
78 {
79 return hasRevisionsSupport_;
80 }
81
82 bool HasLabelsSupport() const
83 {
84 return hasLabelsSupport_;
85 }
86
87 bool HasAtomicIncrementGlobalProperty() const
88 {
89 return hasAtomicIncrementGlobalProperty_;
90 }
91 };
92
46 struct CreateInstanceResult : public boost::noncopyable 93 struct CreateInstanceResult : public boost::noncopyable
47 { 94 {
48 bool isNewPatient_; 95 bool isNewPatient_;
49 bool isNewStudy_; 96 bool isNewStudy_;
50 bool isNewSeries_; 97 bool isNewSeries_;
255 virtual void ListLabels(std::set<std::string>& target, 302 virtual void ListLabels(std::set<std::string>& target,
256 int64_t resource) = 0; 303 int64_t resource) = 0;
257 304
258 // List all the labels that are present in any resource 305 // List all the labels that are present in any resource
259 virtual void ListAllLabels(std::set<std::string>& target) = 0; 306 virtual void ListAllLabels(std::set<std::string>& target) = 0;
307
308 virtual const IDatabaseWrapper::Capabilities& GetDatabaseCapabilities() const = 0;
309
310 virtual int64_t IncrementGlobalProperty(GlobalProperty property,
311 int64_t increment,
312 bool shared) = 0;
260 }; 313 };
261 314
262 315
263 virtual ~IDatabaseWrapper() 316 virtual ~IDatabaseWrapper()
264 { 317 {
268 321
269 virtual void Close() = 0; 322 virtual void Close() = 0;
270 323
271 virtual void FlushToDisk() = 0; 324 virtual void FlushToDisk() = 0;
272 325
273 virtual bool HasFlushToDisk() const = 0;
274
275 virtual ITransaction* StartTransaction(TransactionType type, 326 virtual ITransaction* StartTransaction(TransactionType type,
276 IDatabaseListener& listener) = 0; 327 IDatabaseListener& listener) = 0;
277 328
278 virtual unsigned int GetDatabaseVersion() = 0; 329 virtual unsigned int GetDatabaseVersion() = 0;
279 330
280 virtual void Upgrade(unsigned int targetVersion, 331 virtual void Upgrade(unsigned int targetVersion,
281 IStorageArea& storageArea) = 0; 332 IStorageArea& storageArea) = 0;
282 333
283 virtual bool HasRevisionsSupport() const = 0; 334 virtual const IDatabaseWrapper::Capabilities& GetDatabaseCapabilities() const = 0;
284
285 virtual bool HasLabelsSupport() const = 0;
286 }; 335 };
287 } 336 }