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

ibrdtn/ibrdtn/api/Bundle.h

Go to the documentation of this file.
00001 /*
00002  * Bundle.h
00003  *
00004  *  Created on: 24.07.2009
00005  *      Author: morgenro
00006  */
00007 
00008 #ifndef API_BUNDLE_H_
00009 #define API_BUNDLE_H_
00010 
00011 #include "ibrdtn/data/EID.h"
00012 #include "ibrdtn/data/Bundle.h"
00013 #include "ibrcommon/data/BLOB.h"
00014 
00015 #include <iostream>
00016 #include <fstream>
00017 
00018 namespace dtn
00019 {
00020         namespace api
00021         {
00025                 class Client;
00026 
00030                 class Bundle
00031                 {
00032                         friend class Client;
00033 
00034                 public:
00042                         enum BUNDLE_SECURITY
00043                         {
00044                                 SEC_OFF = 0,
00045                                 SEC_SIGNED = 1,
00046                                 SEC_ENCRYPTED = 2,
00047                                 SEC_ENC_SIGNED = 3
00048                         };
00049 
00056                         enum BUNDLE_PRIORITY
00057                         {
00058                                 PRIO_LOW = 0,
00059                                 PRIO_MEDIUM = 1,
00060                                 PRIO_HIGH = 2
00061                         };
00062 
00066                         Bundle();
00067 
00072                         Bundle(dtn::data::EID destination);
00073 
00077                         virtual ~Bundle();
00078 
00082                         void setSecurity(BUNDLE_SECURITY s);
00083 
00087                         BUNDLE_SECURITY getSecurity();
00088 
00092                         void setLifetime(unsigned int lifetime);
00093 
00097                         unsigned int getLifetime();
00098 
00099                         void requestDeliveredReport();
00100                         void requestForwardedReport();
00101                         void requestDeletedReport();
00102                         void requestReceptionReport();
00103 
00107                         void setPriority(BUNDLE_PRIORITY p);
00108 
00112                         BUNDLE_PRIORITY getPriority();
00113 
00117                         friend std::ostream &operator<<(std::ostream &stream, const dtn::api::Bundle &b)
00118                         {
00119                                 const dtn::data::Bundle &_b = b._b;
00120 
00121                                 // send the bundle
00122                                 dtn::data::DefaultSerializer(stream) << _b; stream.flush();
00123 
00124                                 return stream;
00125                         }
00126 
00127                         friend std::istream &operator>>(std::istream &stream, dtn::api::Bundle &b)
00128                         {
00129                                 dtn::data::DefaultDeserializer(stream) >> b._b;
00130 
00131                                 // read priority
00132                                 if (b._b._procflags & dtn::data::Bundle::PRIORITY_BIT1)
00133                                 {
00134                                                 if (b._b._procflags & dtn::data::Bundle::PRIORITY_BIT2) b._priority = PRIO_HIGH;
00135                                                 else b._priority = PRIO_MEDIUM;
00136                                 }
00137                                 else
00138                                 {
00139                                                 b._priority = PRIO_LOW;
00140                                 }
00141 
00142                                 // read the lifetime
00143                                 b._lifetime = b._b._lifetime;
00144 
00145                                 return stream;
00146                         }
00147 
00151                         ibrcommon::BLOB::Reference getData();
00152 
00153                         dtn::data::EID getDestination();
00154                         dtn::data::EID getSource();
00155                         void setReportTo(const dtn::data::EID &eid);
00156 
00157                         bool operator<(const Bundle& other) const;
00158                         bool operator>(const Bundle& other) const;
00159 
00160                 protected:
00165                         Bundle(dtn::data::Bundle &b);
00166 
00167                         dtn::data::Bundle _b;
00168                         BUNDLE_SECURITY _security;
00169                         BUNDLE_PRIORITY _priority;
00170                         unsigned int _lifetime;
00171                 };
00172         }
00173 }
00174 
00175 #endif /* API_BUNDLE_H_ */

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