servlib/bundling/BPQBlock.h
changeset 5 1849bf57d910
parent 4 c02ca5a6ab82
child 6 d1f220643814
equal deleted inserted replaced
4:c02ca5a6ab82 5:1849bf57d910
    39     u_int length_;              ///< Fragment length
    39     u_int length_;              ///< Fragment length
    40 };
    40 };
    41 
    41 
    42 class BPQBlock {
    42 class BPQBlock {
    43 public:
    43 public:
       
    44     BPQBlock(Bundle* bundle);
    44     BPQBlock(BlockInfo* block);
    45     BPQBlock(BlockInfo* block);
    45     ~BPQBlock();
    46     ~BPQBlock();
    46 
    47 
       
    48     int write_to_buffer(u_char* buf, size_t len);
       
    49 
       
    50     /**
       
    51      * 
       
    52      */
       
    53     typedef enum {
       
    54         KIND_QUERY          = 0x00,
       
    55         KIND_RESPONSE       = 0x01,
       
    56     } kind_t;
       
    57 
    47     /// @{ Accessors
    58     /// @{ Accessors
    48     u_int       kind()          const { return kind_; }
    59     kind_t          kind()          const { return kind_; }
    49     u_int       matching_rule() const { return matching_rule_; }
    60     u_int           matching_rule() const { return matching_rule_; }
    50     u_int       query_len()     const { return query_len_; }
    61     u_int           query_len()     const { return query_len_; }
    51     const char* query_val()     const { return query_val_; }
    62     u_char*         query_val()     const { return query_val_; }   
       
    63     u_int           length()        const;
    52     /// @}
    64     /// @}
       
    65 
       
    66     bool    match(BPQBlock* other)  const;
    53 
    67 
    54     /// @{ Typedefs and wrappers for the BPQFragment vector and iterators
    68     /// @{ Typedefs and wrappers for the BPQFragment vector and iterators
    55     typedef std::vector<BPQFragment> BPQFragmentVec;
    69     typedef std::vector<BPQFragment> BPQFragmentVec;
    56     typedef BPQFragmentVec::iterator iterator;
    70     typedef BPQFragmentVec::iterator iterator;
    57     typedef BPQFragmentVec::const_iterator const_iterator;
    71     typedef BPQFragmentVec::const_iterator const_iterator;
    61     BPQFragmentVec::iterator       end()         { return fragments_.end();   }
    75     BPQFragmentVec::iterator       end()         { return fragments_.end();   }
    62     BPQFragmentVec::const_iterator begin() const { return fragments_.begin(); }
    76     BPQFragmentVec::const_iterator begin() const { return fragments_.begin(); }
    63     BPQFragmentVec::const_iterator end()   const { return fragments_.end();   }
    77     BPQFragmentVec::const_iterator end()   const { return fragments_.end();   }
    64     /// @}
    78     /// @}
    65 
    79 
       
    80 private:
       
    81     int initialise(BlockInfo* block);       ///< Wrapper function called by constructors
    66 
    82 
    67 private:
    83     kind_t kind_;               ///< Query || Response 
    68     u_int kind_;                ///< Query || Response 
       
    69     u_int matching_rule_;       ///< Exact
    84     u_int matching_rule_;       ///< Exact
    70     u_int query_len_;           ///< Length of the query value
    85     u_int query_len_;           ///< Length of the query value
    71     char* query_val_;           ///< Query value
    86     u_char* query_val_;         ///< Query value
    72     BPQFragmentVec fragments_;  ///< List of fragments returned
    87     BPQFragmentVec fragments_;  ///< List of fragments returned
    73 };
    88 };
    74 
    89 
    75 } // namespace dtn
    90 } // namespace dtn
    76 
    91