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.cci

Go to the documentation of this file.
00001 // $Id: PacketData.cci 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 // Custom includes
00027 #include <senf/Utils/senfassert.hh>
00028 #include <iterator>
00029 #include "PacketImpl.hh"
00030 // #include "PacketParser.hh"
00031 
00032 #define prefix_ inline
00033 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00034 
00035 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00036 // senf::PacketData
00037 
00038 prefix_ senf::detail::PacketImpl & senf::PacketData::impl()
00039     const
00040 {
00041     SENF_ASSERT(
00042         impl_,
00043         "Internal failure: PacketData (PacketInterpreter) instance not part of any Packet?");
00044     return *impl_;
00045 }
00046 
00047 prefix_ senf::PacketData::iterator senf::PacketData::begin()
00048     const
00049 {
00050     SENF_ASSERT(begin_ <= impl().size(),
00051                 "Internal failure: PacketInterpreter range outside of data container");
00052     return boost::next(impl().begin(),begin_);
00053 }
00054 
00055 prefix_ senf::PacketData::iterator senf::PacketData::end()
00056     const
00057 {
00058     SENF_ASSERT(end_ <= impl().size(),
00059                 "Internal failure: PacketInterpreter range outside of data container");
00060     return boost::next(impl().begin(),end_);
00061 }
00062 
00063 prefix_ senf::PacketData::size_type senf::PacketData::size()
00064     const
00065 {
00066     return end_ - begin_;
00067 }
00068 
00069 prefix_ bool senf::PacketData::empty()
00070     const
00071 {
00072     return begin_ == end_;
00073 }
00074 
00075 prefix_ senf::PacketData::byte senf::PacketData::operator[](size_type n)
00076     const
00077 {
00078     SENF_ASSERT( n < size(), "Access out of container range" );
00079     return *( boost::next(begin(),n) );
00080 }
00081 
00082 prefix_ senf::PacketData::byte & senf::PacketData::operator[](size_type n)
00083 {
00084     SENF_ASSERT( n < size(), "Access out of container range" );
00085     return *( boost::next(begin(),n) );
00086 }
00087 
00088 // Modifying the raw packet data
00089 
00090 prefix_ void senf::PacketData::insert(iterator pos, byte v)
00091 {
00092     impl().insert(this,pos,v);
00093 }
00094 
00095 prefix_ void senf::PacketData::insert(iterator pos, size_type n, byte v)
00096 {
00097     impl().insert(this,pos,n,v);
00098 }
00099 
00100 prefix_ void senf::PacketData::erase(iterator pos)
00101 {
00102     impl().erase(this,pos);
00103 }
00104 
00105 prefix_ void senf::PacketData::erase(iterator first, iterator last)
00106 {
00107     impl().erase(this,first,last);
00108 }
00109 
00110 prefix_ void senf::PacketData::clear()
00111 {
00112     impl().clear(this);
00113 }
00114 
00115 prefix_ void senf::PacketData::reserve(size_type n)
00116 {
00117     impl().reserve(n + size() - impl().size());
00118 }
00119 
00120 prefix_ senf::PacketData::size_type senf::PacketData::capacity()
00121     const
00122 {
00123     return impl().capacity() - (impl().size() - size());
00124 }
00125 
00126 prefix_ bool senf::PacketData::valid()
00127 {
00128     return impl_;
00129 }
00130 
00131 // protected members
00132 
00133 prefix_ senf::PacketData::PacketData(size_type b, size_type e)
00134     : impl_(), begin_(b), end_(e)
00135 {}
00136 
00137 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00138 #undef prefix_
00139 
00140 
00141 // Local Variables:
00142 // mode: c++
00143 // fill-column: 100
00144 // c-file-style: "senf"
00145 // indent-tabs-mode: nil
00146 // ispell-local-dictionary: "american"
00147 // compile-command: "scons -u test"
00148 // comment-column: 40
00149 // End:

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