Alchemy
1.0
A framework to robustly process network messages and structured data
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
Hg
proxy
bitlist_field_proxy.h
1
/// @file detail/bitlist_field_proxy.h
2
///
3
/// An adapter object for BitLists to work within MsgFields.
4
///
5
/// The MIT License(MIT)
6
/// @copyright 2014 Paul M Watt
7
// ****************************************************************************
8
#ifndef BITLIST_FIELD_PROXY_H_INCLUDED
9
#define BITLIST_FIELD_PROXY_H_INCLUDED
10
// Includes *******************************************************************
11
#include <
Hg/datum/datum.h
>
12
#include <Pb/bit_field/packed_bits.h>
13
14
namespace
Hg
15
{
16
17
namespace
detail
18
{
19
20
// ****************************************************************************
21
/// A proxy template specialization for bitfield data types.
22
///
23
/// @param kt_idx
24
/// @param format_type
25
///
26
template
<
size_t
kt_idx,
27
typename
format_t
28
>
29
struct
DataProxy
<
packed_trait
, kt_idx, format_t>
30
:
public
Datum
<kt_idx, format_t>
31
{
32
typedef
33
Datum
< kt_idx,
34
format_t
35
>
datum_type
;
36
37
typedef
typename
38
datum_type::value_type
value_type
;
39
40
typedef
datum_type
reference
;
41
42
// **************************************************************************
43
/// Default Constructor
44
///
45
/// Initializes the internal buffer to a static nil instance that is legal to
46
/// call into with no actions performed.
47
///
48
DataProxy
()
49
{ }
50
51
// **************************************************************************
52
/// Copy Constructor
53
///
54
/// Makes a complete copy of an existing Proxy object, including internal
55
/// references to the MsgBuffer that is associated with the base Datum instance.
56
///
57
/// @param proxy A reference to the Another instance of a DataProxy.
58
///
59
DataProxy
(
DataProxy
& proxy)
60
:
datum_type
(proxy)
61
{
62
this->
set
(proxy.
get
());
63
}
64
65
// **************************************************************************
66
/// Conversion operator to a base Datum Type.
67
///
68
/// @note The converted Datum base provides access to the Attach and
69
/// Flush functions of the Datum.
70
///
71
operator
reference
()
72
{
73
return
*
static_cast<
datum_type
*
>
(
this
);
74
}
75
76
// **************************************************************************
77
/// Value Conversion Operator (value_type) const
78
///
79
/// Allows the entire BitSet to be extracted and assigned as a value to
80
/// the host value type.
81
///
82
operator
value_type
()
const
83
{
84
return
static_cast<
const
datum_type
*
>
(
this
)->
operator
value_type
();
85
}
86
87
// **************************************************************************
88
/// Value Conversion Operator (value_type)
89
///
90
/// Allows the entire BitSet to be extracted and assigned as a value to
91
/// the host value type.
92
///
93
operator
value_type
()
94
{
95
return
static_cast<
datum_type
*
>
(
this
)->
operator
value_type
();
96
}
97
98
// **************************************************************************
99
/// Assignment Operator (value_type)
100
///
101
/// Allows assignment to this Datum type from it's parameter type, *value_type*.
102
/// This function is the key to allowing the Datum to behave as if the
103
/// assignment was performed directly on the the managed type.
104
///
105
/// @param rhs A value of the Datum value_type that will
106
/// be used to directly modify the value of the object.
107
///
108
DataProxy
&
109
operator=
(
value_type
rhs)
110
{
111
datum_type::operator=
(rhs);
112
return
*
this
;
113
}
114
};
115
116
}
// namespace detail
117
118
}
// namespace Hg
119
120
#endif
121
Generated on Sat May 9 2015 21:25:05 for Alchemy by
1.8.3.1