RINASim  October 2016
Documentation of framework for OMNeT++
UserDataField.cc
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 
23 /*
24  * @file UserDataField.cc
25  * @author Marcel Marek (imarek@fit.vutbr.cz)
26  * @date Oct 19, 2014
27  * @brief
28  * @detail
29  */
30 
31 #include <UserDataField.h>
33 
34 UserDataField::UserDataField(const char *name, int kind) : UserDataField_Base(name,kind)
35 {
36  size = 0;
37  sduDelimitFlags = 0;
38  sduSeqNum = 0;
39 
40 }
41 
44  sduSeqNum = other.sduSeqNum;
45  size = other.size;
46 // PDUData::const_iterator it;
47 //
48 // for(it = other.pduData.begin(); it != other.pduData.end(); ++it){
49 // SDU* sdu = (*it)->dup();
50 // take(sdu);
51 // pduData.push_back(sdu);
52 // }
53 }
54 
55 void copy(const UserDataField& other){
56 
57 }
58 
59 
64 //void UserDataField::addData(SDU* data){
65 //
66 //
67 // if(pduData.empty()){
68 // //sduSeqnum is set only for first SDU/fragment in UserDataField
69 // sduSeqNum = data->getSeqNum();
70 // sduDelimitFlags |= SDU_SEQ_NUM_PRESENT;
71 // }
72 // take(data);
73 // pduData.push_back(data);
74 // size += data->getSize();
75 // sduDelimitFlags |= data->getFragType();
76 //
77 //
78 //
79 // //TOOD A2 Handle all delimitFlags (eg noLength)
80 // /* The code below is weird. Left it here for future decryption.
81 // if(data->getDataType() == SDU_COMPLETE_TYPE || (data->getDataType() == SDU_FRAGMENT_TYPE && data->getFragType() == SDU_FRAG_FIRST)){
82 // //TODO B1 SduSeqNum is the first SDU/fragment in userDataField, so it should be set only once.
83 // sduSeqNum = data->getSeqNum();
84 // sduDelimitFlags |= SDU_SEQ_NUM_PRESENT;
85 // }
86 // */
87 //}
88 
89 //SDU* UserDataField::getData(){
90 //
91 // if(pduData.empty()){
92 // return NULL;
93 // }
94 // //TODO B1 What if it is SDU fragment? (fragType_var != 0)
95 // SDU* tmp = pduData.front();
96 // tmp->getFragType();
97 // pduData.erase(pduData.begin());
98 // size -= tmp->getSize();
99 // drop(tmp);
100 // return tmp;
101 //}
102 
104 {
105  return sduDelimitFlags;
106 }
107 
108 unsigned int UserDataField::getSduSeqNum() const
109 {
110  return sduSeqNum;
111 }
112 
113 //void UserDataField::setSduDelimitFlags(unsigned int sduDelimitFlags)
114 //{
115 // this->sduDelimitFlags = sduDelimitFlags;
116 //}
117 
118 unsigned int UserDataField::getSize(){
119  return size;
120 }
121 
123 {
124 // std::vector<SDU*>::iterator it;
125 // for(it = pduData.begin(); it != pduData.end();){
126 // drop(*it);
127 // delete (*it);
128 // it = pduData.erase(it);
129 //
130 // }
131 
132 }
133 
134 void UserDataField::setSduSeqNum(unsigned int sduSeqNum) {
135  this->sduSeqNum = sduSeqNum;
136 }
137 
138 //bool UserDataField::operator<(const UserDataField& other) const
139 //{
140 // if(this->getSduSeqNumPresent() && other.getSduSeqNumPresent())
141 // {
142 // if(this->getSduSeqNum() < other.getSduSeqNum){
143 // return true;
144 // }else if(this->getSduSeqNum() > other.getSduSeqNum){
145 // return false;
146 // }else {
147 // if(this->getFirstFragmen()){
148 // return true;
149 // }else if(other.getFirstFragmen()){
150 // return true;
151 // }else if(this->is)
152 // }
153 //
154 // }
155 //
156 //
157 //}
unsigned int getSduDelimitFlags() const
unsigned int sduDelimitFlags
Definition: UserDataField.h:47
unsigned int sduSeqNum
Definition: UserDataField.h:52
void setSduSeqNum(unsigned int sduSeqNum)
void copy(const UserDataField &other)
unsigned int getSize()
Register_Class(UserDataField)
unsigned int size
Definition: UserDataField.h:54
UserDataField(const char *name=NULL, int kind=0)
unsigned int getSduSeqNum() const
virtual ~UserDataField()