Query.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2005-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__GNUTELLA__PACKETS__QUERY_H
00024 #define PROTOCOLS__GNUTELLA__PACKETS__QUERY_H
00025 
00026 #include "Imports.h"
00027 #include "PacketBase.h"
00028 #include "Extensions/QueryExtension.h"
00029 
00030 namespace Protocols {
00031 namespace Gnutella {
00032 namespace Packets {
00033 
00035 
00038 class Query: public PacketBase
00039 {
00040 public:
00041     QString name() const;
00042     auto_ptr <DataBase> copy() const;
00043 
00044     Query (const MinSpeed &minSpeed = MinSpeed(), const QByteArray &searchCriteria = QByteArray(), const QueryData &extension = QueryData());
00045 
00046     MinSpeed        minSpeed() const;
00047     void        setMinSpeed (const MinSpeed &);
00048 
00049     QByteArray      searchCriteria() const;
00050     void        setSearchCriteria (const QByteArray &);
00051 
00052     QueryData       extension() const;
00053     void        setExtension (const QueryData &);
00054 
00055 protected:
00056     // Unhide all overloads from the base class to avoid a compiler warning:
00057     using PacketBase::readPayload;
00058     using PacketBase::writePayload;
00059 
00060     void        readPayload (BinaryReader &);
00061     void        writePayload (BinaryWriter &) const;
00062 
00064 
00067     class Data: public PacketBase::Data
00068     {
00069         Q_SHARED_DATA_COPY (Data);
00070 
00071     public:
00072         MinSpeed        minSpeed;
00073         QByteArray      searchCriteria;
00074         QueryData       extension;
00075     };
00076 
00077     Q_DECLARE_SHARED_DATA (Data);
00078 };
00079 
00081 inline MinSpeed Query::minSpeed() const
00082 { Q_SD (const Data); return d->minSpeed; }
00083 
00085 inline void Query::setMinSpeed (const MinSpeed & minSpeed)
00086 { Q_SD (Data); invalidatePayload(); d->minSpeed = minSpeed; }
00087 
00089 inline QByteArray Query::searchCriteria() const
00090 { Q_SD (const Data); return d->searchCriteria; }
00091 
00093 inline void Query::setSearchCriteria (const QByteArray & searchCriteria)
00094 { Q_SD (Data); invalidatePayload(); d->searchCriteria = searchCriteria; }
00095 
00097 inline QueryData Query::extension() const
00098 { Q_SD (const Data); return d->extension; }
00099 
00101 inline void Query::setExtension (const QueryData & extension)
00102 { Q_SD (Data); invalidatePayload(); d->extension = extension; }
00103 
00104 } // namespace Packets
00105 } // namespace Gnutella
00106 } // namespace Protocols
00107 
00108 #endif // PROTOCOLS__GNUTELLA__PACKETS__QUERY_H