PacketHistory.hh
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef PACKETHISTORY_HH_
00018 # define PACKETHISTORY_HH_
00019
00020 # include "Packet.hh"
00021
00029 class PacketHistory
00030 {
00031 public:
00032 PacketHistory();
00033 ~PacketHistory();
00034
00037 void addCopy(const Packet* pkt);
00038
00042 const Packet* at(unsigned int i) const;
00043
00046 unsigned int size() const;
00047
00048 private:
00049 std::vector<Packet*> packets_;
00050 };
00051
00052 inline PacketHistory::PacketHistory()
00053 {
00054 }
00055
00056 inline PacketHistory::~PacketHistory()
00057 {
00058 while (!packets_.empty())
00059 {
00060 free(packets_.back());
00061 packets_.pop_back();
00062 }
00063 }
00064
00065 inline void PacketHistory::addCopy(const Packet* pkt)
00066 {
00067 Packet* pkt_copy = static_cast<Packet*>(malloc(pkt->data_size));
00068 memcpy(pkt_copy, pkt, pkt->data_size);
00069 packets_.push_back(pkt_copy);
00070 }
00071
00072 inline const Packet* PacketHistory::at(unsigned int index) const
00073 {
00074 return packets_.at(index);
00075 }
00076
00077 inline unsigned int PacketHistory::size() const
00078 {
00079 return packets_.size();
00080 }
00081
00082 #endif