A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
byte-tag-list.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #ifndef BYTE_TAG_LIST_H
21 #define BYTE_TAG_LIST_H
22 
23 #include <stdint.h>
24 #include "ns3/type-id.h"
25 #include "tag-buffer.h"
26 
27 namespace ns3 {
28 
29 struct ByteTagListData;
30 
69 {
70 public:
77  class Iterator
78  {
79 public:
86  struct Item
87  {
89  uint32_t size;
90  int32_t start;
91  int32_t end;
93  Item (TagBuffer buf);
94 private:
95  friend class ByteTagList;
96  friend class ByteTagList::Iterator;
97  };
98 
104  bool HasNext (void) const;
105 
111  struct ByteTagList::Iterator::Item Next (void);
112 
118  uint32_t GetOffsetStart (void) const;
119 private:
120  friend class ByteTagList;
121 
129  Iterator (uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd);
130 
134  void PrepareForNext (void);
135  uint8_t *m_current;
136  uint8_t *m_end;
137  int32_t m_offsetStart;
138  int32_t m_offsetEnd;
139  uint32_t m_nextTid;
140  uint32_t m_nextSize;
141  int32_t m_nextStart;
142  int32_t m_nextEnd;
143  };
144 
145  ByteTagList ();
146 
155  ByteTagList (const ByteTagList &o);
156 
167  ~ByteTagList ();
168 
179  TagBuffer Add (TypeId tid, uint32_t bufferSize, int32_t start, int32_t end);
180 
186  void Add (const ByteTagList &o);
187 
192  void RemoveAll (void);
193 
205  ByteTagList::Iterator Begin (int32_t offsetStart, int32_t offsetEnd) const;
206 
216  void AddAtEnd (int32_t adjustment, int32_t appendOffset);
226  void AddAtStart (int32_t adjustment, int32_t prependOffset);
227 
228 private:
234  bool IsDirtyAtEnd (int32_t appendOffset);
240  bool IsDirtyAtStart (int32_t prependOffset);
241 
247  ByteTagList::Iterator BeginAll (void) const;
248 
254  struct ByteTagListData *Allocate (uint32_t size);
255 
260  void Deallocate (struct ByteTagListData *data);
261 
262  uint16_t m_used;
264 };
265 
266 } // namespace ns3
267 
268 #endif /* BYTE_TAG_LIST_H */
ByteTagList & operator=(const ByteTagList &o)
Assignment operator, deallocates current data and assigns value of passed in ByteTagList.
Iterator(uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd)
Constructor.
struct ByteTagListData * m_data
the ByteTagListData structure
keep track of the byte tags stored in a packet.
Definition: byte-tag-list.h:68
bool HasNext(void) const
Used to determine if the iterator is at the end of the byteTagList.
TagBuffer Add(TypeId tid, uint32_t bufferSize, int32_t start, int32_t end)
uint32_t m_nextTid
TypeId of the next tag.
void Deallocate(struct ByteTagListData *data)
Deallocates a ByteTagListData.
uint8_t * m_current
Current tag.
int32_t m_offsetEnd
Offset to the end of the tag from the virtual byte buffer.
void PrepareForNext(void)
Prepare the iterator for the next tag.
void RemoveAll(void)
Removes all of the tags from the ByteTagList.
Internal representation of the byte tags stored in a packet.
uint32_t m_nextSize
Size of the next tag.
uint8_t data[writeSize]
uint16_t m_used
the number of used bytes in the buffer
int32_t start
offset to the start of the tag from the virtual byte buffer
Definition: byte-tag-list.h:90
void AddAtEnd(int32_t adjustment, int32_t appendOffset)
Adjust the offsets stored internally by the adjustment delta and make sure that all offsets are small...
struct ByteTagList::Iterator::Item Next(void)
Returns the next Item from the ByteTagList.
struct ByteTagListData * Allocate(uint32_t size)
Allocate the memory for the ByteTagListData.
int32_t m_nextStart
Start of the next tag.
uint32_t GetOffsetStart(void) const
Returns the offset from the start of the virtual byte buffer to the ByteTagList.
int32_t end
offset to the end of the tag from the virtual byte buffer
Definition: byte-tag-list.h:91
ByteTagList::Iterator BeginAll(void) const
Returns an iterator pointing to the very first tag in this list.
int32_t m_offsetStart
Offset to the start of the tag from the virtual byte buffer.
TypeId tid
type of the tag
Definition: byte-tag-list.h:88
uint32_t size
size of tag data
Definition: byte-tag-list.h:89
bool IsDirtyAtStart(int32_t prependOffset)
Check that all offsets are bigger than prependOffset.
ByteTagList::Iterator Begin(int32_t offsetStart, int32_t offsetEnd) const
TagBuffer buf
the data for the tag as generated by Tag::Serialize
Definition: byte-tag-list.h:92
An iterator for iterating through a byte tag list.
Definition: byte-tag-list.h:77
read and write tag data
Definition: tag-buffer.h:51
int32_t m_nextEnd
End of the next tag.
Item(TagBuffer buf)
constructs an item with the given TagBuffer
bool IsDirtyAtEnd(int32_t appendOffset)
Check that all offsets are smaller than appendOffset.
a unique identifier for an interface.
Definition: type-id.h:49
void AddAtStart(int32_t adjustment, int32_t prependOffset)
Adjust the offsets stored internally by the adjustment delta and make sure that all offsets are bigge...
uint8_t * m_end
End tag.
An item specifies an individual tag within a byte buffer.
Definition: byte-tag-list.h:86