Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

PacketData.hh

Go to the documentation of this file.
00001 // $Id: PacketData.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #ifndef HH_SENF_Packets_PacketData_
00027 #define HH_SENF_Packets_PacketData_ 1
00028 
00029 // Custom includes
00030 #include <boost/utility.hpp>
00031 #include <boost/type_traits.hpp>
00032 #include <senf/Utils/Exception.hh>
00033 
00034 //#include "PacketData.mpp"
00035 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00036 
00037 namespace senf {
00038 
00067     class PacketData
00068         : boost::noncopyable
00069     {
00070     public:
00071         //-////////////////////////////////////////////////////////////////////////
00072         // Types
00073 
00074         typedef senf::detail::packet::iterator iterator;
00075         typedef senf::detail::packet::const_iterator const_iterator;
00076         typedef senf::detail::packet::size_type size_type;
00077         typedef senf::detail::packet::difference_type difference_type;
00078         typedef senf::detail::packet::byte byte;
00079         typedef byte value_type;
00080         typedef byte & reference;
00081         typedef byte const & const_reference;
00082         typedef byte * pointer;
00083         typedef byte const * const_pointer;
00084 
00085         //-////////////////////////////////////////////////////////////////////////
00087         //\{
00088 
00089         // no public constructors
00090         // no conversion constructors
00091 
00092         //\}
00093         //-////////////////////////////////////////////////////////////////////////
00094 
00096         //\{
00097 
00098         iterator begin() const; 
00099 
00101         iterator end() const; 
00102 
00104         size_type size() const; 
00105         bool empty() const; 
00106 
00109         byte operator[](size_type n) const; 
00110         byte & operator[](size_type n); 
00111 
00112         // Modifying the raw packet data
00113 
00114         // IMPORTANT NOTE: It is not possible to insert data AFTER an empty packet
00115         // since for an empty packet begin() == end(). However, I hope this problem is
00116         // only academic since what should an empty packet be good for ?
00117         void insert(iterator pos, byte v);
00118         void insert(iterator pos, size_type n, byte v);
00119 #       ifndef DOXYGEN
00120         template <class InputIterator>
00121         void insert(iterator pos, InputIterator f, InputIterator l,
00122                     typename boost::disable_if< boost::is_convertible<InputIterator,size_type> >::type * = 0);
00123 #       else
00124         template <class InputIterator>
00125         void insert(iterator pos, InputIterator f, InputIterator l);
00126 #       endif
00127 
00128         void erase(iterator pos);
00129         void erase(iterator first, iterator last);
00130         void clear(); 
00131 
00132         void resize(size_type n, byte v=0);
00133 
00134         void reserve(size_type n);
00135         size_type capacity() const;
00136 
00137         //\}
00138 
00139     protected:
00140         PacketData(size_type b, size_type e);
00141 
00143         detail::PacketImpl * impl_;
00144 
00145         detail::PacketImpl & impl() const;
00146 
00147         bool valid();
00148 
00149     private:
00150         size_type begin_;
00151         size_type end_;
00152 
00153         friend class detail::PacketImpl;
00154     };
00155 
00156     class PacketParserBase;
00157 
00163     struct TruncatedPacketException : public senf::Exception
00164     { TruncatedPacketException() : senf::Exception("truncated packet") {} };
00165 
00166 }
00167 
00168 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00169 #endif
00170 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_PacketData_i_)
00171 #define HH_SENF_Packets_PacketData_i_
00172 #include "PacketData.cci"
00173 //#include "PacketData.ct"
00174 #include "PacketData.cti"
00175 #endif
00176 
00177 
00178 // Local Variables:
00179 // mode: c++
00180 // fill-column: 100
00181 // c-file-style: "senf"
00182 // indent-tabs-mode: nil
00183 // ispell-local-dictionary: "american"
00184 // compile-command: "scons -u test"
00185 // comment-column: 40
00186 // End:
00187 

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research