TransportStub.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2006-2007 by Peter Dimov.
00004 
00005 This file is part of Calitko (http://www.calitko.org).
00006 
00007 Calitko is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 Calitko is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Calitko; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 */
00022 
00023 #ifndef PROTOCOLS__GENERICS__TESTING__TRANSPORT_STUB_H
00024 #define PROTOCOLS__GENERICS__TESTING__TRANSPORT_STUB_H
00025 
00026 #include "Imports.h"
00027 #include "../Transport.h"
00028 
00029 namespace Protocols {
00030 namespace Generics {
00031 namespace Testing {
00032 
00034 
00051 class TransportStub : public Transport
00052 {
00053 public:
00054                     TransportStub();
00055 
00056     // Interface Transport::Connection implementation:
00057     void            connectToNode (const Uri &);
00058     void            disconnectFromNode();
00059     void            abort();
00060 
00061     //NodeAddress       ownNodeAddress() const;
00062     //NodeAddress       remoteNodeAddress() const;
00063 
00064     // Interface Transport::Buffer implementation:
00065     bool            canRead (int count) const;
00066 
00067     QByteArray      peek (int count) const;
00068     QByteArray      peekAtMost (int count) const;
00069     QByteArray      peekTo (const QByteArray &delimiter) const;
00070     QByteArray      peekAll() const;
00071 
00072     QByteArray      read (int count);
00073     QByteArray      readAtMost (int count);
00074     QByteArray      readTo (const QByteArray &delimiter);
00075     QByteArray      readAll();
00076 
00077     bool            canWrite (int count) const;
00078 
00079     bool            write (const QByteArray &bytes, bool flush);
00080 
00081     // Interface Transport implementation:
00082     void            setTransportStatus (TransportStatus *);
00083 
00084     // Compatibility with Mock and Driver classes:
00085     operator Transport *();
00086 
00087     // Stub properties:
00088     QByteArray      readBuffer;
00089     QByteArray      writeBuffer;
00090     TransportStatus *status;
00091 };
00092 
00093 } // namespace Testing
00094 } // namespace Generics
00095 } // namespace Protocols
00096 
00097 #endif // PROTOCOLS__GENERICS__TESTING__TRANSPORT_STUB_H