annotate Sphinx/source/developers/creating-plugins.rst @ 45:d7796decd3fe

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