INET Framework for OMNeT++/OMNEST
inet::rtp::SdesItem Class Reference

The class SdesItem is used for storing a source description item (type of description, description string) for an Rtp end system. More...

#include <Sdes.h>

Inheritance diagram for inet::rtp::SdesItem:

Public Types

enum  SdesItemType {
  SDES_UNDEF = 0, SDES_CNAME = 1, SDES_NAME = 2, SDES_EMAIL = 3,
  SDES_PHONE = 4, SDES_LOC = 5, SDES_TOOL = 6, SDES_NOTE = 7,
  SDES_PRIV = 8
}
 This enumeration holds the types of source description items as defined in the RFC. More...
 

Public Member Functions

 SdesItem ()
 Default constructor. More...
 
 SdesItem (SdesItemType type, const char *content)
 Constructor which sets the entry. More...
 
 SdesItem (const SdesItem &sdesItem)
 Copy constructor. More...
 
virtual ~SdesItem ()
 Destructor. More...
 
SdesItemoperator= (const SdesItem &sdesItem)
 Assignment operator. More...
 
virtual SdesItemdup () const override
 Duplicates theis SdesItem by calling the copy constructor. More...
 
virtual std::string str () const override
 Writes a short info about this SdesItem into the given string. More...
 
virtual void dump (std::ostream &os) const
 Writes an info about this SdesItem into the give output stream. More...
 
virtual SdesItemType getType () const
 Returns the type of this sdes item. More...
 
virtual const char * getContent () const
 Returns the stored sdes string. More...
 
virtual int getLengthField () const
 This method returns the length of Value part. More...
 
virtual int getSdesTotalLength () const
 This method returns the size of this SdesItem in bytes as it would be in the real world. More...
 

Protected Attributes

SdesItemType _type
 The type of this SdesItem. More...
 
int _length
 The length of this SdesItem. More...
 
std::string _content
 The sdes string. More...
 

Private Member Functions

void copy (const SdesItem &other)
 
void clean ()
 

Detailed Description

The class SdesItem is used for storing a source description item (type of description, description string) for an Rtp end system.

Member Enumeration Documentation

◆ SdesItemType

This enumeration holds the types of source description items as defined in the RFC.

In this implementation only SDES_UNDEF and SDES_CNAME are usable.

Enumerator
SDES_UNDEF 
SDES_CNAME 
SDES_NAME 
SDES_EMAIL 
SDES_PHONE 
SDES_LOC 
SDES_TOOL 
SDES_NOTE 
SDES_PRIV 
29  {
30  SDES_UNDEF = 0,
31  SDES_CNAME = 1,
32  SDES_NAME = 2,
33  SDES_EMAIL = 3,
34  SDES_PHONE = 4,
35  SDES_LOC = 5,
36  SDES_TOOL = 6,
37  SDES_NOTE = 7,
38  SDES_PRIV = 8
39  };

Constructor & Destructor Documentation

◆ SdesItem() [1/3]

inet::rtp::SdesItem::SdesItem ( )

Default constructor.

18  : cObject()
19 {
20  _type = SDES_UNDEF;
21  _length = 0;
22  _content = "";
23 }

Referenced by dup().

◆ SdesItem() [2/3]

inet::rtp::SdesItem::SdesItem ( SdesItemType  type,
const char *  content 
)

Constructor which sets the entry.

25  : cObject()
26 {
27  if (nullptr == content)
28  throw cRuntimeError("The content parameter must be a valid pointer.");
29  _type = type;
30  _content = content;
31  // an sdes item requires one byte for the type field,
32  // one byte for the length field and bytes for
33  // the content string
34  _length = _content.length();
35 }

◆ SdesItem() [3/3]

inet::rtp::SdesItem::SdesItem ( const SdesItem sdesItem)

Copy constructor.

37  : cObject(sdesItem)
38 {
39  copy(sdesItem);
40 }

◆ ~SdesItem()

inet::rtp::SdesItem::~SdesItem ( )
virtual

Destructor.

43 {
44  clean();
45 }

Member Function Documentation

◆ clean()

void inet::rtp::SdesItem::clean ( )
inlineprivate
104 {} // FIXME The `_content' sometimes allocated, sometimes not allocated pointer.

Referenced by operator=(), and ~SdesItem().

◆ copy()

void inet::rtp::SdesItem::copy ( const SdesItem other)
private
58 {
59  _type = sdesItem._type;
60  _length = sdesItem._length;
61  _content = sdesItem._content;
62 }

Referenced by operator=(), and SdesItem().

