annotate Framework/Plugins/StorageBackend.h @ 27:173176f8cef2

jobs branch has disappeared in orthanc
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 14 Jul 2018 13:18:31 +0200
parents 9e419261f1c9
children 714c5d2bee76
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #pragma once
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "../Common/DatabaseManager.h"
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include <orthanc/OrthancCDatabasePlugin.h>
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 namespace OrthancDatabases
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 {
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 class StorageBackend : public boost::noncopyable
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 private:
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 DatabaseManager manager_;
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 protected:
12
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
36 void ReadFromString(void*& buffer,
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
37 size_t& size,
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
38 const std::string& content);
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
39
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 public:
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 StorageBackend(IDatabaseFactory* factory);
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 virtual ~StorageBackend()
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 }
12
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
46
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
47 DatabaseManager& GetManager()
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
48 {
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
49 return manager_;
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
50 }
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
12
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
52 // NB: These methods will always be invoked in mutual exclusion,
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
53 // as having access to some "DatabaseManager::Transaction" implies
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
54 // that the parent "DatabaseManager" is locked
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
55 virtual void Create(DatabaseManager::Transaction& transaction,
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
56 const std::string& uuid,
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 const void* content,
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 size_t size,
16
9e419261f1c9 mysql storage area working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
59 OrthancPluginContentType type);
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 virtual void Read(void*& content,
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 size_t& size,
12
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
63 DatabaseManager::Transaction& transaction,
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 const std::string& uuid,
16
9e419261f1c9 mysql storage area working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
65 OrthancPluginContentType type);
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
12
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
67 virtual void Remove(DatabaseManager::Transaction& transaction,
41543239072d transactions for storage area
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1
diff changeset
68 const std::string& uuid,
16
9e419261f1c9 mysql storage area working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
69 OrthancPluginContentType type);
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 static void Register(OrthancPluginContext* context,
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 StorageBackend* backend); // Takes ownership
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
14
9774802fd05f PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 12
diff changeset
74 // For unit testing!
9774802fd05f PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 12
diff changeset
75 void ReadToString(std::string& content,
9774802fd05f PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 12
diff changeset
76 DatabaseManager::Transaction& transaction,
9774802fd05f PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 12
diff changeset
77 const std::string& uuid,
9774802fd05f PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 12
diff changeset
78 OrthancPluginContentType type);
9774802fd05f PostgreSQLStorageArea working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 12
diff changeset
79
1
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 static void Finalize();
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 };
d17b2631bb67 starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 }