<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- /builddir/build/BUILD/libqxt/src/core/qxtpipe.cpp --> <head> <title>QxtPipe Class Reference</title> <link href="stylesheet.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://libqxt.org"><img src="images/qxt-logo.png" width="50" height="40" align="left" border="0" /></a></td> <td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a> · <a href="classes.html"><font color="#004faf">Classes</font></a> · <a href="namespaces.html"><font color="#004faf">Namespaces</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td> <td align="right" valign="top" width="230"></td></tr></table><h1 class="title">QxtPipe Class Reference<br /><span class="small-subtitle">[<a href="qxtcore.html">QxtCore</a> module]</span> </h1> <p>The QxtPipe class provides a pipeable <a href="http://doc.qtsoftware.com/4.5/qiodevice.html">QIODevice</a> * * pipes can be connected to other pipes, to exchange data * The default implementation uses a buffer. * Reimplement to make your custom class able to be connected into a pipe chain. * * Example usage: * <a href="#details">More...</a></p> <pre> #include <QxtPipe></pre><p>Inherits <a href="http://doc.qtsoftware.com/4.5/qiodevice.html">QIODevice</a>.</p> <p>Inherited by <a href="qxtdeplex.html">QxtDeplex</a> and <a href="qxtstdio.html">QxtStdio</a>.</p> <ul> <li><a href="qxtpipe-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h3>Public Functions</h3> <ul> <li><div class="fn"></div><b><a href="qxtpipe.html#QxtPipe">QxtPipe</a></b> ( QObject * <i>parent</i> = 0 )</li> <li><div class="fn"></div>bool <b><a href="qxtpipe.html#connect">connect</a></b> ( QxtPipe * <i>other</i>, QIODevice::OpenMode <i>mode</i> = QIODevice::ReadWrite, Qt::ConnectionType <i>connectionType</i> = Qt::AutoConnection )</li> <li><div class="fn"></div>bool <b><a href="qxtpipe.html#disconnect">disconnect</a></b> ( QxtPipe * <i>other</i> )</li> <li><div class="fn"></div>QxtPipe & <b><a href="qxtpipe.html#operator-7c">operator|</a></b> ( QxtPipe & <i>target</i> )</li> </ul> <ul> <li><div class="fn"></div>33 public functions inherited from <a href="http://doc.qtsoftware.com/4.5/qiodevice.html#public-functions">QIODevice</a></li> <li><div class="fn"></div>29 public functions inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#public-functions">QObject</a></li> </ul> <a name="protected-functions"></a> <h3>Protected Functions</h3> <ul> <li><div class="fn"></div>void <b><a href="qxtpipe.html#enqueData">enqueData</a></b> ( QByteArray <i>datab</i> )</li> <li><div class="fn"></div>virtual void <b><a href="qxtpipe.html#receiveData">receiveData</a></b> ( QByteArray <i>datab</i>, const QxtPipe * <i>sender</i> )</li> <li><div class="fn"></div>void <b><a href="qxtpipe.html#sendData">sendData</a></b> ( QByteArray <i>data</i> ) const</li> </ul> <ul> <li><div class="fn"></div>5 protected functions inherited from <a href="http://doc.qtsoftware.com/4.5/qiodevice.html#protected-functions">QIODevice</a></li> <li><div class="fn"></div>7 protected functions inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#protected-functions">QObject</a></li> </ul> <h3>Additional Inherited Members</h3> <ul> <li><div class="fn"></div>1 property inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#properties">QObject</a></li> <li><div class="fn"></div>1 public slot inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#public-slots">QObject</a></li> <li><div class="fn"></div>4 signals inherited from <a href="http://doc.qtsoftware.com/4.5/qiodevice.html#signals">QIODevice</a></li> <li><div class="fn"></div>1 signal inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#signals">QObject</a></li> <li><div class="fn"></div>1 public type inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#public-variables">QObject</a></li> <li><div class="fn"></div>4 static public members inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#static-public-members">QObject</a></li> <li><div class="fn"></div>2 protected variables inherited from <a href="http://doc.qtsoftware.com/4.5/qobject.html#protected-variables">QObject</a></li> </ul> <a name="details"></a> <hr /> <h2>Detailed Description</h2> <p>* * *</p> <p>The QxtPipe class provides a pipeable <a href="http://doc.qtsoftware.com/4.5/qiodevice.html">QIODevice</a> * * pipes can be connected to other pipes, to exchange data * The default implementation uses a buffer. * Reimplement to make your custom class able to be connected into a pipe chain. * * Example usage: *</p> <pre> * QxtPipe p1; * QxtPipe p2; * QxtPipe p3; * p1|p2|p3; * p1.write("hi. how are you?"); * qDebug()<<p3.readAll(); * p3.write("I'm fine, thanks."); * qDebug()<<p1.readAll(); *</pre> <p><h4>Subclassing</h4> When implementing your own pipe element, like a de/encoder or something, you have to reimplement <a href="qxtpipe.html#receiveData">receiveData</a>() and call <a href="qxtpipe.html#sendData">sendData</a>() whenever you have something to send to the pipe network.</p> <p>If you want to the user to be able to read from the device directly via the <a href="http://doc.qtsoftware.com/4.5/qiodevice.html">QIODevice</a> facility you have to call enqueuData() too</p> <p>If you don't want to the user to be able to write to the device directly via the <a href="http://doc.qtsoftware.com/4.5/qiodevice.html">QIODevice</a> facility (that would be fatal for a decoder, for example), then reimplement the functions <a href="http://doc.qtsoftware.com/4.5/qiodevice.html#readData">readData</a>() and <a href="http://doc.qtsoftware.com/4.5/qiodevice.html#writeData">writeData</a>() and return 0.</p> <p>See also <a href="qxtdeplex.html">QxtDeplex</a>.</p> <hr /> <h2>Member Function Documentation</h2> <h3 class="fn"><a name="QxtPipe"></a>QxtPipe::QxtPipe ( <a href="http://doc.qtsoftware.com/4.5/qobject.html">QObject</a> * <i>parent</i> = 0 )</h3> <p>Contructs a new <a href="qxtpipe.html">QxtPipe</a> with <i>parent</i>.</p> <h3 class="fn"><a name="connect"></a>bool QxtPipe::connect ( QxtPipe * <i>other</i>, <a href="http://doc.qtsoftware.com/4.5/qiodevice.html#OpenMode-typedef">QIODevice::OpenMode</a> <i>mode</i> = QIODevice::ReadWrite, <a href="http://doc.qtsoftware.com/4.5/qt.html#ConnectionType-enum">Qt::ConnectionType</a> <i>connectionType</i> = Qt::AutoConnection )</h3> <p>Pipes the output of this instance to the <i>other</i> <a href="qxtpipe.html">QxtPipe</a> using the given <i>mode</i> and <i>connectionType</i>. Returns <tt>true</tt> if succeeds. Connection pipes with this function can be considered thread safe.</p> <p>Example usage:</p> <pre> QxtPipe p1; QxtPipe p2; p1.connect(&p2,QIODevice::ReadOnly); <span class="comment"> //this data will go nowhere. p2 is connected to p1, but not p2 to p1.</span> p1.write("hello"); <span class="comment"> //while this data will end up in p1</span> p2.write("world"); qDebug()<<p1.readAll();</pre> <h3 class="fn"><a name="disconnect"></a>bool QxtPipe::disconnect ( QxtPipe * <i>other</i> )</h3> <p>Cuts the connection to the <i>other</i> <a href="qxtpipe.html">QxtPipe</a> and returns <tt>true</tt> if succeeds.</p> <h3 class="fn"><a name="enqueData"></a>void QxtPipe::enqueData ( <a href="http://doc.qtsoftware.com/4.5/qbytearray.html">QByteArray</a> <i>datab</i> ) <tt> [protected]</tt></h3> <p>Call this from your subclass to make <i>datab</i> available to the QIODevice::read facility</p> <h3 class="fn"><a name="receiveData"></a>void QxtPipe::receiveData ( <a href="http://doc.qtsoftware.com/4.5/qbytearray.html">QByteArray</a> <i>datab</i>, const QxtPipe * <i>sender</i> ) <tt> [virtual protected]</tt></h3> <p>This function is called from any connected pipe to input <i>datab</i> from <i>sender</i> into this instance. Reimplement this function to handle data from the pipe network.</p> <p>The default implementation calls <a href="qxtpipe.html#enqueData">enqueData</a>() and <a href="qxtpipe.html#sendData">sendData</a>().</p> <h3 class="fn"><a name="sendData"></a>void QxtPipe::sendData ( <a href="http://doc.qtsoftware.com/4.5/qbytearray.html">QByteArray</a> <i>data</i> ) const <tt> [protected]</tt></h3> <p>Call this from your subclass to write <i>data</i> to the pipe network. All write connected pipes will be invoked with receiveData In this case this is called from receiveData, the sender will be excluded from the receiver list.</p> <h3 class="fn"><a name="operator-7c"></a>QxtPipe & QxtPipe::operator| ( QxtPipe & <i>target</i> )</h3> <p>Convenience function for <a href="qxtpipe.html#connect">QxtPipe::connect</a>(). Pipes the output of this instance to the <i>target</i> <a href="qxtpipe.html">QxtPipe</a> in readwrite mode with auto connection.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td align="left">Copyright © 2007-2010 <a href="mailto:foundation@libqxt.org">Qxt Foundation</a></td> <td align="right"><div align="right"> <a href="http://libqxt.org">Qxt</a> 0.6.1</div></td> </tr></table></div></address></body> </html>