IBR-DTNSuite  0.10
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 
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 
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
48  }
49 
51  {
52  // raise the new event
54  }
55 
56  const std::string TransferAbortedEvent::getName() const
57  {
59  }
60 
62  {
63  return _peer;
64  }
65 
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 
79  return "connection went down";
80 
81  case REASON_REFUSED:
82  return "bundle has been refused";
83 
85  return "retry limit reached";
86 
88  return "bundle has been deleted";
89  }
90 
91  return "undefined";
92  }
93 
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 }