IBR-DTNSuite
0.8
|
00001 /* 00002 * TransferAbortedEvent.cpp 00003 * 00004 * Created on: 16.02.2010 00005 * Author: morgenro 00006 */ 00007 00008 #include "net/TransferAbortedEvent.h" 00009 00010 namespace dtn 00011 { 00012 namespace net 00013 { 00014 TransferAbortedEvent::TransferAbortedEvent(const dtn::data::EID &peer, const dtn::data::Bundle &bundle, const AbortReason r) 00015 : reason(r), _peer(peer), _bundle(bundle) 00016 { 00017 } 00018 00019 TransferAbortedEvent::TransferAbortedEvent(const dtn::data::EID &peer, const dtn::data::BundleID &id, const AbortReason r) 00020 : reason(r), _peer(peer), _bundle(id) 00021 { 00022 } 00023 00024 TransferAbortedEvent::~TransferAbortedEvent() 00025 { 00026 00027 } 00028 00029 void TransferAbortedEvent::raise(const dtn::data::EID &peer, const dtn::data::Bundle &bundle, const AbortReason r) 00030 { 00031 // raise the new event 00032 dtn::core::Event::raiseEvent( new TransferAbortedEvent(peer, bundle, r) ); 00033 } 00034 00035 void TransferAbortedEvent::raise(const dtn::data::EID &peer, const dtn::data::BundleID &id, const AbortReason r) 00036 { 00037 // raise the new event 00038 dtn::core::Event::raiseEvent( new TransferAbortedEvent(peer, id, r) ); 00039 } 00040 00041 const std::string TransferAbortedEvent::getName() const 00042 { 00043 return TransferAbortedEvent::className; 00044 } 00045 00046 const dtn::data::EID& TransferAbortedEvent::getPeer() const 00047 { 00048 return _peer; 00049 } 00050 00051 const dtn::data::BundleID& TransferAbortedEvent::getBundleID() const 00052 { 00053 return _bundle; 00054 } 00055 00056 const std::string TransferAbortedEvent::getReason(const AbortReason reason) 00057 { 00058 switch (reason) 00059 { 00060 case REASON_UNDEFINED: 00061 return "undefined"; 00062 00063 case REASON_CONNECTION_DOWN: 00064 return "connection went down"; 00065 00066 case REASON_REFUSED: 00067 return "bundle has been refused"; 00068 00069 case REASON_RETRY_LIMIT_REACHED: 00070 return "retry limit reached"; 00071 00072 case REASON_BUNDLE_DELETED: 00073 return "bundle has been deleted"; 00074 } 00075 00076 return "undefined"; 00077 } 00078 00079 string TransferAbortedEvent::toString() const 00080 { 00081 return className + ": transfer of bundle " + _bundle.toString() + " to " + _peer.getString() + " aborted. (" + getReason(reason) + ")"; 00082 } 00083 00084 const std::string TransferAbortedEvent::className = "TransferAbortedEvent"; 00085 } 00086 }