A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tag.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#ifndef TAG_H
9#define TAG_H
10
11#include "tag-buffer.h"
12
13#include "ns3/object-base.h"
14
15#include <stdint.h>
16
17namespace ns3
18{
19
20/**
21 * @ingroup packet
22 *
23 * @brief tag a set of bytes in a packet
24 *
25 * New kinds of tags can be created by subclassing from this abstract base class.
26 */
27class Tag : public ObjectBase
28{
29 public:
30 /**
31 * @brief Get the type ID.
32 * @return the object TypeId
33 */
34 static TypeId GetTypeId();
35
36 /**
37 * @returns the number of bytes required to serialize the data of the tag.
38 *
39 * This method is typically invoked by Packet::AddPacketTag or Packet::AddByteTag
40 * just prior to calling Tag::Serialize.
41 */
42 virtual uint32_t GetSerializedSize() const = 0;
43 /**
44 * @param i the buffer to write data into.
45 *
46 * Write the content of the tag in the provided tag buffer.
47 * DO NOT attempt to write more bytes than you requested
48 * with Tag::GetSerializedSize.
49 */
50 virtual void Serialize(TagBuffer i) const = 0;
51 /**
52 * @param i the buffer to read data from.
53 *
54 * Read the content of the tag from the provided tag buffer.
55 * DO NOT attempt to read more bytes than you wrote with
56 * Tag::Serialize.
57 */
58 virtual void Deserialize(TagBuffer i) = 0;
59
60 /**
61 * @param os the stream to print to
62 *
63 * This method is typically invoked from the Packet::PrintByteTags
64 * or Packet::PrintPacketTags methods.
65 */
66 virtual void Print(std::ostream& os) const = 0;
67};
68
69} // namespace ns3
70
71#endif /* TAG_H */
Anchor the ns-3 type and attribute system.
read and write tag data
Definition tag-buffer.h:41
tag a set of bytes in a packet
Definition tag.h:28
virtual uint32_t GetSerializedSize() const =0
virtual void Serialize(TagBuffer i) const =0
virtual void Print(std::ostream &os) const =0
virtual void Deserialize(TagBuffer i)=0
static TypeId GetTypeId()
Get the type ID.
Definition tag.cc:16
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.