• 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         {
00026                 class Bundle
00027                 {
00028                 public:
00035                         enum BUNDLE_PRIORITY
00036                         {
00037                                 PRIO_LOW = 0,
00038                                 PRIO_MEDIUM = 1,
00039                                 PRIO_HIGH = 2
00040                         };
00041 
00045                         Bundle();
00046 
00051                         Bundle(const dtn::data::EID &destination);
00052 
00056                         virtual ~Bundle();
00057 
00062                         void setLifetime(unsigned int lifetime);
00063 
00068                         unsigned int getLifetime() const;
00069 
00074                         void requestDeliveredReport();
00075 
00080                         void requestForwardedReport();
00081 
00087                         void requestDeletedReport();
00088 
00093                         void requestReceptionReport();
00094 
00098                         void requestCustodyTransfer();
00099 
00105                         void requestEncryption();
00106 
00112                         void requestSigned();
00113 
00118                         bool statusVerified();
00119 
00124                         void setPriority(BUNDLE_PRIORITY p);
00125 
00130                         BUNDLE_PRIORITY getPriority() const;
00131 
00139                         friend std::ostream &operator<<(std::ostream &stream, const dtn::api::Bundle &b)
00140                         {
00141                                 // To send a bundle, we construct a default serializer. Such a serializer convert
00142                                 // the bundle data to the standardized form as byte stream.
00143                                 dtn::data::DefaultSerializer(stream) << b._b;
00144 
00145                                 // Since this method is used to serialize bundles into an StreamConnection, we need to call
00146                                 // a flush on the StreamConnection. This signals the stream to set the bundle end flag on
00147                                 // the last segment of streaming.
00148                                 stream.flush();
00149 
00150                                 // To support concatenation of streaming calls, we return the reference to the output stream.
00151                                 return stream;
00152                         }
00153 
00161                         friend std::istream &operator>>(std::istream &stream, dtn::api::Bundle &b)
00162                         {
00163                                 // To receive a bundle, we construct a default deserializer. Such a deserializer
00164                                 // convert a byte stream into a bundle object. If this deserialization fails
00165                                 // an exception will be thrown.
00166                                 dtn::data::DefaultDeserializer(stream) >> b._b;
00167 
00168                                 // To support concatenation of streaming calls, we return the reference to the input stream.
00169                                 return stream;
00170                         }
00171 
00177                         ibrcommon::BLOB::Reference getData() throw (dtn::MissingObjectException);
00178 
00184                         void setDestination(const dtn::data::EID &eid, const bool singleton = true);
00185 
00191                         void setReportTo(const dtn::data::EID &eid);
00192 
00197                         dtn::data::EID getDestination() const;
00198 
00203                         dtn::data::EID getSource() const;
00204 
00209                         dtn::data::EID getReportTo() const;
00210 
00215                         dtn::data::EID getCustodian() const;
00216 
00224                         bool operator<(const Bundle& other) const;
00225 
00233                         bool operator>(const Bundle& other) const;
00234 
00235                 protected:
00241                         Bundle(const dtn::data::Bundle &b);
00242 
00243                         // base bundle object
00244                         dtn::data::Bundle _b;
00245                 };
00246         }
00247 }
00248 
00249 #endif /* API_BUNDLE_H_ */

Generated on Wed Mar 30 2011 11:11:49 for IBR-DTNSuite by  doxygen 1.7.1