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:
71  /*
72  * \brief An iterator for iterating through a byte tag list
73  *
74  * An iterator for iterating through a byte tag list
75  *
76  */
77  class Iterator
78  {
79 public:
80  /*
81  * \brief An item specifies an individual tag within a byte buffer
82  *
83  * An item specifies an individual tag within a byte buffer
84  *
85  */
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 
99  /*
100  * \brief Used to determine if the iterator is at the end of the byteTagList
101  *
102  * \returns true if there are more Items in the list
103  */
104  bool HasNext (void) const;
105 
106  /*
107  * \brief Returns the next Item from the ByteTagList
108  *
109  * \returns the next Item in the ByteTagList
110  */
111  struct ByteTagList::Iterator::Item Next (void);
112 
113  /*
114  * \brief Returns the offset from the start of the virtual byte buffer to the ByteTagList
115  *
116  * \returns offset to the start of this ByteTagList
117  */
118  uint32_t GetOffsetStart (void) const;
119 private:
120  friend class ByteTagList;
121  Iterator (uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd);
122  void PrepareForNext (void);
123  uint8_t *m_current;
124  uint8_t *m_end;
125  int32_t m_offsetStart;
126  int32_t m_offsetEnd;
127  uint32_t m_nextTid;
128  uint32_t m_nextSize;
129  int32_t m_nextStart;
130  int32_t m_nextEnd;
131  };
132 
133  ByteTagList ();
134 
143  ByteTagList (const ByteTagList &o);
144 
155  ~ByteTagList ();
156 
167  TagBuffer Add (TypeId tid, uint32_t bufferSize, int32_t start, int32_t end);
168 
174  void Add (const ByteTagList &o);
175 
180  void RemoveAll (void);
181 
193  ByteTagList::Iterator Begin (int32_t offsetStart, int32_t offsetEnd) const;
194 
204  void AddAtEnd (int32_t adjustment, int32_t appendOffset);
214  void AddAtStart (int32_t adjustment, int32_t prependOffset);
215 
216 private:
217  bool IsDirtyAtEnd (int32_t appendOffset);
218  bool IsDirtyAtStart (int32_t prependOffset);
219  ByteTagList::Iterator BeginAll (void) const;
220 
221  struct ByteTagListData *Allocate (uint32_t size);
222  void Deallocate (struct ByteTagListData *data);
223 
224  uint16_t m_used;
226 };
227 
228 } // namespace ns3
229 
230 #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)
struct ByteTagListData * m_data
keep track of the byte tags stored in a packet.
Definition: byte-tag-list.h:68
bool HasNext(void) const
TagBuffer Add(TypeId tid, uint32_t bufferSize, int32_t start, int32_t end)
void Deallocate(struct ByteTagListData *data)
void RemoveAll(void)
Removes all of the tags from the ByteTagList.
uint8_t data[writeSize]
int32_t start
size of tag data
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)
struct ByteTagListData * Allocate(uint32_t size)
uint32_t GetOffsetStart(void) const
int32_t end
offset to the start of the tag from the virtual byte buffer
Definition: byte-tag-list.h:91
ByteTagList::Iterator BeginAll(void) const
uint32_t size
type of the tag
Definition: byte-tag-list.h:89
bool IsDirtyAtStart(int32_t prependOffset)
ByteTagList::Iterator Begin(int32_t offsetStart, int32_t offsetEnd) const
TagBuffer buf
offset to the end of the tag from the virtual byte buffer
Definition: byte-tag-list.h:92
read and write tag data
Definition: tag-buffer.h:51
Item(TagBuffer buf)
the data for the tag as generated by Tag::Serialize
bool IsDirtyAtEnd(int32_t 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...