IBR-DTNSuite  0.10
BundleEvent.cpp
Go to the documentation of this file.
1 /*
2  * BundleEvent.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 "core/BundleEvent.h"
23 #include "core/EventDispatcher.h"
24 
25 namespace dtn
26 {
27  namespace core
28  {
29  BundleEvent::BundleEvent(const dtn::data::MetaBundle &b, const EventBundleAction action, dtn::data::StatusReportBlock::REASON_CODE reason) : m_bundle(b), m_action(action), m_reason(reason)
30  {}
31 
33  {}
34 
36  {
37  return m_bundle;
38  }
39 
41  {
42  return m_action;
43  }
44 
46  {
47  return m_reason;
48  }
49 
50  const std::string BundleEvent::getName() const
51  {
53  }
54 
55  std::string BundleEvent::getMessage() const
56  {
57  switch (getAction())
58  {
59  case BUNDLE_DELETED:
60  return "bundle " + getBundle().toString() + " deleted";
62  return "custody accepted for " + getBundle().toString();
63  case BUNDLE_FORWARDED:
64  return "bundle " + getBundle().toString() + " forwarded";
65  case BUNDLE_DELIVERED:
66  return "bundle " + getBundle().toString() + " delivered";
67  case BUNDLE_RECEIVED:
68  return "bundle " + getBundle().toString() + " received";
69  case BUNDLE_STORED:
70  return "bundle " + getBundle().toString() + " stored";
71  default:
72  break;
73  }
74 
75  return "unkown";
76  }
77 
79  {
80  // raise the new event
81  dtn::core::EventDispatcher<BundleEvent>::raise( new BundleEvent(bundle, action, reason) );
82  }
83 
84  const string BundleEvent::className = "BundleEvent";
85  }
86 }