src/wscout_gui_packet.hh

00001 /*
00002  * WScout - Lightweight PCAP visualizer.
00003  * Copyright (C) 2007  Universite Pierre et Marie Curie - Paris 6
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00018  * MA  02110-1301  USA
00019  *
00020  * Author: Thomas Claveirole <thomas.claveirole@lip6.fr>
00021  */
00022 
00023 #ifndef WSCOUT_GUI_PACKET_HH_
00024 # define WSCOUT_GUI_PACKET_HH_
00025 
00026 # include <vector>
00027 # include <map>
00028 
00029 # include <QtGui/QFrame>
00030 # include <QtGui/QBoxLayout>
00031 
00032 # include "wscout_pcap_trace.hh"
00033 # include "wscout_gui_pcap_header.hh"
00034 # include "wscout_gui_abstract_header.hh"
00035 
00036 namespace wscout
00037 {
00038 
00039   namespace gui
00040   {
00041 
00051     class Packet: public QFrame
00052     {
00053       Q_OBJECT
00054 
00055       enum
00056       {
00058         header_spacing          = 1,
00059 
00061         border_sel              = 4,
00062 
00064         packet_margin_sel       = 0,
00065 
00067         border_unsel            = 1,
00068 
00070         packet_margin_unsel     = 3
00071 
00072       };
00073 
00074     public:
00076       typedef pcap::Trace::iterator::value_type packet;
00077 
00079       typedef pcap::Trace::link_type            link_type;
00080 
00082       Packet(QWidget* parent = 0);
00083 
00086       void              setup(link_type t, unsigned n, const packet& p);
00087 
00089       QBoxLayout*       layout();
00090 
00092       typedef AbstractHeader* (*header_allocator)();
00093 
00107       static void       registerProtocol(protocol::id, header_allocator);
00108 
00110       typedef std::map<protocol::id, header_allocator>  protocol_map;
00111 
00118       static protocol_map&      protocols();
00119 
00120     public slots:
00121 
00123       void                      setSelected(bool state = true);
00124 
00125     private:
00126       int                       lineWidth() const;
00127       int                       margin() const;
00128       void                      setupBorders();
00129       void                      setupLayout();
00130       void                      updateMinimumSize();
00131 
00132 
00133       PcapHeader                        pcap_;
00134       std::vector<AbstractHeader*>      headers_;
00135       bool                              selected_;
00136     };
00137 
00138   } // End of namespace gui.
00139 
00140 } // End of namespace wscout.
00141 
00142 #endif // ! WSCOUT_GUI_PACKET_HH_

Generated on Wed Sep 12 16:02:49 2007 for WScout by  doxygen 1.5.3