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  SDES_ITEM_TYPE {
  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 (SDES_ITEM_TYPE 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 info () 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 SDES_ITEM_TYPE getType () const
 Returns the type of this sdes item. More...
 
virtual const char * getContent () const
 Returns the stored sdes string. More...
 
virtual int getLength () const
 This method returns the size of this SDESItem in bytes as it would be in the real world. More...
 

Protected Attributes

SDES_ITEM_TYPE _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

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 
39  {
40  SDES_UNDEF = 0,
41  SDES_CNAME = 1,
42  SDES_NAME = 2,
43  SDES_EMAIL = 3,
44  SDES_PHONE = 4,
45  SDES_LOC = 5,
46  SDES_TOOL = 6,
47  SDES_NOTE = 7,
48  SDES_PRIV = 8
49  };
Definition: sdes.h:43
Definition: sdes.h:47
Definition: sdes.h:48
Definition: sdes.h:46
Definition: sdes.h:42
Definition: sdes.h:41
Definition: sdes.h:44
Definition: sdes.h:40
Definition: sdes.h:45

Constructor & Destructor Documentation

inet::rtp::SDESItem::SDESItem ( )

Default constructor.

Referenced by dup().

28  : cObject()
29 {
30  _type = SDES_UNDEF;
31  _length = 2;
32  _content = "";
33 }
SDES_ITEM_TYPE _type
The type of this SDESItem.
Definition: sdes.h:115
std::string _content
The sdes string.
Definition: sdes.h:125
Definition: sdes.h:40
int _length
The length of this SDESItem.
Definition: sdes.h:120
inet::rtp::SDESItem::SDESItem ( SDES_ITEM_TYPE  type,
const char *  content 
)

Constructor which sets the entry.

35  : cObject()
36 {
37  if (nullptr == content)
38  throw cRuntimeError("The content parameter must be a valid pointer.");
39  _type = type;
40  _content = content;
41  // an sdes item requires one byte for the type field,
42  // one byte for the length field and bytes for
43  // the content string
44  _length = 2 + _content.length();
45 }
SDES_ITEM_TYPE _type
The type of this SDESItem.
Definition: sdes.h:115
std::string _content
The sdes string.
Definition: sdes.h:125
int _length
The length of this SDESItem.
Definition: sdes.h:120
inet::rtp::SDESItem::SDESItem ( const SDESItem sdesItem)

Copy constructor.

47  : cObject(sdesItem)
48 {
49  copy(sdesItem);
50 }
void copy(const SDESItem &other)
Definition: sdes.cc:67
inet::rtp::SDESItem::~SDESItem ( )
virtual

Destructor.

53 {
54  clean();
55 }
void clean()
Definition: sdes.h:109

Member Function Documentation

void inet::rtp::SDESItem::clean ( )
inlineprivate

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

109 {} //FIXME The `_content' sometimes allocated, sometimes not allocated pointer.
void inet::rtp::SDESItem::copy ( const SDESItem other)
private

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

68 {
69  _type = sdesItem._type;
70  _length = sdesItem._length;
71  _content = sdesItem._content;
72 }
SDES_ITEM_TYPE _type
The type of this SDESItem.
Definition: sdes.h:115
std::string _content
The sdes string.
Definition: sdes.h:125
int _length
The length of this SDESItem.
Definition: sdes.h:120
void inet::rtp::SDESItem::dump ( std::ostream &  os) const
virtual

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

87 {
88  os << "SDESItem:" << endl;
89  os << " type = " << _type << endl;
90  os << " content = " << _content << endl;
91 }
SDES_ITEM_TYPE _type
The type of this SDESItem.
Definition: sdes.h:115
std::string _content
The sdes string.
Definition: sdes.h:125
SDESItem * inet::rtp::SDESItem::dup ( ) const
overridevirtual

Duplicates theis SDESItem by calling the copy constructor.

75 {
76  return new SDESItem(*this);
77 }
SDESItem()
Default constructor.
Definition: sdes.cc:28
const char * inet::rtp::SDESItem::getContent ( ) const
virtual

Returns the stored sdes string.

99 {
100  return _content.c_str();
101 }
std::string _content
The sdes string.
Definition: sdes.h:125
int inet::rtp::SDESItem::getLength ( ) const
virtual

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

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

104 {
105  // bytes needed for this sdes item are
106  // one byte for type, one for length
107  // and the string
108  return _length + 2;
109 }
int _length
The length of this SDESItem.
Definition: sdes.h:120
SDESItem::SDES_ITEM_TYPE inet::rtp::SDESItem::getType ( ) const
virtual

Returns the type of this sdes item.

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

94 {
95  return _type;
96 }
SDES_ITEM_TYPE _type
The type of this SDESItem.
Definition: sdes.h:115
std::string inet::rtp::SDESItem::info ( ) const
overridevirtual

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

80 {
81  std::stringstream out;
82  out << "SDESItem=" << _content;
83  return out.str();
84 }
std::string _content
The sdes string.
Definition: sdes.h:125
SDESItem & inet::rtp::SDESItem::operator= ( const SDESItem sdesItem)

Assignment operator.

58 {
59  if (this == &sdesItem)
60  return *this;
61  clean();
62  cObject::operator=(sdesItem);
63  copy(sdesItem);
64  return *this;
65 }
void copy(const SDESItem &other)
Definition: sdes.cc:67
void clean()
Definition: sdes.h:109

Member Data Documentation

std::string inet::rtp::SDESItem::_content
protected

The sdes string.

Referenced by copy(), dump(), getContent(), info(), and SDESItem().

int inet::rtp::SDESItem::_length
protected

The length of this SDESItem.

Referenced by copy(), getLength(), and SDESItem().

SDES_ITEM_TYPE 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: