• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

daemon/src/routing/BaseRouter.h

Go to the documentation of this file.
00001 /*
00002  * BaseRouter.h
00003  *
00004  *  Created on: 15.02.2010
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef BASEROUTER_H_
00009 #define BASEROUTER_H_
00010 
00011 #include "Component.h"
00012 #include "ibrdtn/data/DTNTime.h"
00013 #include "ibrdtn/data/BundleID.h"
00014 #include "core/EventReceiver.h"
00015 #include "core/BundleStorage.h"
00016 #include "ibrcommon/thread/Thread.h"
00017 #include "ibrcommon/thread/Conditional.h"
00018 #include <ibrdtn/data/MetaBundle.h>
00019 #include "routing/BundleSummary.h"
00020 
00021 namespace dtn
00022 {
00023         namespace routing
00024         {
00025                 class BaseRouter : public dtn::core::EventReceiver, public dtn::daemon::IntegratedComponent
00026                 {
00027                 public:
00028                         class RoutingException : public ibrcommon::Exception
00029                         {
00030                                 public:
00031                                         RoutingException(string what = "An error occured during routing.") throw() : Exception(what)
00032                                         {
00033                                         };
00034                         };
00035 
00039                         class NoNeighbourFoundException : public RoutingException
00040                         {
00041                                 public:
00042                                         NoNeighbourFoundException(string what = "No neighbour was found.") throw() : RoutingException(what)
00043                                         {
00044                                         };
00045                         };
00046 
00050                         class NoRouteFoundException : public RoutingException
00051                         {
00052                                 public:
00053                                         NoRouteFoundException(string what = "No route found.") throw() : RoutingException(what)
00054                                         {
00055                                         };
00056                         };
00057 
00058                         class Extension
00059                         {
00060                         public:
00061                                 Extension();
00062                                 virtual ~Extension() = 0;
00063 
00064                                 virtual void notify(const dtn::core::Event *evt) = 0;
00065 
00066                         protected:
00067                                 BaseRouter *getRouter();
00068 
00069                         private:
00070                                 friend class BaseRouter;
00071                                 static BaseRouter *_router;
00072                         };
00073 
00074                         class ThreadedExtension : public Extension, public ibrcommon::JoinableThread
00075                         {
00076                         public:
00077                                 ThreadedExtension();
00078                                 virtual ~ThreadedExtension() = 0;
00079 
00080                                 virtual void notify(const dtn::core::Event *evt) = 0;
00081 
00082                         protected:
00083                                 virtual void stopExtension() = 0;
00084                         };
00085 
00086                         class Endpoint
00087                         {
00088                         public:
00089                                 Endpoint();
00090                                 virtual ~Endpoint() = 0;
00091                         };
00092 
00093                 private:
00094                         class VirtualEndpoint
00095                         {
00096                         public:
00097                                 VirtualEndpoint(dtn::data::EID name);
00098                                 virtual ~VirtualEndpoint();
00099 
00100                                 ibrcommon::Mutex _clientlock;
00101                                 Endpoint *_client;
00102 
00103                                 dtn::data::EID _name;
00104                                 dtn::data::DTNTime _lastseen;
00105                                 dtn::data::DTNTime _expire;
00106                         };
00107 
00108                 public:
00109                         BaseRouter(dtn::core::BundleStorage &storage);
00110                         ~BaseRouter();
00111 
00116                         void addExtension(BaseRouter::Extension *extension);
00117 
00124                         void transferTo(const dtn::data::EID &destination, const dtn::data::BundleID &id);
00125 
00129                         void raiseEvent(const dtn::core::Event *evt);
00130 
00136                         dtn::data::Bundle getBundle(const dtn::data::BundleID &id);
00137 
00138                         dtn::core::BundleStorage &getStorage();
00139 
00145                         bool isKnown(const dtn::data::BundleID &id);
00146 
00151                         void setKnown(const dtn::data::MetaBundle &meta);
00152 
00153                         const SummaryVector getSummaryVector();
00154 
00158                         virtual const std::string getName() const;
00159 
00160                 protected:
00161                         virtual void componentUp();
00162                         virtual void componentDown();
00163 
00164                 private:
00165                         ibrcommon::Mutex _known_bundles_lock;
00166                         BundleSummary _known_bundles;
00167 
00168                         dtn::core::BundleStorage &_storage;
00169                         std::list<BaseRouter::Extension*> _extensions;
00170                 };
00171         }
00172 }
00173 
00174 
00175 #endif /* BASEROUTER_H_ */

Generated on Thu Nov 11 2010 09:49:47 for IBR-DTNSuite by  doxygen 1.7.1