38
|
1 .. _creating-plugins:
|
|
2
|
24
|
3 Creating new plugins
|
|
4 ====================
|
|
5
|
|
6 The recommended way of :ref:`contributing to the Orthanc code <contributing>`
|
|
7 is by extending it by :ref:`creating new plugins <plugins>`.
|
|
8
|
|
9 Overview
|
|
10 --------
|
|
11
|
|
12 Orthanc plugins must use the `plugin SDK
|
|
13 <https://orthanc.chu.ulg.ac.be/sdk/index.html>`__ and must be written
|
|
14 in C or C++. They must also fullfil the terms of the `GPLv3 license
|
|
15 <http://www.gnu.org/licenses/quick-guide-gplv3.en.html>`__ that is
|
|
16 used by the core of Orthanc. Sample code for plugins can be found `in
|
|
17 the official Orthanc repository
|
|
18 <https://bitbucket.org/sjodogne/orthanc/src/default/Plugins/Samples/>`__
|
|
19 (in the ``Plugins/Samples`` folder of the ``plugins`` branch). A
|
|
20 tutorial showing how to implement a basic WADO server is `available on
|
|
21 CodeProject
|
25
|
22 <http://www.codeproject.com/Articles/797118/Implementing-a-WADO-Server-using-Orthanc>`__.
|
|
23
|
|
24 We suggest developers to adopt the :ref:`coding style of the Orthanc
|
|
25 core <coding-style>`, although this is of course not required.
|
|
26
|
|
27 Do not hesitate to `contact us
|
|
28 <http://www.orthanc-server.com/static.php?page=contact>`__ if you wish
|
|
29 your plugin to be **indexed** in :ref:`this part of the Orthanc Book
|
|
30 <plugins-contributed>`!
|
|
31
|
|
32
|
|
33 Structure of the plugins
|
|
34 ------------------------
|
24
|
35
|
|
36 A plugin takes the form of a shared library (``.DLL`` under Windows,
|
42
|
37 ``.so`` under GNU/Linux, ``.dylib`` under Apple OS X...) that use the
|
|
38 `ABI of the C language
|
25
|
39 <https://en.wikipedia.org/wiki/Application_binary_interface>`__ to
|
|
40 declare 4 public functions/symbols:
|
24
|
41
|
|
42 * ``int32_t OrthancPluginInitialize(OrthancPluginContext* context)``. This
|
|
43 callback function is responsible for initializing the plugin. The
|
|
44 ``context`` argument gives access to the API of Orthanc.
|
|
45 * ``void OrthancPluginFinalize()``. This function is responsible
|
|
46 for finalizing the plugin, releasing all the allocated resources.
|
|
47 * ``const char* OrthancPluginGetName()``. This function must give a
|
|
48 name to the plugin.
|
|
49 * ``const char* OrthancPluginGetVersion()``. This function must
|
|
50 provide the version of the plugin.
|
|
51
|
25
|
52 *Remark:* The size of the memory buffers that are exchanged between
|
|
53 the Orthanc core and the plugins must be below 4GB. This is a
|
|
54 consequence of the fact that the Orthanc plugin SDK uses ``uint32_t``
|
|
55 to encode the size of a memory buffer. We might extend the SDK in
|
|
56 the future to deal with buffers whose size if above 4GB.
|