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