IBR-DTN  1.0.0
EpidemicRoutingExtension.h
Go to the documentation of this file.
1 /*
2  * EpidemicRoutingExtension.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 EPIDEMICROUTINGEXTENSION_H_
23 #define EPIDEMICROUTINGEXTENSION_H_
24 
25 #include "core/Node.h"
26 #include "core/AbstractWorker.h"
27 #include "core/EventReceiver.h"
28 
32 
33 #include <ibrdtn/data/Block.h>
34 #include <ibrdtn/data/SDNV.h>
37 
38 #include <ibrcommon/thread/Queue.h>
39 #include <ibrcommon/thread/Thread.h>
40 
41 #include <list>
42 #include <queue>
43 
44 namespace dtn
45 {
46  namespace routing
47  {
48  class EpidemicRoutingExtension : public RoutingExtension, public ibrcommon::JoinableThread, public dtn::core::EventReceiver<dtn::routing::NodeHandshakeEvent>
49  {
50  static const std::string TAG;
51 
52  public:
54  virtual ~EpidemicRoutingExtension();
55 
56  virtual const std::string getTag() const throw ();
57 
58  virtual void eventDataChanged(const dtn::data::EID &peer) throw ();
59 
60  virtual void eventBundleQueued(const dtn::data::EID &peer, const dtn::data::MetaBundle &meta) throw ();
61 
62  void raiseEvent(const dtn::routing::NodeHandshakeEvent &evt) throw ();
63  void componentUp() throw ();
64  void componentDown() throw ();
65 
69  virtual void requestHandshake(const dtn::data::EID&, NodeHandshake&) const;
70 
71  protected:
72  void run() throw ();
73  void __cancellation() throw ();
74 
75  private:
76  class Task
77  {
78  public:
79  virtual ~Task() {};
80  virtual std::string toString() = 0;
81  };
82 
83  class SearchNextBundleTask : public Task
84  {
85  public:
86  SearchNextBundleTask(const dtn::data::EID &eid);
87  virtual ~SearchNextBundleTask();
88 
89  virtual std::string toString();
90 
91  const dtn::data::EID eid;
92  };
93 
97  ibrcommon::Queue<EpidemicRoutingExtension::Task* > _taskqueue;
98  };
99  }
100 }
101 
102 #endif /* EPIDEMICROUTINGEXTENSION_H_ */
virtual void requestHandshake(const dtn::data::EID &, NodeHandshake &) const
virtual void eventDataChanged(const dtn::data::EID &peer)
void raiseEvent(const dtn::routing::NodeHandshakeEvent &evt)
virtual void eventBundleQueued(const dtn::data::EID &peer, const dtn::data::MetaBundle &meta)
virtual const std::string getTag() const