]> Creatis software - cpPlugins.git/blob - doc/third_party/Pluma/html/index.htm
Base objects migration
[cpPlugins.git] / doc / third_party / Pluma / html / index.htm
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3     <head>
4         <title>Pluma - Plug-in Management Framework</title>
5         <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
6         <link href="doxygen.css" rel="stylesheet" type="text/css" />
7         <link href="tabs.css" rel="stylesheet" type="text/css" />
8     </head>
9     <body>
10         <div id="logo">
11             <img src="./logo.png" title="Pluma home" alt="Pluma logo" />
12         </div>
13 <!-- Generated by Doxygen 1.8.6 -->
14   <div id="navrow1" class="tabs">
15     <ul class="tablist">
16       <li class="current"><a href="index.htm"><span>Main&#160;Page</span></a></li>
17       <li><a href="annotated.htm"><span>Classes</span></a></li>
18       <li><a href="files.htm"><span>Files</span></a></li>
19     </ul>
20   </div>
21 </div><!-- top -->
22 <div class="header">
23   <div class="headertitle">
24 <div class="title">Pluma Documentation</div>  </div>
25 </div><!--header-->
26 <div class="contents">
27 <div class="textblock"><h1><a class="anchor" id="welcome"></a>
28 Welcome</h1>
29 <p>Welcome to Pluma documentation. Here you will find a detailed view of all Pluma <a href="./annotated.htm">classes</a>.<br/>
30  If you are looking for support, you can visit the official website at <a href="http://pluma-framework.sourceforge.net/">http://pluma-framework.sourceforge.net/</a>.<br/>
31 <br/>
32 </p>
33 <p>CSS based on <a href="http://www.sfml-dev.org/documentation/1.6/">SFML1.6 documentation</a><br/>
34 </p>
35 <h1><a class="anchor" id="example"></a>
36 Short Example</h1>
37 <p>A short example to demonstrate Pluma usage:<br/>
38  A host application define a Device interface. A certain plugin defines a Keyboard, witch is a Device. The host will use DeviceProviders to create objects of type Device. The plugin will provide host specifically with a KeyboardProvider.<br/>
39 </p>
40 <p>Device hpp (shared): </p>
41 <div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Pluma/Pluma.hpp&gt;</span></div>
42 <div class="line"><span class="keyword">class </span>Device{</div>
43 <div class="line"><span class="keyword">public</span>:</div>
44 <div class="line">    <span class="keyword">virtual</span> std::string getDescription() <span class="keyword">const</span> = 0;</div>
45 <div class="line">};</div>
46 <div class="line"><span class="comment">// create DevicedProvider class</span></div>
47 <div class="line">PLUMA_PROVIDER_HEADER(Device);</div>
48 </div><!-- fragment --><p>Device cpp (shared): </p>
49 <div class="fragment"><div class="line"><span class="preprocessor">#include &quot;Device.hpp&quot;</span></div>
50 <div class="line">generate DevicedProvider with version 6, and compatible with at least v.3</div>
51 <div class="line">PLUMA_PROVIDER_SOURCE(Device, 6, 3);</div>
52 </div><!-- fragment --><p><br/>
53  Keyboard code on the plugin side: </p>
54 <div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Pluma/Pluma.hpp&gt;</span></div>
55 <div class="line"><span class="preprocessor">#include &quot;Device.hpp&quot;</span></div>
56 <div class="line"></div>
57 <div class="line"><span class="keyword">class </span>Keyboard: <span class="keyword">public</span> Device{</div>
58 <div class="line"><span class="keyword">public</span>:</div>
59 <div class="line">    std::string getDescription()<span class="keyword"> const</span>{</div>
60 <div class="line">        <span class="keywordflow">return</span> <span class="stringliteral">&quot;keyboard&quot;</span>;</div>
61 <div class="line">    }</div>
62 <div class="line">};</div>
63 <div class="line"></div>
64 <div class="line"><span class="comment">// create KeyboardProvider, it implements DeviceProvider</span></div>
65 <div class="line">PLUMA_INHERIT_PROVIDER(Keyboard, Device);</div>
66 </div><!-- fragment --><p>plugin connector: </p>
67 <div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Pluma/Connector.hpp&gt;</span></div>
68 <div class="line"><span class="preprocessor">#include &quot;Keyboard.hpp&quot;</span></div>
69 <div class="line"></div>
70 <div class="line">PLUMA_CONNECTOR</div>
71 <div class="line"><span class="keywordtype">bool</span> connect(<a class="code" href="classpluma_1_1Host.htm">pluma::Host</a>&amp; host){</div>
72 <div class="line">    <span class="comment">// add a keyboard provider to host</span></div>
73 <div class="line">    host.<a class="code" href="classpluma_1_1Host.htm#ab673ba94ff56a12cdf2a7a25ebb8cc36">add</a>( <span class="keyword">new</span> KeyboardProvider() );</div>
74 <div class="line">    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
75 <div class="line">}</div>
76 </div><!-- fragment --><p>Host application code: </p>
77 <div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Pluma/Pluma.hpp&gt;</span></div>
78 <div class="line"></div>
79 <div class="line"><span class="preprocessor">#include &quot;Device.hpp&quot;</span></div>
80 <div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
81 <div class="line"><span class="preprocessor">#include &lt;vector&gt;</span></div>
82 <div class="line"></div>
83 <div class="line"><span class="keywordtype">int</span> main(){</div>
84 <div class="line"></div>
85 <div class="line">    <a class="code" href="classpluma_1_1Pluma.htm">pluma::Pluma</a> plugins;</div>
86 <div class="line">    <span class="comment">// Tell plugins manager to accept providers of the type DeviceProvider</span></div>
87 <div class="line">    plugins.<a class="code" href="classpluma_1_1Pluma.htm#a200c59b0983c7ca53d11b03cf8220bc7">acceptProviderType</a>&lt;DeviceProvider&gt;();</div>
88 <div class="line">    <span class="comment">// Load library &quot;standard_devices&quot; from folder &quot;plugins&quot;</span></div>
89 <div class="line">    plugins.<a class="code" href="classpluma_1_1PluginManager.htm#aa00400d23efa8a8f94e44dd1c5bf54e6">load</a>(<span class="stringliteral">&quot;plugins&quot;</span>, <span class="stringliteral">&quot;standard_devices&quot;</span>);</div>
90 <div class="line"></div>
91 <div class="line">    <span class="comment">// Get device providers into a vector</span></div>
92 <div class="line">    std::vector&lt;DeviceProvider*&gt; providers;</div>
93 <div class="line">    plugins.<a class="code" href="classpluma_1_1Pluma.htm#a49fa0b2b4497885c4e978259be0a7abe">getProviders</a>(providers);</div>
94 <div class="line"></div>
95 <div class="line">    <span class="comment">// create a Device from the first provider</span></div>
96 <div class="line">    <span class="keywordflow">if</span> (!providers.empty()){</div>
97 <div class="line">        Device* myDevice = providers.first()-&gt;create();</div>
98 <div class="line">        <span class="comment">// do something with myDevice</span></div>
99 <div class="line">        std::cout &lt;&lt; device-&gt;getDescription() &lt;&lt; std::endl;</div>
100 <div class="line">        <span class="comment">// and delete it in the end</span></div>
101 <div class="line">        <span class="keyword">delete</span> myDevice;</div>
102 <div class="line">    }</div>
103 <div class="line">    <span class="keywordflow">return</span> 0;</div>
104 <div class="line">}</div>
105 </div><!-- fragment --> </div></div><!-- contents -->
106
107         <p id="footer">
108             &nbsp;::&nbsp; Copyright &copy; 2011 Gil Costa, all rights reserved &nbsp;::&nbsp;
109             Documentation generated by <a href="http://www.doxygen.org/" title="doxygen website">doxygen 1.7.4</a> &nbsp;::&nbsp;
110         </p>
111     </body>
112 </html>