IBR-DTNSuite  0.10
NodeEvent.cpp
Go to the documentation of this file.
1 /*
2  * NodeEvent.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/NodeEvent.h"
23 #include "core/EventDispatcher.h"
24 
25 using namespace dtn::core;
26 using namespace std;
27 
28 namespace dtn
29 {
30  namespace core
31  {
32  NodeEvent::NodeEvent(const Node &n, const EventNodeAction action)
33  : m_node(n), m_action(action)
34  {
35  switch (action) {
36  case NODE_DATA_ADDED:
37  setLoggable(false);
38  break;
39  case NODE_DATA_REMOVED:
40  setLoggable(false);
41  break;
42  default:
43  break;
44  }
45  }
46 
47  void NodeEvent::raise(const Node &n, const EventNodeAction action)
48  {
50  }
51 
53  {}
54 
55  const Node& NodeEvent::getNode() const
56  {
57  return m_node;
58  }
59 
61  {
62  return m_action;
63  }
64 
65  const string NodeEvent::getName() const
66  {
67  return NodeEvent::className;
68  }
69 
70  string NodeEvent::getMessage() const
71  {
72  switch (getAction())
73  {
74  case NODE_AVAILABLE:
75  return "Node " + getNode().toString() + " available ";
76  case NODE_UNAVAILABLE:
77  return "Node " + getNode().toString() + " unavailable";
78  case NODE_DATA_ADDED:
79  return "Node " + getNode().toString() + " updated, data added";
80  case NODE_DATA_REMOVED:
81  return "Node " + getNode().toString() + " updated, data remove";
82  default:
83  return "unknown";
84  }
85 
86  return "unknown";
87  }
88 
89  const string NodeEvent::className = "NodeEvent";
90  }
91 }