IBR-DTN  1.0.0
FileConvergenceLayer.h
Go to the documentation of this file.
1 /*
2  * FileConvergenceLayer.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 #include "Component.h"
23 #include "net/ConvergenceLayer.h"
24 #include "core/NodeEvent.h"
25 #include "core/TimeEvent.h"
26 #include "core/Node.h"
27 #include "core/EventReceiver.h"
28 #include <ibrdtn/data/BundleList.h>
29 #include <ibrcommon/thread/Mutex.h>
30 #include <ibrcommon/thread/Queue.h>
31 
32 #ifndef FILECONVERGENCELAYER_H_
33 #define FILECONVERGENCELAYER_H_
34 
35 namespace dtn
36 {
37  namespace net
38  {
39 
40  class FileConvergenceLayer : public dtn::net::ConvergenceLayer, public dtn::daemon::IndependentComponent, public dtn::core::EventReceiver<dtn::core::NodeEvent>, public dtn::core::EventReceiver<dtn::core::TimeEvent>
41  {
42  public:
44  virtual ~FileConvergenceLayer();
45 
46  void raiseEvent(const dtn::core::NodeEvent &evt) throw ();
47  void raiseEvent(const dtn::core::TimeEvent &evt) throw ();
48 
50 
51  void open(const dtn::core::Node&);
52  void queue(const dtn::core::Node &n, const dtn::net::BundleTransfer &job);
53 
54  const std::string getName() const;
55 
56  protected:
57  void componentUp() throw ();
58  void componentRun() throw ();
59  void componentDown() throw ();
60 
61  void __cancellation() throw ();
62 
63  private:
64  class Task
65  {
66  public:
67  enum Action
68  {
69  TASK_LOAD,
70  TASK_STORE
71  };
72 
73  Task(Action a, const dtn::core::Node &n);
74  virtual ~Task();
75 
76  const Action action;
77  const dtn::core::Node node;
78  };
79 
80  class StoreBundleTask : public Task
81  {
82  public:
83  StoreBundleTask(const dtn::core::Node &n, const dtn::net::BundleTransfer &j);
84  virtual ~StoreBundleTask();
85 
87  };
88 
89  void replyHandshake(const dtn::data::Bundle &bundle, std::list<dtn::data::MetaBundle>&);
90 
91  ibrcommon::Mutex _blacklist_mutex;
92  dtn::data::BundleList _blacklist;
93  ibrcommon::Queue<Task*> _tasks;
94 
95  static ibrcommon::File getPath(const dtn::core::Node&);
96  static std::list<dtn::data::MetaBundle> scan(const ibrcommon::File &path);
97  void load(const dtn::core::Node&);
98 
99  };
100 
101  } /* namespace net */
102 } /* namespace dtn */
103 #endif /* FILECONVERGENCELAYER_H_ */
void open(const dtn::core::Node &)
dtn::core::Node::Protocol getDiscoveryProtocol() const
void raiseEvent(const dtn::core::NodeEvent &evt)
const std::string getName() const
void queue(const dtn::core::Node &n, const dtn::net::BundleTransfer &job)