INET Framework for OMNeT++/OMNEST
inet::TLVOptions Class Reference

#include <TLVOption.h>

Inheritance diagram for inet::TLVOptions:
inet::TLVOptions_Base

Public Types

typedef std::vector< TLVOptionBase * > TLVOptionVector
 

Public Member Functions

 TLVOptions ()
 
 ~TLVOptions ()
 
 TLVOptions (const TLVOptions &other)
 
TLVOptionsoperator= (const TLVOptions &other)
 
virtual TLVOptionsdup () const override
 
int size () const
 
void clear ()
 Makes the container empty. More...
 
void add (TLVOptionBase *option, int atPos=-1)
 
TLVOptionBaseremove (TLVOptionBase *option)
 
void deleteOptionByType (int type, bool firstOnly=true)
 
TLVOptionBaseat (int m)
 
TLVOptionBaseoperator[] (int m)
 
virtual int getLength () const
 
int findByType (short int type, int firstPos=0) const
 
virtual void setTlvOptionArraySize (unsigned int size) override
 
virtual unsigned int getTlvOptionArraySize () const override
 
virtual TLVOptionBasegetTlvOption (unsigned int k) override
 
virtual void setTlvOption (unsigned int k, const TLVOptionBase &tlvOption) override
 
virtual void parsimPack (cCommBuffer *b) const override
 
virtual void parsimUnpack (cCommBuffer *b) override
 
- Public Member Functions inherited from inet::TLVOptions_Base
virtual ~TLVOptions_Base ()
 
virtual void parsimPack (omnetpp::cCommBuffer *b) const override
 
virtual void parsimUnpack (omnetpp::cCommBuffer *b) override
 
virtual const TLVOptionBasegetTlvOption (unsigned int k) const
 

Private Member Functions

void copy (const TLVOptions &other)
 

Private Attributes

TLVOptionVector optionVector
 

Additional Inherited Members

- Protected Member Functions inherited from inet::TLVOptions_Base
bool operator== (const TLVOptions_Base &)
 
 TLVOptions_Base ()
 
 TLVOptions_Base (const TLVOptions_Base &other)
 
TLVOptions_Baseoperator= (const TLVOptions_Base &other)
 

Member Typedef Documentation

Constructor & Destructor Documentation

inet::TLVOptions::TLVOptions ( )
inline
inet::TLVOptions::~TLVOptions ( )
inline
39 { clear(); }
void clear()
Makes the container empty.
Definition: TLVOption.cc:75
inet::TLVOptions::TLVOptions ( const TLVOptions other)
inline
40 : TLVOptions_Base(other) { copy(other); }
void copy(const TLVOptions &other)
Definition: TLVOption.cc:27

Member Function Documentation

void inet::TLVOptions::add ( TLVOptionBase option,
int  atPos = -1 
)

Referenced by inet::IPv4Datagram::addOption(), and inet::GPSR::setGpsrOptionOnNetworkDatagram().

42 {
43  ASSERT(opt->getLength() >= 1);
44  if (atPos == -1)
45  optionVector.push_back(opt);
46  else
47  optionVector.insert(optionVector.begin() + atPos, opt);
48 }
TLVOptionVector optionVector
Definition: TLVOption.h:34
TLVOptionBase& inet::TLVOptions::at ( int  m)
inline

Referenced by inet::GPSR::findGpsrOptionInNetworkDatagram().

69 { return *optionVector.at(m); }
TLVOptionVector optionVector
Definition: TLVOption.h:34
value< double, units::m > m
Definition: Units.h:1047
void inet::TLVOptions::clear ( )

Makes the container empty.

Contained objects will be deleted.

76 {
77  for (auto opt: optionVector)
78  delete opt;
79  optionVector.clear();
80 }
TLVOptionVector optionVector
Definition: TLVOption.h:34
void inet::TLVOptions::copy ( const TLVOptions other)
private
28 {
29  for (auto opt: other.optionVector)
30  optionVector.push_back(opt->dup());
31 }
TLVOptionVector optionVector
Definition: TLVOption.h:34
void inet::TLVOptions::deleteOptionByType ( int  type,
bool  firstOnly = true 
)
61 {
62  auto it = optionVector.begin();
63  while (it != optionVector.end()) {
64  if ((*it)->getType() == type) {
65  delete (*it);
66  it = optionVector.erase(it);
67  if (firstOnly)
68  break;
69  }
70  else
71  ++it;
72  }
73 }
TLVOptionVector optionVector
Definition: TLVOption.h:34
virtual TLVOptions* inet::TLVOptions::dup ( ) const
inlineoverridevirtual

Reimplemented from inet::TLVOptions_Base.

