Content-Based Networking Simulation Library Documentation (v. 1.2.1)

Packet.h

00001 // -*- C++ -*-
00002 //
00003 //  This file is part of CBNSIM, the Content-Based Networking
00004 //  Simulation Library.
00005 //
00006 //  Authors: See the file AUTHORS for full details.
00007 //
00008 //  Copyright (C) 2002-2004 University of Colorado
00009 //
00010 //  This program is free software; you can redistribute it and/or
00011 //  modify it under the terms of the GNU General Public License
00012 //  as published by the Free Software Foundation; either version 2
00013 //  of the License, or (at your option) any later version.
00014 //
00015 //  This program is distributed in the hope that it will be useful,
00016 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //  GNU General Public License for more details.
00019 //
00020 //  You should have received a copy of the GNU General Public License
00021 //  along with this program; if not, write to the Free Software
00022 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
00023 //  USA, or send email to serl@cs.colorado.edu.
00024 //
00025 // $Id: Packet.h,v 1.4 2005/10/03 21:27:17 hallcp Exp $
00026 //
00027 #ifndef CBNSIM_PACKET_H
00028 #define CBNSIM_PACKET_H
00029 
00030 #include <siena/ssim.h>
00031 #include <string>
00032 
00033 namespace cbnsim
00034 {
00038   class Packet : public ssim::Event
00039   {
00040     static unsigned int s_id_counter;
00041 
00042     bool                m_is_control;
00043     const unsigned int  m_id;
00044     ssim::ProcessId     m_sender;
00045     
00046   protected:
00047     Packet( ssim::ProcessId sender, bool is_control )
00048       : m_is_control( is_control ),
00049         m_id( s_id_counter++ ),
00050         m_sender( sender ) {}
00051     
00052   public:
00053     virtual ~Packet() {}
00054 
00057     virtual unsigned int size() const { return 0; }
00058       
00061     unsigned int id() const
00062     { return m_id; }
00063 
00066     bool is_control() const
00067     { return m_is_control; }
00068 
00071     ssim::ProcessId sender() const
00072     { return m_sender; }
00073   };
00074 };
00075 
00076 #endif