Mercurial > hg > orthanc
annotate OrthancServer/Resources/Graveyard/DatabasePluginSample/Plugin.cpp @ 4831:7053502fbf97
added copyright UCLouvain
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 25 Nov 2021 19:01:11 +0100 |
parents | d9473bd5ed43 |
children | 2e71a08eea15 43e613a7756b |
rev | line source |
---|---|
1671 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1671 | 4 * Department, University Hospital of Liege, Belgium |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
4831
7053502fbf97
added copyright UCLouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
6 * Copyright (C) 2021-2021 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1671 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU General Public License as | |
10 * published by the Free Software Foundation, either version 3 of the | |
11 * License, or (at your option) any later version. | |
12 * | |
13 * In addition, as a special exception, the copyright holders of this | |
14 * program give permission to link the code of its release with the | |
15 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
16 * that use the same license as the "OpenSSL" library), and distribute | |
17 * the linked executables. You must obey the GNU General Public License | |
18 * in all respects for all of the code used other than "OpenSSL". If you | |
19 * modify file(s) with this exception, you may extend this exception to | |
20 * your version of the file(s), but you are not obligated to do so. If | |
21 * you do not wish to do so, delete this exception statement from your | |
22 * version. If you delete this exception statement from all source files | |
23 * in the program, then also delete it here. | |
24 * | |
25 * This program is distributed in the hope that it will be useful, but | |
26 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
28 * General Public License for more details. | |
29 * | |
30 * You should have received a copy of the GNU General Public License | |
31 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
32 **/ | |
33 | |
34 | |
35 #include "Database.h" | |
36 | |
37 #include <memory> | |
38 #include <iostream> | |
39 #include <boost/algorithm/string/predicate.hpp> | |
40 | |
41 static OrthancPluginContext* context_ = NULL; | |
42 static std::auto_ptr<OrthancPlugins::IDatabaseBackend> backend_; | |
43 | |
44 | |
45 extern "C" | |
46 { | |
47 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) | |
48 { | |
49 context_ = c; | |
50 OrthancPluginLogWarning(context_, "Sample plugin is initializing"); | |
51 | |
52 /* Check the version of the Orthanc core */ | |
53 if (OrthancPluginCheckVersion(c) == 0) | |
54 { | |
55 char info[256]; | |
56 sprintf(info, "Your version of Orthanc (%s) must be above %d.%d.%d to run this plugin", | |
57 c->orthancVersion, | |
58 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, | |
59 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, | |
60 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); | |
61 OrthancPluginLogError(context_, info); | |
62 return -1; | |
63 } | |
64 | |
65 std::string path = "SampleDatabase.sqlite"; | |
66 uint32_t argCount = OrthancPluginGetCommandLineArgumentsCount(context_); | |
67 for (uint32_t i = 0; i < argCount; i++) | |
68 { | |
69 char* tmp = OrthancPluginGetCommandLineArgument(context_, i); | |
70 std::string argument(tmp); | |
71 OrthancPluginFreeString(context_, tmp); | |
72 | |
73 if (boost::starts_with(argument, "--database=")) | |
74 { | |
75 path = argument.substr(11); | |
76 } | |
77 } | |
78 | |
79 std::string s = "Using the following SQLite database: " + path; | |
80 OrthancPluginLogWarning(context_, s.c_str()); | |
81 | |
82 backend_.reset(new Database(path)); | |
83 OrthancPlugins::DatabaseBackendAdapter::Register(context_, *backend_); | |
84 | |
85 return 0; | |
86 } | |
87 | |
88 ORTHANC_PLUGINS_API void OrthancPluginFinalize() | |
89 { | |
90 backend_.reset(NULL); | |
91 } | |
92 | |
93 ORTHANC_PLUGINS_API const char* OrthancPluginGetName() | |
94 { | |
95 return "sample-database"; | |
96 } | |
97 | |
98 | |
99 ORTHANC_PLUGINS_API const char* OrthancPluginGetVersion() | |
100 { | |
101 return "1.0"; | |
102 } | |
103 } |