IBR-DTNSuite
0.10
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::Bundle
&bundle,
const
AbortReason r)
30
: reason(r), _peer(peer), _bundle(bundle)
31
{
32
}
33
34
TransferAbortedEvent::TransferAbortedEvent(
const
dtn::data::EID
&peer,
const
dtn::data::BundleID
&
id
,
const
AbortReason r)
35
: reason(r), _peer(peer), _bundle(id)
36
{
37
}
38
39
TransferAbortedEvent::~TransferAbortedEvent
()
40
{
41
42
}
43
44
void
TransferAbortedEvent::raise
(
const
dtn::data::EID
&peer,
const
dtn::data::Bundle
&bundle,
const
AbortReason
r)
45
{
46
// raise the new event
47
dtn::core::EventDispatcher<TransferAbortedEvent>::raise
(
new
TransferAbortedEvent
(peer, bundle, r) );
48
}
49
50
void
TransferAbortedEvent::raise
(
const
dtn::data::EID
&peer,
const
dtn::data::BundleID
&
id
,
const
AbortReason
r)
51
{
52
// raise the new event
53
dtn::core::EventDispatcher<TransferAbortedEvent>::raise
(
new
TransferAbortedEvent
(peer,
id
, r) );
54
}
55
56
const
std::string
TransferAbortedEvent::getName
()
const
57
{
58
return
TransferAbortedEvent::className
;
59
}
60
61
const
dtn::data::EID
&
TransferAbortedEvent::getPeer
()
const
62
{
63
return
_peer;
64
}
65
66
const
dtn::data::BundleID
&
TransferAbortedEvent::getBundleID
()
const
67
{
68
return
_bundle;
69
}
70
71
const
std::string TransferAbortedEvent::getReason(
const
AbortReason reason)
72
{
73
switch
(reason)
74
{
75
case
REASON_UNDEFINED
:
76
return
"undefined"
;
77
78
case
REASON_CONNECTION_DOWN
:
79
return
"connection went down"
;
80
81
case
REASON_REFUSED
:
82
return
"bundle has been refused"
;
83
84
case
REASON_RETRY_LIMIT_REACHED
:
85
return
"retry limit reached"
;
86
87
case
REASON_BUNDLE_DELETED
:
88
return
"bundle has been deleted"
;
89
}
90
91
return
"undefined"
;
92
}
93
94
string
TransferAbortedEvent::getMessage
()
const
95
{
96
return
"transfer of bundle "
+ _bundle.
toString
() +
" to "
+ _peer.
getString
() +
" aborted. ("
+ getReason(reason) +
")"
;
97
}
98
99
const
std::string
TransferAbortedEvent::className
=
"TransferAbortedEvent"
;
100
}
101
}
daemon
src
net
TransferAbortedEvent.cpp
Generated on Mon Jul 22 2013 15:16:00 for IBR-DTNSuite by
1.8.3.1