IBR-DTNSuite  0.10
ExtendedApiHandler.h
Go to the documentation of this file.
1 /*
2  * ExtendedApiHandler.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  * Written-by: Stephen Roettger <roettger@ibr.cs.tu-bs.de>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22 
23 #ifndef EXTENDEDAPIHANDLER_H_
24 #define EXTENDEDAPIHANDLER_H_
25 
26 #include "api/Registration.h"
27 #include "core/Node.h"
28 #include "api/ClientHandler.h"
29 
31 #include <ibrdtn/data/Bundle.h>
33 #include <ibrcommon/thread/Queue.h>
35 
36 
37 namespace dtn
38 {
39  namespace api
40  {
42  {
43  public:
45  {
51  };
52 
54  virtual ~ExtendedApiHandler();
55 
56  virtual void run();
57  virtual void finally();
58  virtual void __cancellation() throw ();
59 
60  bool good() const;
61 
62  private:
63  class Sender : public ibrcommon::JoinableThread
64  {
65  public:
66  Sender(ExtendedApiHandler &conn);
67  virtual ~Sender();
68 
69  protected:
70  void run() throw ();
71  void finally() throw ();
72  void __cancellation() throw ();
73 
74  private:
75  ExtendedApiHandler &_handler;
76  } *_sender;
77 
78  static void sayBundleID(ostream &stream, const dtn::data::BundleID &id);
79  static dtn::data::BundleID readBundleID(const std::vector<std::string>&, const size_t start);
80 
84  void notifyBundle(dtn::data::MetaBundle &bundle);
85 
89  void notifyAdministrativeRecord(dtn::data::MetaBundle &bundle);
90 
91  ibrcommon::Mutex _write_lock;
92 
93  dtn::data::Bundle _bundle_reg;
94 
95  dtn::data::EID _endpoint;
96  ibrcommon::Queue<dtn::data::BundleID> _bundle_queue;
97 
98  dtn::api::PlainSerializer::Encoding _encoding;
99  };
100  }
101 }
102 
103 #endif /* EXTENDEDAPICONNECTION_H_ */