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

#include <PIMPacket.h>

Inheritance diagram for inet::PIMHello:
inet::PIMHello_Base inet::PIMPacket

Public Member Functions

 PIMHello (const char *name=nullptr, int kind=0)
 
 PIMHello (const PIMHello &other)
 
virtual ~PIMHello ()
 
PIMHellooperator= (const PIMHello &other)
 
virtual PIMHellodup () const override
 
virtual void parsimPack (cCommBuffer *b) const override
 
virtual void parsimUnpack (cCommBuffer *b) override
 
virtual void setOptionsArraySize (unsigned int size) override
 
virtual unsigned int getOptionsArraySize () const override
 
virtual HelloOptionPtrgetOptions (unsigned int k) override
 
virtual const HelloOptionPtrgetOptions (unsigned int k) const override
 
virtual void setOptions (unsigned int k, const HelloOptionPtr &options) override
 
- Public Member Functions inherited from inet::PIMHello_Base
virtual ~PIMHello_Base ()
 
virtual void parsimPack (omnetpp::cCommBuffer *b) const override
 
virtual void parsimUnpack (omnetpp::cCommBuffer *b) override
 
- Public Member Functions inherited from inet::PIMPacket
 PIMPacket (const char *name=nullptr, short kind=0)
 
 PIMPacket (const PIMPacket &other)
 
virtual ~PIMPacket ()
 
PIMPacketoperator= (const PIMPacket &other)
 
virtual short getVersion () const
 
virtual void setVersion (short version)
 
virtual short getType () const
 
virtual void setType (short type)
 

Protected Member Functions

bool operator== (const PIMHello &)
 
- Protected Member Functions inherited from inet::PIMHello_Base
bool operator== (const PIMHello_Base &)
 
 PIMHello_Base (const char *name=nullptr, short kind=0)
 
 PIMHello_Base (const PIMHello_Base &other)
 
PIMHello_Baseoperator= (const PIMHello_Base &other)
 
- Protected Member Functions inherited from inet::PIMPacket
bool operator== (const PIMPacket &)
 

Protected Attributes

HelloOptionPtroptions_var
 
unsigned int options_arraysize
 
- Protected Attributes inherited from inet::PIMPacket
short version
 
short type
 

Private Member Functions

void copy (const PIMHello &other)
 

Constructor & Destructor Documentation

inet::PIMHello::PIMHello ( const char *  name = nullptr,
int  kind = 0 
)
24  : PIMHello_Base(name, kind)
25 {
26  this->setType(Hello);
27 
29  this->options_var = nullptr;
30 }
unsigned int options_arraysize
Definition: PIMPacket.h:29
virtual void setType(short type)
PIMHello_Base(const char *name=nullptr, short kind=0)
HelloOptionPtr * options_var
Definition: PIMPacket.h:28
Definition: PIMPacket_m.h:62
inet::PIMHello::PIMHello ( const PIMHello other)
32  : PIMHello_Base(other)
33 {
35  this->options_var = nullptr;
36  copy(other);
37 }
unsigned int options_arraysize
Definition: PIMPacket.h:29
PIMHello_Base(const char *name=nullptr, short kind=0)
HelloOptionPtr * options_var
Definition: PIMPacket.h:28
void copy(const PIMHello &other)
Definition: PIMPacket.cc:57
inet::PIMHello::~PIMHello ( )
virtual
40 {
41  if (options_var) {
42  for (unsigned int i = 0; i < options_arraysize; i++)
43  delete options_var[i];
44  }
45  delete[] options_var;
46 }
unsigned int options_arraysize
Definition: PIMPacket.h:29
HelloOptionPtr * options_var
Definition: PIMPacket.h:28

Member Function Documentation

void inet::PIMHello::copy ( const PIMHello other)
private

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

58 {
59  for (unsigned int i = 0; i < options_arraysize; i++)
60  delete options_var[i];
61  delete[] options_var;
62 
63  this->options_var = (other.options_arraysize == 0) ? nullptr : new HelloOptionPtr[other.options_arraysize];
64  options_arraysize = other.options_arraysize;
65  for (unsigned int i = 0; i < options_arraysize; i++)
66  this->options_var[i] = other.options_var[i]->dup();
67 }
unsigned int options_arraysize
Definition: PIMPacket.h:29
HelloOption * HelloOptionPtr
Definition: PIMPacket_m.h:302
virtual HelloOption * dup() const override
Definition: PIMPacket_m.h:124
HelloOptionPtr * options_var
Definition: PIMPacket.h:28
virtual PIMHello* inet::PIMHello::dup ( ) const
inlineoverridevirtual

Reimplemented from inet::PIMHello_Base.

43 { return new PIMHello(*this); }
PIMHello(const char *name=nullptr, int kind=0)
Definition: PIMPacket.cc:24
HelloOptionPtr & inet::PIMHello::getOptions ( unsigned int  k)
overridevirtual

Implements inet::PIMHello_Base.

Referenced by inet::PIMBase::processHelloPacket().

148 {
149  if (k >= options_arraysize)
150  throw cRuntimeError("Array of size %d indexed by %d", options_arraysize, k);
151  return options_var[k];
152 }
unsigned int options_arraysize
Definition: PIMPacket.h:29
HelloOptionPtr * options_var
Definition: PIMPacket.h:28
const double k
Definition: QAM16Modulation.cc:24
virtual const HelloOptionPtr& inet::PIMHello::getOptions ( unsigned int  k) const
inlineoverridevirtual

