Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Engine/PluginsManager.h @ 5660:e4d9a872998f
replaced incorrect macro WIN32 by _WIN32
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 23 Jun 2024 10:24:31 +0200 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
887 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1232
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
887 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU General Public License as | |
11 * published by the Free Software Foundation, either version 3 of the | |
12 * License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #pragma once | |
25 | |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
26 #if ORTHANC_ENABLE_PLUGINS == 1 |
1632
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1630
diff
changeset
|
27 |
898
7000fc86fe62
improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
897
diff
changeset
|
28 #include "IPluginServiceProvider.h" |
887 | 29 |
888
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
887
diff
changeset
|
30 #include <map> |
894 | 31 #include <list> |
887 | 32 |
33 namespace Orthanc | |
34 { | |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
35 class PluginsManager : public boost::noncopyable |
887 | 36 { |
37 private: | |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
38 class Plugin : public boost::noncopyable |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
39 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
40 private: |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
41 OrthancPluginContext context_; |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
42 SharedLibrary library_; |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
43 std::string version_; |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
44 PluginsManager& pluginManager_; |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
45 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
46 public: |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
47 Plugin(PluginsManager& pluginManager, |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
48 const std::string& path); |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
49 |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
50 SharedLibrary& GetSharedLibrary() |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
51 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
52 return library_; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
53 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
54 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
55 void SetVersion(const std::string& version) |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
56 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
57 version_ = version; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
58 } |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
59 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
60 const std::string& GetVersion() const |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
61 { |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
62 return version_; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
63 } |
1630
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
64 |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
65 PluginsManager& GetPluginManager() |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
66 { |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
67 return pluginManager_; |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
68 } |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
69 |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
70 OrthancPluginContext& GetContext() |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
71 { |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
72 return context_; |
ffd23c0104af
"/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1581
diff
changeset
|
73 } |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
74 }; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
75 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
76 typedef std::map<std::string, Plugin*> Plugins; |
898
7000fc86fe62
improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
897
diff
changeset
|
77 |
887 | 78 Plugins plugins_; |
899 | 79 std::list<IPluginServiceProvider*> serviceProviders_; |
898
7000fc86fe62
improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
897
diff
changeset
|
80 |
1581
357c4bb15701
Plugins have access to explicit error codes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
81 static OrthancPluginErrorCode InvokeService(OrthancPluginContext* context, |
357c4bb15701
Plugins have access to explicit error codes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
82 _OrthancPluginService service, |
357c4bb15701
Plugins have access to explicit error codes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
83 const void* parameters); |
894 | 84 |
887 | 85 public: |
86 PluginsManager(); | |
87 | |
88 ~PluginsManager(); | |
89 | |
90 void RegisterPlugin(const std::string& path); | |
888
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
887
diff
changeset
|
91 |
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
887
diff
changeset
|
92 void ScanFolderForPlugins(const std::string& path, |
d44b845c1c89
recursive scan for plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
887
diff
changeset
|
93 bool isRecursive); |
897
bafc9d592632
REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
896
diff
changeset
|
94 |
899 | 95 void RegisterServiceProvider(IPluginServiceProvider& provider) |
898
7000fc86fe62
improved plugin api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
897
diff
changeset
|
96 { |
899 | 97 serviceProviders_.push_back(&provider); |
897
bafc9d592632
REST callbacks are working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
896
diff
changeset
|
98 } |
1232
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
99 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
100 void ListPlugins(std::list<std::string>& result) const; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
101 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
102 bool HasPlugin(const std::string& name) const; |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
103 |
f1c01451a8ee
Introspection of plugins, Plugins can extend Orthanc Explorer with custom JavaScript
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
907
diff
changeset
|
104 const std::string& GetPluginVersion(const std::string& name) const; |
1644
939b921b2c81
plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
105 |
939b921b2c81
plugin error dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1632
diff
changeset
|
106 static std::string GetPluginName(SharedLibrary& library); |
887 | 107 }; |
108 } | |
1632
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1630
diff
changeset
|
109 |
eb8fbcf008b5
fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1630
diff
changeset
|
110 #endif |