BadPacket.cpp

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 #include "Qt.h"
00024 #include "BadPacket.h"
00025 #include "Imports.cpp"
00026 
00027 QString BadPacket::name() const
00028 {
00029     return "BadPacket";
00030 }
00031 
00032 auto_ptr <DataBase> BadPacket::copy() const
00033 {
00034     return auto_ptr <DataBase> (new BadPacket (*this));
00035 }
00036 
00038 
00040 BadPacket::BadPacket (PacketType type,
00041                       const QByteArray &rawHeader,
00042                       const QByteArray &rawPayload)
00043     : PacketBase (new Data, type)
00044 {
00045     Q_SD (Data);
00046     d->rawHeader        = rawHeader;
00047     d->rawPayload       = rawPayload;
00048     d->rewriteHeader    = false;
00049     d->rewritePayload   = false;
00050 }
00051 
00052 void BadPacket::invalidateHeader()
00053 {
00054     Q_ASSERT (false && "Modifying header fields of BadPackets not allowed!");
00055 }
00056 
00057 void BadPacket::invalidatePayload()
00058 {
00059     Q_ASSERT (false && "Modifying payload fields of BadPackets not allowed!");
00060 }
00061 
00063 bool BadPacket::readHeader (const QByteArray &)
00064 {
00065     return true;
00066 }
00067 
00069 bool BadPacket::readPayload (const QByteArray &)
00070 {
00071     return false;
00072 }
00073 
00074 QByteArray BadPacket::writeHeader() const
00075 {
00076     Q_ASSERT (false && "BadPackets cannot be rebuilt!");
00077     return QByteArray();
00078 }
00079 
00080 QByteArray BadPacket::writePayload() const
00081 {
00082     Q_ASSERT (false && "BadPackets cannot be rebuilt!");
00083     return QByteArray();
00084 }
00085 
00086 void BadPacket::readPayload (BinaryReader &)
00087 {
00088     Q_ASSERT (false && "BadPacket must never be parsed!");
00089 }
00090 
00091 void BadPacket::writePayload (BinaryWriter &) const
00092 {
00093     Q_ASSERT (false && "BadPacket must never be parsed!");
00094 }