cpacketqueue.h

00001 //==========================================================================
00002 //  CPACKETQUEUE.H - part of
00003 //                     OMNeT++/OMNEST
00004 //            Discrete System Simulation in C++
00005 //
00006 //  Author: Andras Varga
00007 //
00008 //==========================================================================
00009 
00010 /*--------------------------------------------------------------*
00011   Copyright (C) 1992-2008 Andras Varga
00012   Copyright (C) 2006-2008 OpenSim Ltd.
00013 
00014   This file is distributed WITHOUT ANY WARRANTY. See the file
00015   `license' for details on this and other legal matters.
00016 *--------------------------------------------------------------*/
00017 
00018 #ifndef __CPACKETQUEUE_H
00019 #define __CPACKETQUEUE_H
00020 
00021 #include "cqueue.h"
00022 #include "cmessage.h"
00023 
00024 NAMESPACE_BEGIN
00025 
00026 
00034 class SIM_API cPacketQueue : public cQueue
00035 {
00036   private:
00037     int64 bitlength;
00038 
00039   private:
00040     void copy(const cPacketQueue& other);
00041     virtual void insert(cObject *obj);
00042     virtual void insertBefore(cObject *where, cObject *obj);
00043     virtual void insertAfter(cObject *where, cObject *obj);
00044     virtual cObject *remove(cObject *obj);
00045 
00046   protected:
00047     // internal
00048     void addLength(cPacket *pkt);
00049     cPacket *checkPacket(cObject *obj);
00050 
00051   public:
00057     cPacketQueue(const char *name=NULL, CompareFunc cmp=NULL);
00058 
00064     cPacketQueue(const cPacketQueue& queue);
00065 
00073     cPacketQueue& operator=(const cPacketQueue& queue);
00075 
00078 
00084     virtual cPacketQueue *dup() const  {return new cPacketQueue(*this);}
00085 
00090     virtual std::string info() const;
00091 
00097     virtual void parsimPack(cCommBuffer *buffer);
00098 
00104     virtual void parsimUnpack(cCommBuffer *buffer);
00106 
00114     virtual void insert(cPacket *pkt);
00115 
00122     virtual void insertBefore(cPacket *where, cPacket *pkt);
00123 
00130     virtual void insertAfter(cPacket *where, cPacket *pkt);
00131 
00137     virtual cPacket *remove(cPacket *pkt);
00138 
00143     virtual cPacket *pop();
00144 
00149     virtual void clear();
00151 
00158     int64 getBitLength() const  {return bitlength;}
00159 
00164     int64 getByteLength() const  {return (bitlength+7)>>3;}
00165 
00171     virtual cPacket *front() const  {return (cPacket *)cQueue::front();}
00172 
00178     virtual cPacket *back() const  {return (cPacket *)cQueue::back();}
00179 
00185     cPacket *get(int i) const  {return (cPacket *)cQueue::get(i);}
00187 };
00188 
00189 NAMESPACE_END
00190 
00191 
00192 #endif
00193 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3