◆ dump()

void inet::rtp::SdesItem::dump ( std::ostream &  os) const
virtual

Writes an info about this SdesItem into the give output stream.

77 {
78  os << "SdesItem:" << endl;
79  os << " type = " << _type << endl;
80  os << " content = " << _content << endl;
81 }

◆ dup()

SdesItem * inet::rtp::SdesItem::dup ( ) const
overridevirtual

Duplicates theis SdesItem by calling the copy constructor.

65 {
66  return new SdesItem(*this);
67 }

Referenced by inet::rtp::RtpParticipantInfo::processSDESChunk().

◆ getContent()

const char * inet::rtp::SdesItem::getContent ( ) const
virtual

Returns the stored sdes string.

89 {
90  return _content.c_str();
91 }

◆ getLengthField()

int inet::rtp::SdesItem::getLengthField ( ) const
virtual

This method returns the length of Value part.

94 {
95  // _length contains the length of value without length of Type and Length fields
96  return _length;
97 }

◆ getSdesTotalLength()

int inet::rtp::SdesItem::getSdesTotalLength ( ) const
virtual

This method returns the size of this SdesItem in bytes as it would be in the real world.

100 {
101  // bytes needed for this sdes item are
102  // one byte for type, one for length
103  // and the string
104  return _length + 2;
105 }

Referenced by inet::rtp::SdesChunk::addSDESItem().

◆ getType()

SdesItem::SdesItemType inet::rtp::SdesItem::getType ( ) const
virtual

Returns the type of this sdes item.

84 {
85  return _type;
86 }

Referenced by inet::rtp::SdesChunk::addSDESItem().

◆ operator=()

SdesItem & inet::rtp::SdesItem::operator= ( const SdesItem sdesItem)

Assignment operator.

48 {
49  if (this == &sdesItem)
50  return *this;
51  clean();
52  cObject::operator=(sdesItem);
53  copy(sdesItem);
54  return *this;
55 }

◆ str()

std::string inet::rtp::SdesItem::str ( ) const
overridevirtual

Writes a short info about this SdesItem into the given string.

70 {
71  std::stringstream out;
72  out << "SdesItem=" << _content;
73  return out.str();
74 }

Member Data Documentation

◆ _content

std::string inet::rtp::SdesItem::_content
protected

The sdes string.

Referenced by copy(), dump(), getContent(), SdesItem(), and str().

◆ _length

int inet::rtp::SdesItem::_length
protected

The length of this SdesItem.

Referenced by copy(), getLengthField(), getSdesTotalLength(), and SdesItem().

◆ _type

SdesItemType inet::rtp::SdesItem::_type
protected

The type of this SdesItem.

Referenced by copy(), dump(), getType(), and SdesItem().


The documentation for this class was generated from the following files:
inet::rtp::SdesItem::_length
int _length
The length of this SdesItem.
Definition: Sdes.h:115
inet::rtp::SdesItem::SDES_PRIV
@ SDES_PRIV
Definition: Sdes.h:38
inet::rtp::SdesItem::clean
void clean()
Definition: Sdes.h:104
inet::rtp::SdesItem::SDES_EMAIL
@ SDES_EMAIL
Definition: Sdes.h:33
inet::rtp::SdesItem::_type
SdesItemType _type
The type of this SdesItem.
Definition: Sdes.h:110
inet::rtp::SdesItem::SDES_CNAME
@ SDES_CNAME
Definition: Sdes.h:31
inet::rtp::SdesItem::SDES_NOTE
@ SDES_NOTE
Definition: Sdes.h:37
type
removed type
Definition: IUdp-gates.txt:7
inet::rtp::SdesItem::SdesItem
SdesItem()
Default constructor.
Definition: Sdes.cc:18
inet::rtp::SdesItem::SDES_LOC
@ SDES_LOC
Definition: Sdes.h:35
inet::rtp::SdesItem::_content
std::string _content
The sdes string.
Definition: Sdes.h:120
inet::rtp::SdesItem::copy
void copy(const SdesItem &other)
Definition: Sdes.cc:57
inet::rtp::SdesItem::SDES_UNDEF
@ SDES_UNDEF
Definition: Sdes.h:30
inet::rtp::SdesItem::SDES_NAME
@ SDES_NAME
Definition: Sdes.h:32
inet::rtp::SdesItem::SDES_TOOL
@ SDES_TOOL
Definition: Sdes.h:36
inet::rtp::SdesItem::SDES_PHONE
@ SDES_PHONE
Definition: Sdes.h:34