aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a04942.html
blob: 755c977588c9838e079c0689fe86d97edf7c7f9a (plain)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>NeL: service.h File Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.6 -->
<div class="qindex">  <form class="search" action="search.php" method="get">
<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a>  | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>service.h File Reference</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
Base class for all network services<p>
<dl compact><dt><b>Id</b></dt><dd><a class="el" href="a04942.html">service.h</a>,v 1.72 2004/01/29 17:14:44 lecroart Exp </dd></dl>

<p>
Definition in file <a class="el" href="a06365.html">service.h</a>.
<p>
<code>#include "<a class="el" href="a06590.html">nel/misc/types_nl.h</a>"</code><br>
<code>#include "<a class="el" href="a05598.html">nel/misc/config_file.h</a>"</code><br>
<code>#include "<a class="el" href="a05673.html">nel/misc/entity_id.h</a>"</code><br>
<code>#include "<a class="el" href="a06666.html">nel/misc/variable.h</a>"</code><br>
<code>#include "<a class="el" href="a05585.html">nel/misc/command.h</a>"</code><br>
<code>#include "<a class="el" href="a06646.html">nel/net/unified_network.h</a>"</code><br>
<code>#include &lt;string&gt;</code><br>
<code>#include &lt;vector&gt;</code><br>

<p>
<a href="a06365.html">Go to the source code of this file.</a><table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Namespaces</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>namespace &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a05378.html">NLMISC</a></td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>namespace &nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a05379.html">NLNET</a></td></tr>

<tr><td colspan=2><br><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>#define&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a04942.html#a0">NLNET_SERVICE_MAIN</a>(__ServiceClassName, __ServiceShortName, __ServiceLongName, __ServicePort, __ServiceCallbackArray, __ConfigDir, __LogDir)</td></tr>

</table>
<hr><h2>Define Documentation</h2>
<a class="anchor" name="a0" doxytag="service.h::NLNET_SERVICE_MAIN" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> #define NLNET_SERVICE_MAIN</td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">__ServiceClassName,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>__ServiceShortName,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>__ServiceLongName,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>__ServicePort,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>__ServiceCallbackArray,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>__ConfigDir,         <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>__LogDir&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
<b>Value:</b><div class="fragment"><pre>\
<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span> **argv) \
{ \
        __ServiceClassName *scn = <span class="keyword">new</span> __ServiceClassName; \
        scn-&gt;setArgs (argc, argv); \
        scn-&gt;setCallbackArray (__ServiceCallbackArray, <span class="keyword">sizeof</span>(__ServiceCallbackArray)/<span class="keyword">sizeof</span>(__ServiceCallbackArray[0])); \
        <a class="code" href="a04558.html#a14">sint</a> retval = scn-&gt;main (__ServiceShortName, __ServiceLongName, __ServicePort, __ConfigDir, __LogDir, __DATE__<span class="stringliteral">" "</span>__TIME__); \
        <span class="keyword">delete</span> scn; \
        <span class="keywordflow">return</span> retval; \
}
</pre></div>The goal of this macro is to simplify the service creation, it creates the main body function.<p>
If you don't want to give a callback array, just put EmptyCallbackArray in the last argument<p>
Example: <pre class="fragment"><div>        <span class="comment">// Create the Test Service class</span>
        <span class="keyword">class </span>CTestService : <span class="keyword">public</span> IService
        {
        <span class="keyword">public</span>:
                <span class="keywordtype">void</span> init () { <a class="code" href="a04199.html#a1">nlinfo</a>(<span class="stringliteral">"init()"</span>); }
                <span class="keywordtype">bool</span> update () { <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"update();"</span>); <span class="keywordflow">return</span> <span class="keyword">true</span>; }
                <span class="keywordtype">void</span> release () { <a class="code" href="a04199.html#a1">nlinfo</a>(<span class="stringliteral">"release()"</span>); }
        };
        <span class="comment">// Create the main() function that create a test service instance and execute it.</span>
        <span class="comment">// "TS" is the short service name and "test_service" is the long one.</span>
        <span class="comment">// The name of the config file is based on the long name!</span>
        <span class="comment">// EmptyCallbackArray means that you don't provide right now the callback</span>
        <span class="comment">// the last 2 path are where is the config file is (directory) and where to log info (directory)</span>
        <a class="code" href="a04942.html#a0">NLNET_SERVICE_MAIN</a>(<a class="code" href="a06971.html">CTestService</a>, <span class="stringliteral">"TS"</span>, <span class="stringliteral">"test_service"</span>, 0, EmptyCallbackArray, <span class="stringliteral">""</span>, <span class="stringliteral">""</span>);
 *
</div></pre><p>
If you want the port to not be auto-assigned by the naming service, set the port to a number different than 0.<p>
Args used by service are always in lower case:<p>
-A followed by the path where to execute the service (it uses chdir()) -B followed by the IP address where the naming service is -C followed by the path where we can find the config file -D followed by the client listening address of the frontend for the login system (FS only) -I to start the service iconified -L followed by the directory where we have to log -N followed by the alias name (used by the admin system) -P followed by the listen port (ListenAddress) -Q to make the service quit immediately after the first update -S followed by the shard Id (sint32) (WS only) -W followed by the path where to save all shard data (SaveFilesDirectory) 
<p>
Definition at line <a class="el" href="a06365.html#l00128">128</a> of file <a class="el" href="a06365.html">service.h</a>.    </td>
  </tr>
</table>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 06:43:16 2004 for NeL by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 > 
</a>1.3.6 </small></address>
</body>
</html>