src/declarative/debugger/qpacketprotocol_p.h
changeset 30 5dc02b23752f
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QPACKETPROTOCOL_H
       
    43 #define QPACKETPROTOCOL_H
       
    44 
       
    45 #include <QtCore/qobject.h>
       
    46 #include <QtCore/qdatastream.h>
       
    47 
       
    48 QT_BEGIN_HEADER
       
    49 
       
    50 QT_BEGIN_NAMESPACE
       
    51 
       
    52 QT_MODULE(Declarative)
       
    53 
       
    54 class QIODevice;
       
    55 class QBuffer;
       
    56 class QPacket;
       
    57 class QPacketAutoSend;
       
    58 class QPacketProtocolPrivate;
       
    59 
       
    60 class Q_DECLARATIVE_EXPORT QPacketProtocol : public QObject
       
    61 {
       
    62 Q_OBJECT
       
    63 public:
       
    64     explicit QPacketProtocol(QIODevice * dev, QObject * parent = 0);
       
    65     virtual ~QPacketProtocol();
       
    66 
       
    67     qint32 maximumPacketSize() const;
       
    68     qint32 setMaximumPacketSize(qint32);
       
    69 
       
    70     QPacketAutoSend send();
       
    71     void send(const QPacket &);
       
    72 
       
    73     qint64 packetsAvailable() const;
       
    74     QPacket read();
       
    75 
       
    76     void clear();
       
    77 
       
    78     QIODevice * device();
       
    79 
       
    80 Q_SIGNALS:
       
    81     void readyRead();
       
    82     void invalidPacket();
       
    83     void packetWritten();
       
    84 
       
    85 private:
       
    86     QPacketProtocolPrivate * d;
       
    87 };
       
    88 
       
    89 
       
    90 class Q_DECLARATIVE_EXPORT QPacket : public QDataStream
       
    91 {
       
    92 public:
       
    93     QPacket();
       
    94     QPacket(const QPacket &);
       
    95     virtual ~QPacket();
       
    96 
       
    97     void clear();
       
    98     bool isEmpty() const;
       
    99 
       
   100 protected:
       
   101     friend class QPacketProtocol;
       
   102     QPacket(const QByteArray & ba);
       
   103     QByteArray b;
       
   104     QBuffer * buf;
       
   105 };
       
   106 
       
   107 class Q_DECLARATIVE_EXPORT QPacketAutoSend : public QPacket
       
   108 {
       
   109 public:
       
   110     virtual ~QPacketAutoSend();
       
   111 
       
   112 private:
       
   113     friend class QPacketProtocol;
       
   114     QPacketAutoSend(QPacketProtocol *);
       
   115     QPacketProtocol * p;
       
   116 };
       
   117 
       
   118 QT_END_NAMESPACE
       
   119 
       
   120 QT_END_HEADER
       
   121 
       
   122 #endif