annotate OrthancServer/Sources/Database/Compatibility/SetOfResources.h @ 5084:9770d537880d attach-custom-data

added support for revision in SQLite + avoid upgrading DB version
author Alain Mazy <am@osimis.io>
date Thu, 15 Sep 2022 09:02:07 +0200
parents 6eff25f70121
children 0ea402b4d901
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1753
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4870
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #pragma once
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
25 #include "../../../../OrthancFramework/Sources/Compatibility.h"
3093
2e1808b6146a reorganization of folders
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
26 #include "../IDatabaseWrapper.h"
3085
c829758b9ca0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3084
diff changeset
27 #include "ILookupResources.h"
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <set>
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include <memory>
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 namespace Orthanc
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
3056
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
34 namespace Compatibility
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
3056
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
36 class SetOfResources : public boost::noncopyable
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
37 {
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
38 private:
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
39 typedef std::set<int64_t> Resources;
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
41 IDatabaseWrapper::ITransaction& transaction_;
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
42 ResourceType level_;
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
43 std::unique_ptr<Resources> resources_;
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
3056
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
45 public:
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
46 SetOfResources(IDatabaseWrapper::ITransaction& transaction,
3056
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
47 ResourceType level) :
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
48 transaction_(transaction),
3056
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
49 level_(level)
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
50 {
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
51 }
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
3056
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
53 ResourceType GetLevel() const
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
54 {
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
55 return level_;
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
56 }
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
3056
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
58 void Intersect(const std::list<int64_t>& resources);
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
3056
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
60 void GoDown();
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
3085
c829758b9ca0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3084
diff changeset
62 void Flatten(ILookupResources& compatibility,
3084
195ba4cbac3f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
63 std::list<int64_t>& result);
1750
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
64
3056
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
65 void Flatten(std::list<std::string>& result);
1750
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1747
diff changeset
66
3056
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
67 void Clear()
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
68 {
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
69 resources_.reset(NULL);
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
70 }
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
71 };
6c5d4281da4a removal of SQLiteDatabaseWrapper::GetAllInternalIds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3050
diff changeset
72 }
1746
d143db00a794 SetOfResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }