RINASim  October 2016
Documentation of framework for OMNeT++
CDAPMsgLogEntry.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 #include "CDAPMsgLogEntry.h"
24 
25 CDAPMsgLogEntry::CDAPMsgLogEntry(unsigned char opc, long invoke, bool srflag) :
26  opCode(opc), invokeId(invoke), processedAt(simTime()), sndFlag(srflag)
27 {
28 }
29 
31  opCode = 0;
33  processedAt = 0;
34  sndFlag = false;
35 }
36 
37 std::string CDAPMsgLogEntry::info() const {
38  std::ostringstream os;
39  os << (sndFlag ? "Sent " : "Received " )
40  << getOpCodeString() << "(" << (int)opCode
41  << ")\ninvokeId: " << invokeId << endl
42  << "processed at: " << this->processedAt;
43  return os.str();
44 }
45 
46 std::ostream& operator <<(std::ostream& os, const CDAPMsgLogEntry& mle) {
47  return os << mle.info();
48 }
49 
51  return invokeId;
52 }
53 
54 void CDAPMsgLogEntry::setInvokeId(long invokeId) {
55  this->invokeId = invokeId;
56 }
57 
58 const unsigned char CDAPMsgLogEntry::getOpCode() const {
59  return opCode;
60 }
61 
62 void CDAPMsgLogEntry::setOpCode(const unsigned char opCode) {
63  this->opCode = opCode;
64 }
65 
66 const simtime_t& CDAPMsgLogEntry::getProcessedAt() const {
67  return processedAt;
68 }
69 
70 void CDAPMsgLogEntry::setProcessedAt(const simtime_t& requestedAt) {
71  this->processedAt = requestedAt;
72 }
73 
74 std::string CDAPMsgLogEntry::getOpCodeString() const {
75  switch(this->opCode)
76  {
77  case 1: return "M_CONNECT";
78  case 2: return "M_CONNECT_R";
79  case 3: return "M_RELEASE";
80  case 4: return "M_RELEASE_R";
81  case 5: return "M_CREATE";
82  case 6: return "M_CREATE_R";
83  case 7: return "M_DELETE";
84  case 8: return "M_DELETE_R";
85  case 9: return "M_READ";
86  case 10: return "M_READ_R";
87  case 11: return "M_CANCELREAD";
88  case 12: return "M_CANCELREAD_R";
89  case 13: return "M_WRITE";
90  case 14: return "M_WRITE_R";
91  case 15: return "M_START";
92  case 16: return "M_START_R";
93  case 17: return "M_STOP";
94  case 18: return "M_STOP_R";
95  default: return "UNKNOWN";
96  }
97 }
98 
void setProcessedAt(const simtime_t &requestedAt)
long invokeId
unsigned char opCode
const unsigned char getOpCode() const
const simtime_t & getProcessedAt() const
simtime_t processedAt
bool sndFlag
virtual ~CDAPMsgLogEntry()
CDAPMsgLogEntry(unsigned char opc, long invoke, bool srflag)
void setOpCode(const unsigned char opCode)
std::ostream & operator<<(std::ostream &os, const CDAPMsgLogEntry &mle)
long getInvokeId() const
const int UNINIT_INVOKEID
std::string info() const
void setInvokeId(long invokeId)
std::string getOpCodeString() const