PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/vp_plugins/qtservice-2.6_1-opensource/doc/html/qtservice.html

http://cupsfilter.googlecode.com/
HTML | 92 lines | 90 code | 1 blank | 1 comment | 0 complexity | 72b9a74e41f9d873fd6c3b26c125d86e MD5 | raw file
 1<?xml version="1.0" encoding="iso-8859-1"?>
 2<!DOCTYPE html
 3    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 4<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 5<!-- qtservice-2.6_1-opensource/src/qtservice.cpp -->
 6<head>
 7  <title>QtService Class Reference</title>
 8  <link href="classic.css" rel="stylesheet" type="text/css" />
 9</head>
10<body>
11<table border="0" cellpadding="0" cellspacing="0" width="100%">
12<tr>
13<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
14<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
15</tr></table><h1 class="title">QtService Class Reference</h1>
16<p>The QtService is a convenient template class that allows you to create a service for a particular application type. <a href="#details">More...</a></p>
17<pre> #include &lt;QtService&gt;</pre><p>Inherits <a href="qtservicebase.html">QtServiceBase</a>.</p>
18<ul>
19<li><a href="qtservice-members.html">List of all members, including inherited members</a></li>
20</ul>
21<a name="public-functions"></a>
22<h3>Public Functions</h3>
23<ul>
24<li><div class="fn"></div><b><a href="qtservice.html#QtService">QtService</a></b> ( int <i>argc</i>, char ** <i>argv</i>, const QString &amp; <i>name</i> )</li>
25<li><div class="fn"></div><b><a href="qtservice.html#dtor.QtService">~QtService</a></b> ()</li>
26</ul>
27<ul>
28<li><div class="fn"></div>9 public functions inherited from <a href="qtservicebase.html#public-functions">QtServiceBase</a></li>
29</ul>
30<a name="protected-functions"></a>
31<h3>Protected Functions</h3>
32<ul>
33<li><div class="fn"></div>Application * <b><a href="qtservice.html#application">application</a></b> () const</li>
34</ul>
35<ul>
36<li><div class="fn"></div>7 protected functions inherited from <a href="qtservicebase.html#protected-functions">QtServiceBase</a></li>
37</ul>
38<h3>Additional Inherited Members</h3>
39<ul>
40<li><div class="fn"></div>1 static public member inherited from <a href="qtservicebase.html#static-public-members">QtServiceBase</a></li>
41</ul>
42<a name="details"></a>
43<hr />
44<h2>Detailed Description</h2>
45<p>The QtService is a convenient template class that allows you to create a service for a particular application type.</p>
46<p>A Windows service or Unix daemon (a &quot;service&quot;), is a program that runs &quot;in the background&quot; independently of whether a user is logged in or not. A service is often set up to start when the machine boots up, and will typically run continuously as long as the machine is on.</p>
47<p>Services are usually non-interactive console applications. User interaction, if required, is usually implemented in a separate, normal GUI application that communicates with the service through an IPC channel. For simple communication, <a href="qtservicecontroller.html#sendCommand">QtServiceController::sendCommand</a>() and <a href="qtservicebase.html#processCommand">QtService::processCommand</a>() may be used, possibly in combination with a shared settings file. For more complex, interactive communication, a custom IPC channel should be used, e.g&#x2e; based on Qt's networking classes. (In certain circumstances, a service may provide a GUI itself, ref. the &quot;interactive&quot; example documentation).</p>
48<p><b>Note:</b> On Unix systems, this class relies on facilities provided by the <a href="http://qt.nokia.com/doc/4.5/qtnetwork.html">QtNetwork</a> module, provided as part of the Qt Open Source Edition and certain <a href="http://qt.nokia.com/doc/4.5/commercialeditions.html">Qt Commercial Editions</a>.</p>
49<p>The QtService class functionality is inherited from <a href="qtservicebase.html">QtServiceBase</a>, but in addition the QtService class binds an instance of <a href="qtservicebase.html">QtServiceBase</a> with an application type.</p>
50<p>Typically, you will create a service by subclassing the QtService template class. For example:</p>
51<pre> class MyService : public QtService&lt;QApplication&gt;
52 {
53 public:
54     MyService(int argc, char **argv);
55     ~MyService();
56
57 protected:
58     void start();
59     void stop();
60     void pause();
61     void resume();
62     void processCommand(int code);
63 };</pre>
64<p>The application type can be <a href="http://qt.nokia.com/doc/4.5/qcoreapplication.html">QCoreApplication</a> for services without GUI, <a href="http://qt.nokia.com/doc/4.5/qapplication.html">QApplication</a> for services with GUI or you can use your own custom application type.</p>
65<p>You must reimplement the <a href="qtservicebase.html#start">QtServiceBase::start</a>() function to perform the service's work. Usually you create some main object on the heap which is the heart of your service.</p>
66<p>In addition, you might want to reimplement the <a href="qtservicebase.html#pause">QtServiceBase::pause</a>(), <a href="qtservicebase.html#processCommand">QtServiceBase::processCommand</a>(), <a href="qtservicebase.html#resume">QtServiceBase::resume</a>() and <a href="qtservicebase.html#stop">QtServiceBase::stop</a>() to intervene the service's process on controller requests. You can control any given service using an instance of the <a href="qtservicecontroller.html">QtServiceController</a> class which also allows you to control services from separate applications. The mentioned functions are all virtual and won't do anything unless they are reimplemented.</p>
67<p>Your custom service is typically instantiated in the application's main function. Then the main function will call your service's <a href="qtservicebase.html#exec">exec</a>() function, and return the result of that call. For example:</p>
68<pre>     int main(int argc, char **argv)
69     {
70         MyService service(argc, argv);
71         return service.exec();
72     }</pre>
73<p>When the <a href="qtservicebase.html#exec">exec</a>() function is called, it will parse the <a href="qtservicebase.html#servicespecificarguments">service specific arguments</a> passed in <tt>argv</tt>, perform the required actions, and exit.</p>
74<p>If none of the arguments is recognized as service specific, <a href="qtservicebase.html#exec">exec</a>() will first call the <a href="qtservicebase.html#createApplication">createApplication</a>() function, then <a href="qtservicebase.html#executeApplication">executeApplication</a>() and finally the <a href="qtservicebase.html#start">start</a>() function. In the end, <a href="qtservicebase.html#exec">exec</a>() returns while the service continues in its own process waiting for commands from the service controller.</p>
75<p>See also <a href="qtservicebase.html">QtServiceBase</a> and <a href="qtservicecontroller.html">QtServiceController</a>.</p>
76<hr />
77<h2>Member Function Documentation</h2>
78<h3 class="fn"><a name="QtService"></a>QtService::QtService ( int <i>argc</i>, char ** <i>argv</i>, const <a href="http://qt.nokia.com/doc/4.5/qstring.html">QString</a> &amp; <i>name</i> )</h3>
79<p>Constructs a <a href="qtservice.html">QtService</a> object called <i>name</i>. The <i>argc</i> and <i>argv</i> parameters are parsed after the <a href="qtservicebase.html#exec">exec</a>() function has been called. Then they are passed to the application's constructor.</p>
80<p>There can only be one <a href="qtservice.html">QtService</a> object in a process.</p>
81<p>See also <a href="qtservicebase.html#QtServiceBase">QtServiceBase</a>().</p>
82<h3 class="fn"><a name="dtor.QtService"></a>QtService::~QtService ()</h3>
83<p>Destroys the service object.</p>
84<h3 class="fn"><a name="application"></a>Application * QtService::application () const&nbsp;&nbsp;<tt> [protected]</tt></h3>
85<p>Returns a pointer to the application object.</p>
86<p /><address><hr /><div align="center">
87<table width="100%" cellspacing="0" border="0"><tr class="address">
88<td width="30%" align="left">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies)</td>
89<td width="40%" align="center"><a href="http://qt.nokia.com/doc/trademarks.html">Trademarks</a></td>
90<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
91</tr></table></div></address></body>
92</html>