IBR-DTNSuite
0.8
|
00001 /* 00002 * BundleReceivedEvent.cpp 00003 * 00004 * Created on: 15.02.2010 00005 * Author: morgenro 00006 */ 00007 00008 #include "net/BundleReceivedEvent.h" 00009 #include "core/BundleCore.h" 00010 #include <ibrcommon/Logger.h> 00011 00012 namespace dtn 00013 { 00014 namespace net 00015 { 00016 BundleReceivedEvent::BundleReceivedEvent(const dtn::data::EID &p, const dtn::data::Bundle &b, const bool &local) 00017 : Event(-1), peer(p), bundle(b), fromlocal(local) 00018 { 00019 00020 } 00021 00022 BundleReceivedEvent::~BundleReceivedEvent() 00023 { 00024 00025 } 00026 00027 void BundleReceivedEvent::raise(const dtn::data::EID &peer, const dtn::data::Bundle &bundle, const bool &local, const bool &wait) 00028 { 00029 // raise the new event 00030 dtn::core::Event::raiseEvent( new BundleReceivedEvent(peer, bundle, local), wait ); 00031 } 00032 00033 const std::string BundleReceivedEvent::getName() const 00034 { 00035 return BundleReceivedEvent::className; 00036 } 00037 00038 std::string BundleReceivedEvent::toString() const 00039 { 00040 if (fromlocal) { 00041 return className + ": Bundle received " + bundle.toString() + " (local)"; 00042 } else { 00043 return className + ": Bundle received " + bundle.toString() + " from " + peer.getString(); 00044 } 00045 } 00046 00047 const string BundleReceivedEvent::className = "BundleReceivedEvent"; 00048 } 00049 }