IBR-DTNSuite
0.12
Main Page
Namespaces
Classes
Files
File List
File Members
TransferAbortedEvent.cpp
Go to the documentation of this file.
1
/*
2
* TransferAbortedEvent.cpp
3
*
4
* Copyright (C) 2011 IBR, TU Braunschweig
5
*
6
* Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7
*
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
11
*
12
* http://www.apache.org/licenses/LICENSE-2.0
13
*
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
19
*
20
*/
21
22
#include "
net/TransferAbortedEvent.h
"
23
#include "
core/EventDispatcher.h
"
24
25
namespace
dtn
26
{
27
namespace
net
28
{
29
TransferAbortedEvent::TransferAbortedEvent(
const
dtn::data::EID
&peer,
const
dtn::data::BundleID
&
id
,
const
AbortReason r)
30
: reason(r), _peer(peer), _bundle(id)
31
{
32
}
33
34
TransferAbortedEvent::~TransferAbortedEvent
()
35
{
36
37
}
38
39
void
TransferAbortedEvent::raise
(
const
dtn::data::EID
&peer,
const
dtn::data::BundleID
&
id
,
const
AbortReason
r)
40
{
41
// raise the new event
42
dtn::core::EventDispatcher<TransferAbortedEvent>::queue
(
new
TransferAbortedEvent
(peer,
id
, r) );
43
}
44
45
const
std::string
TransferAbortedEvent::getName
()
const
46
{
47
return
TransferAbortedEvent::className
;
48
}
49
50
const
dtn::data::EID
&
TransferAbortedEvent::getPeer
()
const
51
{
52
return
_peer;
53
}
54
55
const
dtn::data::BundleID
&
TransferAbortedEvent::getBundleID
()
const
56
{
57
return
_bundle;
58
}
59
60
const
std::string TransferAbortedEvent::getReason(
const
AbortReason reason)
61
{
62
switch
(reason)
63
{
64
case
REASON_UNDEFINED
:
65
return
"undefined"
;
66
67
case
REASON_CONNECTION_DOWN
:
68
return
"connection went down"
;
69
70
case
REASON_REFUSED
:
71
return
"bundle has been refused"
;
72
73
case
REASON_RETRY_LIMIT_REACHED
:
74
return
"retry limit reached"
;
75
76
case
REASON_BUNDLE_DELETED
:
77
return
"bundle has been deleted"
;
78
}
79
80
return
"undefined"
;
81
}
82
83
string
TransferAbortedEvent::getMessage
()
const
84
{
85
return
"transfer of bundle "
+ _bundle.
toString
() +
" to "
+ _peer.
getString
() +
" aborted. ("
+ getReason(reason) +
")"
;
86
}
87
88
const
std::string
TransferAbortedEvent::className
=
"TransferAbortedEvent"
;
89
}
90
}
daemon
src
net
TransferAbortedEvent.cpp
Generated on Thu Mar 27 2014 09:26:20 for IBR-DTNSuite by
1.8.4