--- a/servlib/bundling/BPQBlock.h Wed Oct 26 13:33:11 2011 +0100
+++ b/servlib/bundling/BPQBlock.h Fri Jan 06 17:28:36 2012 +0000
@@ -22,26 +22,11 @@
#endif
#include "BlockInfo.h"
+#include "BPQFragmentList.h"
#include <oasys/debug/Log.h>
namespace dtn {
-class BPQFragment{
-public:
- BPQFragment(size_t offset , size_t length) :
- offset_(offset),
- length_(length) {}
- ~BPQFragment() {}
-
- /// @{ Accessors
- size_t offset() const { return offset_; }
- size_t length() const { return length_; }
- /// @}
-
-private:
- size_t offset_; ///< Fragment offset
- size_t length_; ///< Fragment length
-};
class BPQBlock : public oasys::Logger
{
@@ -66,22 +51,15 @@
u_char* query_val() const { return query_val_; }
u_int length() const;
u_int frag_len() const { return fragments_.size(); }
+ const BPQFragmentList& fragments() const { return fragments_; }
/// @}
- bool match(const BPQBlock* other) const;
- void add_fragment(BPQFragment fragment) {fragments_.push_back(fragment);}
+ bool match (const BPQBlock* other) const;
- /// @{ Typedefs and wrappers for the BPQFragment vector and iterators
- typedef std::vector<BPQFragment> BPQFragmentVec;
- typedef BPQFragmentVec::iterator iterator;
- typedef BPQFragmentVec::const_iterator const_iterator;
-
- bool empty() const { return fragments_.empty(); }
- BPQFragmentVec::iterator begin() { return fragments_.begin(); }
- BPQFragmentVec::iterator end() { return fragments_.end(); }
- BPQFragmentVec::const_iterator begin() const { return fragments_.begin(); }
- BPQFragmentVec::const_iterator end() const { return fragments_.end(); }
- /// @}
+ /**
+ * Add the new fragment in sorted order
+ */
+ void add_fragment (BPQFragment* fragment);
private:
int initialise(BlockInfo* block, bool created_locally, const Bundle* bundle); ///< Wrapper function called by constructor
@@ -101,7 +79,7 @@
EndpointID source_; ///< Original Source EID
u_int query_len_; ///< Length of the query value
u_char* query_val_; ///< Query value
- BPQFragmentVec fragments_; ///< List of fragments returned
+ BPQFragmentList fragments_; ///< List of fragments returned
};
} // namespace dtn