/usr/share/doc/libpion-doc/html/plugin__service_8hpp_source.html is in libpion-doc 5.0.4+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>pion: include/pion/http/plugin_service.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
</ul>
</div>
<h1>include/pion/http/plugin_service.hpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// ---------------------------------------------------------------------</span>
<a name="l00002"></a>00002 <span class="comment">// pion: a Boost C++ framework for building lightweight HTTP interfaces</span>
<a name="l00003"></a>00003 <span class="comment">// ---------------------------------------------------------------------</span>
<a name="l00004"></a>00004 <span class="comment">// Copyright (C) 2007-2012 Cloudmeter, Inc. (http://www.cloudmeter.com)</span>
<a name="l00005"></a>00005 <span class="comment">//</span>
<a name="l00006"></a>00006 <span class="comment">// Distributed under the Boost Software License, Version 1.0.</span>
<a name="l00007"></a>00007 <span class="comment">// See http://www.boost.org/LICENSE_1_0.txt</span>
<a name="l00008"></a>00008 <span class="comment">//</span>
<a name="l00009"></a>00009
<a name="l00010"></a>00010 <span class="preprocessor">#ifndef __PION_PLUGIN_SERVICE_HEADER__</span>
<a name="l00011"></a>00011 <span class="preprocessor"></span><span class="preprocessor">#define __PION_PLUGIN_SERVICE_HEADER__</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span>
<a name="l00013"></a>00013 <span class="preprocessor">#include <string></span>
<a name="l00014"></a>00014 <span class="preprocessor">#include <boost/noncopyable.hpp></span>
<a name="l00015"></a>00015 <span class="preprocessor">#include <pion/config.hpp></span>
<a name="l00016"></a>00016 <span class="preprocessor">#include <pion/error.hpp></span>
<a name="l00017"></a>00017 <span class="preprocessor">#include <pion/algorithm.hpp></span>
<a name="l00018"></a>00018 <span class="preprocessor">#include <pion/http/request.hpp></span>
<a name="l00019"></a>00019 <span class="preprocessor">#include <pion/tcp/connection.hpp></span>
<a name="l00020"></a>00020
<a name="l00021"></a>00021
<a name="l00022"></a>00022 <span class="keyword">namespace </span>pion { <span class="comment">// begin namespace pion</span>
<a name="l00023"></a>00023 <span class="keyword">namespace </span>http { <span class="comment">// begin namespace http</span>
<a name="l00024"></a>00024
<a name="l00025"></a>00025
<a name="l00029"></a><a class="code" href="classpion_1_1http_1_1plugin__service.html">00029</a> <span class="keyword">class </span><a class="code" href="classpion_1_1http_1_1plugin__service.html">plugin_service</a> :
<a name="l00030"></a>00030 <span class="keyword">private</span> boost::noncopyable
<a name="l00031"></a>00031 {
<a name="l00032"></a>00032 <span class="keyword">public</span>:
<a name="l00033"></a>00033
<a name="l00035"></a><a class="code" href="classpion_1_1http_1_1plugin__service.html#a587b482f3e8d7bd03ac0d7d693538b23">00035</a> <a class="code" href="classpion_1_1http_1_1plugin__service.html#a587b482f3e8d7bd03ac0d7d693538b23" title="default constructor">plugin_service</a>(<span class="keywordtype">void</span>) {}
<a name="l00036"></a>00036
<a name="l00038"></a><a class="code" href="classpion_1_1http_1_1plugin__service.html#a1d7ffeb7d24a0ab951562031b7c16552">00038</a> <span class="keyword">virtual</span> <a class="code" href="classpion_1_1http_1_1plugin__service.html#a1d7ffeb7d24a0ab951562031b7c16552" title="virtual destructor">~plugin_service</a>() {}
<a name="l00039"></a>00039
<a name="l00046"></a>00046 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classpion_1_1http_1_1plugin__service.html#a2ea7bfac96e9d5fc2dbd327871540621">operator()</a>(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn) = 0;
<a name="l00047"></a>00047
<a name="l00054"></a><a class="code" href="classpion_1_1http_1_1plugin__service.html#a49cddd4c2a99e276373b5f7162ff3cde">00054</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classpion_1_1http_1_1plugin__service.html#a49cddd4c2a99e276373b5f7162ff3cde">set_option</a>(<span class="keyword">const</span> std::string& name, <span class="keyword">const</span> std::string& value) {
<a name="l00055"></a>00055 BOOST_THROW_EXCEPTION( <a class="code" href="classpion_1_1error_1_1bad__arg.html" title="exception thrown for an invalid configuration argument or option">error::bad_arg</a>() << error::errinfo_arg_name(name) );
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057
<a name="l00059"></a><a class="code" href="classpion_1_1http_1_1plugin__service.html#acb534a38c423ead57c98d07077579ecc">00059</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classpion_1_1http_1_1plugin__service.html#acb534a38c423ead57c98d07077579ecc" title="called when the web service&#39;s server is starting">start</a>(<span class="keywordtype">void</span>) {}
<a name="l00060"></a>00060
<a name="l00062"></a><a class="code" href="classpion_1_1http_1_1plugin__service.html#a6d8c34f35f95d8e45c5476314bebdf6f">00062</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classpion_1_1http_1_1plugin__service.html#a6d8c34f35f95d8e45c5476314bebdf6f" title="called when the web service&#39;s server is stopping">stop</a>(<span class="keywordtype">void</span>) {}
<a name="l00063"></a>00063
<a name="l00065"></a><a class="code" href="classpion_1_1http_1_1plugin__service.html#a081c90dafdae862ca35b4684eaed4b36">00065</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classpion_1_1http_1_1plugin__service.html#a081c90dafdae862ca35b4684eaed4b36" title="sets the URI stem or resource that is bound to the web service">set_resource</a>(<span class="keyword">const</span> std::string& str) { m_resource = str; }
<a name="l00066"></a>00066
<a name="l00068"></a><a class="code" href="classpion_1_1http_1_1plugin__service.html#ae65490a94aeeabfdb0f890dc9a93e0be">00068</a> <span class="keyword">inline</span> <span class="keyword">const</span> std::string& <a class="code" href="classpion_1_1http_1_1plugin__service.html#ae65490a94aeeabfdb0f890dc9a93e0be" title="returns the URI stem or resource that is bound to the web service">get_resource</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_resource; }
<a name="l00069"></a>00069
<a name="l00071"></a><a class="code" href="classpion_1_1http_1_1plugin__service.html#a72659ae4dfd83e5a8411e5f1e9bf8dcb">00071</a> <span class="keyword">inline</span> std::string <a class="code" href="classpion_1_1http_1_1plugin__service.html#a72659ae4dfd83e5a8411e5f1e9bf8dcb" title="returns the path to the resource requested, relative to the web service&#39;s location...">get_relative_resource</a>(<span class="keyword">const</span> std::string& resource_requested)<span class="keyword"> const </span>{
<a name="l00072"></a>00072 <span class="keywordflow">if</span> (resource_requested.size() <= <a class="code" href="classpion_1_1http_1_1plugin__service.html#ae65490a94aeeabfdb0f890dc9a93e0be" title="returns the URI stem or resource that is bound to the web service">get_resource</a>().size()) {
<a name="l00073"></a>00073 <span class="comment">// either the request matches the web service's resource path (a directory)</span>
<a name="l00074"></a>00074 <span class="comment">// or the request does not match (should never happen)</span>
<a name="l00075"></a>00075 <span class="keywordflow">return</span> std::string();
<a name="l00076"></a>00076 }
<a name="l00077"></a>00077 <span class="comment">// strip the web service's resource path plus the slash after it</span>
<a name="l00078"></a>00078 <span class="keywordflow">return</span> <a class="code" href="structpion_1_1algorithm.html#a440bd54b07a24c80bc939fdb03583721" title="escapes URL-encoded strings (a20value+with20spaces)">algorithm::url_decode</a>(resource_requested.substr(<a class="code" href="classpion_1_1http_1_1plugin__service.html#ae65490a94aeeabfdb0f890dc9a93e0be" title="returns the URI stem or resource that is bound to the web service">get_resource</a>().size() + 1));
<a name="l00079"></a>00079 }
<a name="l00080"></a>00080
<a name="l00081"></a>00081
<a name="l00082"></a>00082 <span class="keyword">private</span>:
<a name="l00083"></a>00083
<a name="l00085"></a>00085 std::string m_resource;
<a name="l00086"></a>00086 };
<a name="l00087"></a>00087
<a name="l00088"></a>00088
<a name="l00089"></a>00089 <span class="comment">//</span>
<a name="l00090"></a>00090 <span class="comment">// The following symbols must be defined for any web service that you would</span>
<a name="l00091"></a>00091 <span class="comment">// like to be able to load dynamically using the http::server::load_service()</span>
<a name="l00092"></a>00092 <span class="comment">// function. These are not required for any services that you only want to link</span>
<a name="l00093"></a>00093 <span class="comment">// directly into your programs.</span>
<a name="l00094"></a>00094 <span class="comment">//</span>
<a name="l00095"></a>00095 <span class="comment">// Make sure that you replace "MyPluginName" with the name of your derived class.</span>
<a name="l00096"></a>00096 <span class="comment">// This name must also match the name of the object file (excluding the</span>
<a name="l00097"></a>00097 <span class="comment">// extension). These symbols must be linked into your service's object file,</span>
<a name="l00098"></a>00098 <span class="comment">// not included in any headers that it may use (declarations are OK in headers</span>
<a name="l00099"></a>00099 <span class="comment">// but not the definitions).</span>
<a name="l00100"></a>00100 <span class="comment">//</span>
<a name="l00101"></a>00101 <span class="comment">// The "pion_create" function is used to create new instances of your service.</span>
<a name="l00102"></a>00102 <span class="comment">// The "pion_destroy" function is used to destroy instances of your service.</span>
<a name="l00103"></a>00103 <span class="comment">//</span>
<a name="l00104"></a>00104 <span class="comment">// extern "C" MyPluginName *pion_create_MyPluginName(void) {</span>
<a name="l00105"></a>00105 <span class="comment">// return new MyPluginName;</span>
<a name="l00106"></a>00106 <span class="comment">// }</span>
<a name="l00107"></a>00107 <span class="comment">//</span>
<a name="l00108"></a>00108 <span class="comment">// extern "C" void pion_destroy_MyPluginName(MyPluginName *service_ptr) {</span>
<a name="l00109"></a>00109 <span class="comment">// delete service_ptr;</span>
<a name="l00110"></a>00110 <span class="comment">// }</span>
<a name="l00111"></a>00111 <span class="comment">//</span>
<a name="l00112"></a>00112
<a name="l00113"></a>00113
<a name="l00114"></a>00114 } <span class="comment">// end namespace http</span>
<a name="l00115"></a>00115 } <span class="comment">// end namespace pion</span>
<a name="l00116"></a>00116
<a name="l00117"></a>00117 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 16 Sep 2013 for pion by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>
|