src/common/byte-tag-list.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 03 Jun 2009 08:49:40 +0200
changeset 4502 07d34c0d8d18
parent 3299 src/common/tag-list.h@4c42f0b977ad
child 5050 5c2002bda934
permissions -rw-r--r--
new tags
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3050
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
     2
/*
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
     3
 * Copyright (c) 2008 INRIA
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
     4
 *
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
     7
 * published by the Free Software Foundation;
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
     8
 *
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
    12
 * GNU General Public License for more details.
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
    13
 *
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
    14
 * You should have received a copy of the GNU General Public License
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
    15
 * along with this program; if not, write to the Free Software
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
    17
 *
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
9cc612c6cd32 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3049
diff changeset
    19
 */
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    20
#ifndef BYTE_TAG_LIST_H
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    21
#define BYTE_TAG_LIST_H
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include <stdint.h>
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#include "ns3/type-id.h"
3041
a624276a897b mtag -> tag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3040
diff changeset
    25
#include "tag-buffer.h"
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
namespace ns3 {
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    29
struct ByteTagListData;
3043
4a1ab06f0d63 use a free list for tag buffers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3042
diff changeset
    30
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    31
/**
3182
61fe7fe81ebd Doxygen organization
Tom Henderson <tomh@tomh.org>
parents: 3083
diff changeset
    32
 * \ingroup packet
61fe7fe81ebd Doxygen organization
Tom Henderson <tomh@tomh.org>
parents: 3083
diff changeset
    33
 *
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    34
 * \brief keep track of the tags stored in a packet.
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    35
 *
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    36
 * This class is mostly private to the Packet implementation and users
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    37
 * should never have to access it directly.
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    38
 *
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    39
 * \internal
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    40
 * The implementation of this class is a bit tricky so, there are a couple
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    41
 * of things to keep in mind here:
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    42
 *
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    43
 *   - it stores all tags in a single byte buffer: each tag is stored
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    44
 *     as 4 32bit integers (TypeId, tag data size, start, end) followed 
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    45
 *     by the tag data as generated by Tag::Serialize.
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    46
 *
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    47
 *   - the struct ByteTagListData structure which contains the tag byte buffer
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    48
 *     is shared and, thus, reference-counted. This data structure is unshared
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    49
 *     as-needed to emulate COW semantics.
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    50
 *
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    51
 *   - each tag tags a unique set of bytes identified by the pair of offsets 
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    52
 *     (start,end). These offsets are provided by Buffer::GetCurrentStartOffset
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    53
 *     and Buffer::GetCurrentEndOffset which means that they are relative to 
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    54
 *     the start of the 'virtual byte buffer' as explained in the documentation
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    55
 *     for the ns3::Buffer class. Whenever the origin of the offset of the Buffer
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    56
 *     instance associated to this ByteTagList instance changes, the Buffer class
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    57
 *     reports this to its container Packet class as a bool return value
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    58
 *     in Buffer::AddAtStart and Buffer::AddAtEnd. In both cases, when this happens
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    59
 *     the Packet class calls ByteTagList::AddAtEnd and ByteTagList::AddAtStart to update
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    60
 *     the byte offsets of each tag in the ByteTagList.
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    61
 *
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    62
 *   - whenever bytes are removed from the packet byte buffer, the ByteTagList offsets 
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    63
 *     are never updated because we rely on the fact that they will be updated in
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    64
 *     either the next call to Packet::AddHeader or Packet::AddTrailer or when
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    65
 *     the user iterates the tag list with Packet::GetTagIterator and 
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    66
 *     TagIterator::Next.
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
    67
 */
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    68
class ByteTagList
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
{
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
public:
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
  class Iterator
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
  {
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
  public:
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
    struct Item 
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
    {
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
      TypeId tid;
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
      uint32_t size;
3299
4c42f0b977ad bug 217: avoid unsigned/signed confusion. Used signed all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3223
diff changeset
    79
      int32_t start;
4c42f0b977ad bug 217: avoid unsigned/signed confusion. Used signed all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3223
diff changeset
    80
      int32_t end;
3040
e11e106c7c19 Mtag -> Tag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3035
diff changeset
    81
      TagBuffer buf;
3083
7172d5dcae51 fix build for g++ 3.4.6
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3059
diff changeset
    82
      Item (TagBuffer buf);
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
    private:
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    84
      friend class ByteTagList;
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    85
      friend class ByteTagList::Iterator;
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
    };
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
    bool HasNext (void) const;
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    88
    struct ByteTagList::Iterator::Item Next (void);
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
    uint32_t GetOffsetStart (void) const;
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
  private:
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
    91
    friend class ByteTagList;
3299
4c42f0b977ad bug 217: avoid unsigned/signed confusion. Used signed all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3223
diff changeset
    92
    Iterator (uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd);
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
    void PrepareForNext (void);
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
    uint8_t *m_current;
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
    uint8_t *m_end;
3299
4c42f0b977ad bug 217: avoid unsigned/signed confusion. Used signed all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3223
diff changeset
    96
    int32_t m_offsetStart;
4c42f0b977ad bug 217: avoid unsigned/signed confusion. Used signed all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3223
diff changeset
    97
    int32_t m_offsetEnd;
3056
d4bb2f7687d1 avoid doing the work twice.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3050
diff changeset
    98
    uint32_t m_nextTid;
d4bb2f7687d1 avoid doing the work twice.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3050
diff changeset
    99
    uint32_t m_nextSize;
3299
4c42f0b977ad bug 217: avoid unsigned/signed confusion. Used signed all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3223
diff changeset
   100
    int32_t m_nextStart;
4c42f0b977ad bug 217: avoid unsigned/signed confusion. Used signed all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3223
diff changeset
   101
    int32_t m_nextEnd;
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
  };
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   104
  ByteTagList ();
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   105
  ByteTagList (const ByteTagList &o);
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   106
  ByteTagList &operator = (const ByteTagList &o);
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   107
  ~ByteTagList ();
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   109
  /**
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   110
   * \param tid the typeid of the tag added
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   111
   * \param bufferSize the size of the tag when its serialization will 
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   112
   *        be completed. Typically, the return value of Tag::GetSerializedSize
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   113
   * \param start offset which uniquely identifies the first byte tagged by this tag.
3185
c859e129a934 fix dox warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3083
diff changeset
   114
   * \param end offset which uniquely identifies the last byte tagged by this tag.
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   115
   * \returns a buffer which can be used to write the tag data.     
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   116
   *
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   117
   * 
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   118
   */
3299
4c42f0b977ad bug 217: avoid unsigned/signed confusion. Used signed all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3223
diff changeset
   119
  TagBuffer Add (TypeId tid, uint32_t bufferSize, int32_t start, int32_t end);
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   121
  /**
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   122
   * \param o the other list of tags to aggregate.
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   123
   *
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   124
   * Aggregate the two lists of tags.
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   125
   */
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   126
  void Add (const ByteTagList &o);
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
  void RemoveAll (void);
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   130
  /**
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   131
   * \param offsetStart the offset which uniquely identifies the first data byte 
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   132
   *        present in the byte buffer associated to this ByteTagList.
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   133
   * \param offsetEnd the offset which uniquely identifies the last data byte 
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   134
   *        present in the byte buffer associated to this ByteTagList.
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   135
   * \returns an iterator
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   136
   *
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   137
   * The returned iterator will allow you to loop through the set of tags present
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   138
   * in this list: the boundaries of each tag as reported by their start and
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   139
   * end offsets will be included within the input offsetStart and offsetEnd.
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   140
   */
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   141
  ByteTagList::Iterator Begin (int32_t offsetStart, int32_t offsetEnd) const;
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   142
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   143
  /**
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   144
   * Adjust the offsets stored internally by the adjustment delta and
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   145
   * make sure that all offsets are smaller than appendOffset which represents
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   146
   * the location where new bytes have been added to the byte buffer.
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   147
   */
3299
4c42f0b977ad bug 217: avoid unsigned/signed confusion. Used signed all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3223
diff changeset
   148
  void AddAtEnd (int32_t adjustment, int32_t appendOffset);
3059
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   149
  /**
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   150
   * Adjust the offsets stored internally by the adjustment delta and
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   151
   * make sure that all offsets are bigger than prependOffset which represents
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   152
   * the location where new bytes have been added to the byte buffer.
890b147e1ed6 attempt to document some of the internal details
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3056
diff changeset
   153
   */
3299
4c42f0b977ad bug 217: avoid unsigned/signed confusion. Used signed all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3223
diff changeset
   154
  void AddAtStart (int32_t adjustment, int32_t prependOffset);
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   156
private:
3299
4c42f0b977ad bug 217: avoid unsigned/signed confusion. Used signed all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3223
diff changeset
   157
  bool IsDirtyAtEnd (int32_t appendOffset);
4c42f0b977ad bug 217: avoid unsigned/signed confusion. Used signed all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3223
diff changeset
   158
  bool IsDirtyAtStart (int32_t prependOffset);
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   159
  ByteTagList::Iterator BeginAll (void) const;
3042
d0a9677d5452 use a shared buffer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3041
diff changeset
   160
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   161
  struct ByteTagListData *Allocate (uint32_t size);
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   162
  void Deallocate (struct ByteTagListData *data);
3042
d0a9677d5452 use a shared buffer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3041
diff changeset
   163
d0a9677d5452 use a shared buffer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3041
diff changeset
   164
  uint16_t m_used;
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   165
  struct ByteTagListData *m_data;
3035
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   166
};
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   167
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   168
} // namespace ns3
644bfc099992 a new tag implementation: Mtag
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   169
4502
07d34c0d8d18 new tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3299
diff changeset
   170
#endif /* BYTE_TAG_LIST_H */