IBR-DTNSuite  0.12
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::BundleID &id, const AbortReason r)
30  : reason(r), _peer(peer), _bundle(id)
31  {
32  }
33 
35  {
36 
37  }
38 
40  {
41  // raise the new event
43  }
44 
45  const std::string TransferAbortedEvent::getName() const
46  {
48  }
49 
51  {
52  return _peer;
53  }
54 
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 
68  return "connection went down";
69 
70  case REASON_REFUSED:
71  return "bundle has been refused";
72 
74  return "retry limit reached";
75 
77  return "bundle has been deleted";
78  }
79 
80  return "undefined";
81  }
82 
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 }