Reimplemented from inet::PIMHello_Base.

Referenced by getOptions().

51 { return const_cast<PIMHello *>(this)->getOptions(k); }
virtual HelloOptionPtr & getOptions(unsigned int k) override
Definition: PIMPacket.cc:147
PIMHello(const char *name=nullptr, int kind=0)
Definition: PIMPacket.cc:24
const double k
Definition: QAM16Modulation.cc:24
unsigned int inet::PIMHello::getOptionsArraySize ( ) const
overridevirtual

Implements inet::PIMHello_Base.

Referenced by inet::PIMBase::processHelloPacket().

143 {
144  return options_arraysize;
145 }
unsigned int options_arraysize
Definition: PIMPacket.h:29
PIMHello & inet::PIMHello::operator= ( const PIMHello other)
49 {
50  if (this == &other)
51  return *this;
52  PIMPacket::operator=(other);
53  copy(other);
54  return *this;
55 }
PIMPacket & operator=(const PIMPacket &other)
void copy(const PIMHello &other)
Definition: PIMPacket.cc:57
bool inet::PIMHello::operator== ( const PIMHello )
protected
void inet::PIMHello::parsimPack ( cCommBuffer *  b) const
overridevirtual
70 {
72  b->pack(options_arraysize);
73  for (unsigned int i = 0; i < options_arraysize; i++) {
74  if (options_var[i]) {
77  }
78  else
79  doParsimPacking(b, (short int)0);
80  }
81 }
unsigned int options_arraysize
Definition: PIMPacket.h:29
virtual short getType() const
void doParsimPacking(omnetpp::cCommBuffer *b, const ApplicationPacket &obj)
Definition: ApplicationPacket_m.h:71
HelloOptionPtr * options_var
Definition: PIMPacket.h:28
virtual void parsimPack(omnetpp::cCommBuffer *b) const override
value< double, units::m > b
Definition: Units.h:1054
void inet::PIMHello::parsimUnpack ( cCommBuffer *  b)
overridevirtual
84 {
86  for (unsigned int i = 0; i < options_arraysize; i++)
87  delete options_var[i];
88  delete[] this->options_var;
89  b->unpack(options_arraysize);
90  if (options_arraysize == 0) {
91  this->options_var = nullptr;
92  }
93  else {
95  for (unsigned int i = 0; i < options_arraysize; i++) {
96  short int type;
97  doParsimUnpacking(b, type);
98  switch (type) {
99  case 0:
100  options_var[i] = nullptr;
101  break;
102 
103  case Holdtime:
104  options_var[i] = new HoldtimeOption();
105  break;
106 
107  case LANPruneDelay:
108  options_var[i] = new LANPruneDelayOption();
109  break;
110 
111  case DRPriority:
112  options_var[i] = new DRPriorityOption();
113  break;
114 
115  case GenerationID:
116  options_var[i] = new GenerationIDOption();
117  break;
118 
119  //case StateRefreshCapable: TODO break;
120  //case AddressList: break;
121  default:
122  throw cRuntimeError("PIMHello::parsimUnpack(): unknown option type: %sd.", type);
123  }
124  if (options_var[i])
126  }
127  }
128 }
unsigned int options_arraysize
Definition: PIMPacket.h:29
HelloOption * HelloOptionPtr
Definition: PIMPacket_m.h:302
virtual void parsimUnpack(omnetpp::cCommBuffer *b) override
void doParsimUnpacking(omnetpp::cCommBuffer *b, ApplicationPacket &obj)
Definition: ApplicationPacket_m.h:72
HelloOptionPtr * options_var
Definition: PIMPacket.h:28
Definition: PIMPacket_m.h:90
Definition: PIMPacket_m.h:91
Definition: PIMPacket_m.h:92
short type
Definition: PIMPacket_m.h:397
Definition: PIMPacket_m.h:93
value< double, units::m > b
Definition: Units.h:1054
void inet::PIMHello::setOptions ( unsigned int  k,
const HelloOptionPtr options 
)
overridevirtual

Implements inet::PIMHello_Base.

Referenced by inet::PIMBase::sendHelloPacket().

155 {
156  if (k >= options_arraysize)
157  throw cRuntimeError("Array of size %d indexed by %d", options_arraysize, k);
158  delete this->options_var[k];
159  this->options_var[k] = options;
160 }
unsigned int options_arraysize
Definition: PIMPacket.h:29
HelloOptionPtr * options_var
Definition: PIMPacket.h:28
const double k
Definition: QAM16Modulation.cc:24
void inet::PIMHello::setOptionsArraySize ( unsigned int  size)
overridevirtual

Implements inet::PIMHello_Base.

Referenced by inet::PIMBase::sendHelloPacket().

131 {
132  HelloOptionPtr *options_var2 = (size == 0) ? nullptr : new HelloOptionPtr[size];
133  for (unsigned int i = 0; i < size; i++)
134  options_var2[i] = i < options_arraysize ? options_var[i] : nullptr;
135  for (unsigned int i = size; i < options_arraysize; i++)
136  delete options_var[i];
137  options_arraysize = size;
138  delete[] options_var;
139  this->options_var = options_var2;
140 }
unsigned int options_arraysize
Definition: PIMPacket.h:29
HelloOption * HelloOptionPtr
Definition: PIMPacket_m.h:302
HelloOptionPtr * options_var
Definition: PIMPacket.h:28

Member Data Documentation

unsigned int inet::PIMHello::options_arraysize
protected
HelloOptionPtr* inet::PIMHello::options_var
protected

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