servlib/bundling/BPQBlock.h
changeset 4 c02ca5a6ab82
child 5 1849bf57d910
equal deleted inserted replaced
3:c244287035f5 4:c02ca5a6ab82
       
     1 /*
       
     2  *    Copyright 2008 Intel Corporation
       
     3  * 
       
     4  *    Licensed under the Apache License, Version 2.0 (the "License");
       
     5  *    you may not use this file except in compliance with the License.
       
     6  *    You may obtain a copy of the License at
       
     7  * 
       
     8  *        http://www.apache.org/licenses/LICENSE-2.0
       
     9  * 
       
    10  *    Unless required by applicable law or agreed to in writing, software
       
    11  *    distributed under the License is distributed on an "AS IS" BASIS,
       
    12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    13  *    See the License for the specific language governing permissions and
       
    14  *    limitations under the License.
       
    15  */
       
    16 
       
    17 #ifndef _BPQ_BLOCK_H_
       
    18 #define _BPQ_BLOCK_H_
       
    19 
       
    20 #ifdef HAVE_CONFIG_H
       
    21 #  include <dtn-config.h>
       
    22 #endif
       
    23 
       
    24 #include "BlockInfo.h"
       
    25 namespace dtn {
       
    26 
       
    27 class BPQFragment{
       
    28 public:
       
    29     BPQFragment() {}
       
    30     ~BPQFragment() {}
       
    31 
       
    32     /// @{ Accessors
       
    33     u_int offset() const { return offset_; }
       
    34     u_int length() const { return length_; }
       
    35     /// @}
       
    36 
       
    37 private:
       
    38     u_int offset_;              ///< Fragment offset
       
    39     u_int length_;              ///< Fragment length
       
    40 };
       
    41 
       
    42 class BPQBlock {
       
    43 public:
       
    44     BPQBlock(BlockInfo* block);
       
    45     ~BPQBlock();
       
    46 
       
    47     /// @{ Accessors
       
    48     u_int       kind()          const { return kind_; }
       
    49     u_int       matching_rule() const { return matching_rule_; }
       
    50     u_int       query_len()     const { return query_len_; }
       
    51     const char* query_val()     const { return query_val_; }
       
    52     /// @}
       
    53 
       
    54     /// @{ Typedefs and wrappers for the BPQFragment vector and iterators
       
    55     typedef std::vector<BPQFragment> BPQFragmentVec;
       
    56     typedef BPQFragmentVec::iterator iterator;
       
    57     typedef BPQFragmentVec::const_iterator const_iterator;
       
    58 
       
    59     bool                           empty() const { return fragments_.empty(); }
       
    60     BPQFragmentVec::iterator       begin()       { return fragments_.begin(); }
       
    61     BPQFragmentVec::iterator       end()         { return fragments_.end();   }
       
    62     BPQFragmentVec::const_iterator begin() const { return fragments_.begin(); }
       
    63     BPQFragmentVec::const_iterator end()   const { return fragments_.end();   }
       
    64     /// @}
       
    65 
       
    66 
       
    67 private:
       
    68     u_int kind_;                ///< Query || Response 
       
    69     u_int matching_rule_;       ///< Exact
       
    70     u_int query_len_;           ///< Length of the query value
       
    71     char* query_val_;           ///< Query value
       
    72     BPQFragmentVec fragments_;  ///< List of fragments returned
       
    73 };
       
    74 
       
    75 } // namespace dtn
       
    76 
       
    77 #endif /* _BPQ_BLOCK_H_ */
       
    78