42 { return new TLVOptions(*this); }
TLVOptions()
Definition: TLVOption.h:38
int inet::TLVOptions::findByType ( short int  type,
int  firstPos = 0 
) const

Referenced by inet::GPSR::findGpsrOptionInNetworkDatagram(), and inet::IPv4Datagram::findOptionByType().

83 {
84  for (unsigned int pos=firstPos; pos < optionVector.size(); pos++)
85  if (optionVector[pos]->getType() == type)
86  return pos;
87  return -1;
88 }
TLVOptionVector optionVector
Definition: TLVOption.h:34
int inet::TLVOptions::getLength ( ) const
virtual

Referenced by inet::IPv4Datagram::calculateHeaderByteLength(), and inet::GPSR::setGpsrOptionOnNetworkDatagram().

34 {
35  int length = 0;
36  for (auto opt: optionVector)
37  length += opt->getLength();
38  return length;
39 }
TLVOptionVector optionVector
Definition: TLVOption.h:34
virtual TLVOptionBase& inet::TLVOptions::getTlvOption ( unsigned int  k)
inlineoverridevirtual

Implements inet::TLVOptions_Base.

90 { return at(k); }
TLVOptionBase & at(int m)
Definition: TLVOption.h:69
const double k
Definition: QAM16Modulation.cc:24
virtual unsigned int inet::TLVOptions::getTlvOptionArraySize ( ) const
inlineoverridevirtual

Implements inet::TLVOptions_Base.

89 { return size(); }
int size() const
Definition: TLVOption.h:44
TLVOptions& inet::TLVOptions::operator= ( const TLVOptions other)
inline
41 { if (this != &other) { TLVOptions_Base::operator=(other); clear(); copy(other); } return *this; }
TLVOptions_Base & operator=(const TLVOptions_Base &other)
void clear()
Makes the container empty.
Definition: TLVOption.cc:75
void copy(const TLVOptions &other)
Definition: TLVOption.cc:27
TLVOptionBase& inet::TLVOptions::operator[] ( int  m)
inline
74 { return at(m); }
TLVOptionBase & at(int m)
Definition: TLVOption.h:69
value< double, units::m > m
Definition: Units.h:1047
void inet::TLVOptions::parsimPack ( cCommBuffer *  b) const
overridevirtual
91 {
93  int s = (int)optionVector.size();
94  doParsimPacking(b, s);
95  for (auto opt: optionVector)
96  b->packObject(opt);
97 }
TLVOptionVector optionVector
Definition: TLVOption.h:34
void doParsimPacking(omnetpp::cCommBuffer *b, const ApplicationPacket &obj)
Definition: ApplicationPacket_m.h:71
virtual void parsimPack(omnetpp::cCommBuffer *b) const override
value< double, units::s > s
Definition: Units.h:1049
value< double, units::m > b
Definition: Units.h:1054
void inet::TLVOptions::parsimUnpack ( cCommBuffer *  b)
overridevirtual
100 {
102  int s;
103  doParsimUnpacking(b, s);
104  for (int i = 0; i < s; i++)
105  optionVector.push_back(check_and_cast<TLVOptionBase *>(b->unpackObject()));
106 }
TLVOptionVector optionVector
Definition: TLVOption.h:34
void doParsimUnpacking(omnetpp::cCommBuffer *b, ApplicationPacket &obj)
Definition: ApplicationPacket_m.h:72
value< double, units::s > s
Definition: Units.h:1049
virtual void parsimUnpack(omnetpp::cCommBuffer *b) override
value< double, units::m > b
Definition: Units.h:1054
TLVOptionBase * inet::TLVOptions::remove ( TLVOptionBase option)
51 {
52  for (auto it = optionVector.begin(); it != optionVector.end(); ++it)
53  if ((*it) == option) {
54  optionVector.erase(it);
55  return option;
56  }
57  return nullptr;
58 }
TLVOptionVector optionVector
Definition: TLVOption.h:34
virtual void inet::TLVOptions::setTlvOption ( unsigned int  k,
const TLVOptionBase tlvOption 
)
inlineoverridevirtual

Implements inet::TLVOptions_Base.

91 { throw cRuntimeError("Do not use it!"); }
virtual void inet::TLVOptions::setTlvOptionArraySize ( unsigned int  size)
inlineoverridevirtual

Implements inet::TLVOptions_Base.

88 { throw cRuntimeError("Do not use it!"); }
int inet::TLVOptions::size ( ) const
inline
44 { return optionVector.size(); }
TLVOptionVector optionVector
Definition: TLVOption.h:34

Member Data Documentation

TLVOptionVector inet::TLVOptions::optionVector
private

The documentation for this class was generated from the following files: