IBR-DTNSuite  0.8
daemon/src/core/BundleCore.h
Go to the documentation of this file.
00001 #ifndef BUNDLECORE_H_
00002 #define BUNDLECORE_H_
00003 
00004 #include "Component.h"
00005 
00006 #include "core/EventReceiver.h"
00007 #include "core/StatusReportGenerator.h"
00008 #include "storage/BundleStorage.h"
00009 #include "core/WallClock.h"
00010 #include "routing/BaseRouter.h"
00011 
00012 #include "net/ConnectionManager.h"
00013 #include "net/ConvergenceLayer.h"
00014 
00015 #include <ibrdtn/data/Serializer.h>
00016 #include <ibrdtn/data/EID.h>
00017 #include <ibrdtn/data/CustodySignalBlock.h>
00018 
00019 #include <vector>
00020 #include <set>
00021 #include <map>
00022 
00023 using namespace dtn::data;
00024 
00025 namespace dtn
00026 {
00027         namespace core
00028         {
00032                 class BundleCore : public dtn::daemon::IntegratedComponent, public dtn::core::EventReceiver, public dtn::data::Validator
00033                 {
00034                 public:
00035                         static dtn::data::EID local;
00036 
00037                         static BundleCore& getInstance();
00038 
00039                         WallClock& getClock();
00040 
00041                         void setStorage(dtn::storage::BundleStorage *storage);
00042                         dtn::storage::BundleStorage& getStorage();
00043 
00044                         void setRouter(dtn::routing::BaseRouter *router);
00045                         dtn::routing::BaseRouter& getRouter() const;
00046 
00047                         void transferTo(const dtn::data::EID &destination, const dtn::data::BundleID &bundle);
00048 
00049                         void addConvergenceLayer(dtn::net::ConvergenceLayer *cl);
00050 
00051                         void addConnection(const dtn::core::Node &n);
00052                         void removeConnection(const dtn::core::Node &n);
00053 
00060                         void addRoute(const dtn::data::EID &destination, const dtn::data::EID &nexthop, size_t timeout = 0);
00061 
00067                         void removeRoute(const dtn::data::EID &destination, const dtn::data::EID &nexthop);
00068 
00073                         const std::set<dtn::core::Node> getNeighbors();
00074 
00080                         bool isNeighbor(const dtn::core::Node &node);
00081 
00088                         const dtn::core::Node getNeighbor(const dtn::data::EID &eid);
00089 
00090                         void raiseEvent(const dtn::core::Event *evt);
00091 
00092                         virtual void validate(const dtn::data::PrimaryBlock &obj) const throw (RejectedException);
00093                         virtual void validate(const dtn::data::Block &obj, const size_t length) const throw (RejectedException);
00094                         virtual void validate(const dtn::data::Bundle &obj) const throw (RejectedException);
00095 
00099                         static size_t blocksizelimit;
00100 
00104                         static size_t max_lifetime;
00105 
00109                         static size_t max_timestamp_future;
00110 
00114                         static bool forwarding;
00115 
00119                         virtual const std::string getName() const;
00120 
00121                         static void processBlocks(dtn::data::Bundle &b);
00122 
00123                 protected:
00124                         virtual void componentUp();
00125                         virtual void componentDown();
00126 
00127                 private:
00131                         BundleCore();
00132 
00136                         virtual ~BundleCore();
00137 
00141                         BundleCore operator=(const BundleCore &k) { return k; };
00142 
00146                         WallClock _clock;
00147 
00148                         dtn::storage::BundleStorage *_storage;
00149                         dtn::routing::BaseRouter *_router;
00150 
00151                         // generator for statusreports
00152                         StatusReportGenerator _statusreportgen;
00153 
00154                         // manager class for connections
00155                         dtn::net::ConnectionManager _connectionmanager;
00156                 };
00157         }
00158 }
00159 
00160 #endif /*BUNDLECORE_H_*/
00161