IBR-DTNSuite  0.12
NeighborRoutingExtension.h
Go to the documentation of this file.
1 /*
2  * NeighborRoutingExtension.h
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 #ifndef NEIGHBORROUTINGEXTENSION_H_
23 #define NEIGHBORROUTINGEXTENSION_H_
24 
27 #include "core/Node.h"
28 
29 #include <ibrdtn/data/MetaBundle.h>
30 #include "ibrdtn/data/EID.h"
31 #include <ibrcommon/thread/Queue.h>
32 #include <list>
33 #include <map>
34 #include <queue>
35 
36 namespace dtn
37 {
38  namespace routing
39  {
41  {
42  static const std::string TAG;
43 
44  public:
46  virtual ~NeighborRoutingExtension();
47 
48  virtual void eventDataChanged(const dtn::data::EID &peer) throw ();
49 
50  virtual void eventBundleQueued(const dtn::data::EID &peer, const dtn::data::MetaBundle &meta) throw ();
51 
52  void componentUp() throw ();
53  void componentDown() throw ();
54 
55  protected:
56  void run() throw ();
57  void __cancellation() throw ();
58 
59  private:
60  class Task
61  {
62  public:
63  virtual ~Task() {};
64  virtual std::string toString() = 0;
65  };
66 
67  class SearchNextBundleTask : public Task
68  {
69  public:
70  SearchNextBundleTask(const dtn::data::EID &eid);
71  virtual ~SearchNextBundleTask();
72 
73  virtual std::string toString();
74 
75  const dtn::data::EID eid;
76  };
77 
78  class ProcessBundleTask : public Task
79  {
80  public:
81  ProcessBundleTask(const dtn::data::MetaBundle &meta, const dtn::data::EID &origin, const dtn::data::EID &nexthop);
82  virtual ~ProcessBundleTask();
83 
84  virtual std::string toString();
85 
86  const dtn::data::MetaBundle bundle;
87  const dtn::data::EID origin;
88  const dtn::data::EID nexthop;
89  };
90 
91  bool shouldRouteTo(const dtn::data::MetaBundle &meta, const NeighborDatabase::NeighborEntry &n) const;
92 
97  };
98  }
99 }
100 
101 #endif /* NEIGHBORROUTINGEXTENSION_H_ */