Skip to content

Commit 5645bfc

Browse files
committed
Making wrapper_base more generic, preparing for async-related wrappers.
1 parent 1014405 commit 5645bfc

File tree

8 files changed

+33
-27
lines changed

8 files changed

+33
-27
lines changed

boost/network/detail/directive_base.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace boost { namespace network { namespace detail {
1818
//explicit directive_base(basic_message<tag> & message_)
1919
// : _message(message_)
2020
protected:
21-
virtual ~directive_base()
21+
~directive_base()
2222
{ }; // can only be extended
2323

2424
// mutable basic_message<tag> & _message;

boost/network/detail/wrapper_base.hpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,30 @@
99

1010
namespace boost { namespace network {
1111

12-
template <class Tag>
13-
struct basic_message;
14-
1512
namespace detail {
1613

17-
template <class Tag>
14+
template <class Tag, class Message>
1815
struct wrapper_base {
19-
explicit wrapper_base(basic_message<Tag> & message_)
16+
explicit wrapper_base(Message & message_)
2017
: _message(message_)
2118
{};
2219

2320
protected:
2421
~wrapper_base() {}; // for extending only
2522

26-
basic_message<Tag> & _message;
23+
Message & _message;
2724
};
2825

29-
template <class Tag>
26+
template <class Tag, class Message>
3027
struct wrapper_base_const {
31-
explicit wrapper_base_const(basic_message<Tag> const & message_)
28+
explicit wrapper_base_const(Message const & message_)
3229
: _message(message_)
3330
{}
3431

3532
protected:
3633
~wrapper_base_const() {}; // for extending only
3734

38-
basic_message<Tag> const & _message;
35+
Message const & _message;
3936
};
4037

4138
} // namespace detail

boost/network/message.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ namespace boost { namespace network {
125125
private:
126126

127127
friend struct detail::directive_base<Tag> ;
128-
friend struct detail::wrapper_base<Tag> ;
128+
friend struct detail::wrapper_base<Tag, basic_message<Tag> > ;
129129

130130
mutable headers_container_type _headers;
131131
mutable string_type _body;

boost/network/message/wrappers/body.hpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,46 @@
88
#define __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__
99

1010
#include <boost/network/traits/string.hpp>
11+
#include <boost/network/detail/wrapper_base.hpp>
1112

1213
namespace boost { namespace network {
1314

1415
namespace impl {
1516
template <class Tag>
16-
struct body_wrapper : public detail::wrapper_base<Tag> {
17+
struct body_wrapper : public detail::wrapper_base<Tag, basic_message<Tag> > {
1718
typedef basic_message<Tag> message_type;
1819
typedef typename string<Tag>::type string_type;
20+
typedef detail::wrapper_base<Tag, basic_message<Tag> > wrapper_base;
1921

2022
explicit body_wrapper(basic_message<Tag> & message_)
21-
: detail::wrapper_base<Tag>(message_)
23+
: wrapper_base(message_)
2224
{ };
2325

2426
operator string_type () const {
25-
return string_type(detail::wrapper_base<Tag>::_message.body());
27+
return string_type(wrapper_base::_message.body());
2628
};
2729

2830
std::size_t size() const {
29-
return detail::wrapper_base<Tag>::_message.body().size();
31+
return wrapper_base::_message.body().size();
3032
}
3133
};
3234

3335
template <class Tag>
34-
struct body_wrapper_const : public detail::wrapper_base_const<Tag> {
36+
struct body_wrapper_const : public detail::wrapper_base_const<Tag, basic_message<Tag> > {
3537
typedef basic_message<Tag> message_type;
3638
typedef typename string<Tag>::type string_type;
39+
typedef detail::wrapper_base_const<Tag, basic_message<Tag> > wrapper_base;
3740

3841
explicit body_wrapper_const(basic_message<Tag> const & message_)
39-
: detail::wrapper_base_const<Tag>(message_)
42+
: wrapper_base(message_)
4043
{};
4144

4245
operator string_type () const {
43-
return string_type(detail::wrapper_base_const<Tag>::_message.body());
46+
return string_type(wrapper_base::_message.body());
4447
}
4548

4649
std::size_t size() const {
47-
return detail::wrapper_base<Tag>::_message.body().size();
50+
return wrapper_base::_message.body().size();
4851
}
4952
};
5053

boost/network/message/wrappers/destination.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ namespace boost { namespace network {
1515

1616
namespace impl {
1717
template <class Tag>
18-
struct destination_wrapper : public detail::wrapper_base<Tag> {
18+
struct destination_wrapper : public detail::wrapper_base<Tag, basic_message<Tag> > {
1919
typedef Tag tag;
2020
typedef basic_message<tag> message_type;
2121
typedef typename string<Tag>::type string_type;
22+
typedef detail::wrapper_base<Tag, basic_message<Tag> > wrapper_base;
2223

2324
explicit destination_wrapper(message_type & message_)
24-
: detail::wrapper_base<tag>(message_)
25+
: wrapper_base(message_)
2526
{ };
2627

2728
operator string_type () const {
28-
return string_type(detail::wrapper_base<tag>::_message.destination());
29+
return string_type(wrapper_base::_message.destination());
2930
};
3031
};
3132
} // namespace impl

boost/network/message/wrappers/headers.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@ namespace boost { namespace network {
4545
*/
4646
namespace impl {
4747
template <class Tag>
48-
struct headers_wrapper : public detail::wrapper_base_const<Tag> {
48+
struct headers_wrapper : public detail::wrapper_base_const<Tag, basic_message<Tag> > {
4949
typedef Tag tag;
5050
typedef basic_message<Tag> message_type;
5151
typedef typename string<Tag>::type string_type;
5252
typedef typename headers_range<message_type>::type range_type;
5353
typedef typename headers_container<Tag>::type headers_container_type;
5454
typedef typename headers_container_type::const_iterator const_iterator;
5555
typedef typename headers_container_type::iterator iterator;
56+
typedef detail::wrapper_base_const<Tag, basic_message<Tag> > wrapper_base;
5657

5758
explicit headers_wrapper(basic_message<Tag> const & message_)
58-
: detail::wrapper_base_const<Tag>(message_)
59+
: wrapper_base(message_)
5960
{ };
6061

6162
range_type operator[] (string_type const & key) const {

boost/network/message/wrappers/source.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ namespace boost { namespace network {
1515

1616
namespace impl {
1717
template <class Tag>
18-
struct source_wrapper : public detail::wrapper_base<Tag> {
18+
struct source_wrapper : public detail::wrapper_base<Tag, basic_message<Tag> > {
1919
typedef Tag tag;
2020
typedef basic_message<tag> message_type;
2121
typedef typename string<tag>::type string_type;
22+
typedef detail::wrapper_base<Tag, basic_message<Tag> > wrapper_base;
2223

2324
explicit source_wrapper(basic_message<tag> & message_)
24-
: detail::wrapper_base<tag>(message_)
25+
: wrapper_base(message_)
2526
{ };
2627

2728
operator string_type () const {
28-
return string_type(detail::wrapper_base<tag>::_message.source());
29+
return string_type(wrapper_base::_message.source());
2930
};
3031
};
3132
} // namespace impl

boost/network/protocol/http/message/async_message.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//FIXME move this out to a trait
1414
#include <set>
1515
#include <boost/foreach.hpp>
16+
#include <boost/network/detail/wrapper_base.hpp>
1617

1718
namespace boost { namespace network { namespace http {
1819

@@ -135,6 +136,8 @@ namespace boost { namespace network { namespace http {
135136
mutable headers_container_type added_headers;
136137
mutable std::set<string_type> removed_headers;
137138
mutable boost::shared_future<string_type> body_;
139+
140+
friend struct boost::network::detail::wrapper_base<Tag, async_message<Tag> >;
138141
};
139142

140143
template <class Tag>

0 commit comments

Comments
 (0)