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
data_proxy.h
Go to the documentation of this file.
1
/// @file Hg/proxy/data_proxy.h
2
///
3
/// The declaration and definition of the DataProxy.
4
///
5
/// A parameterized type that abstracts the details between all different types
6
/// of message fields. This will allow a single message field MACRO to be
7
/// used when defining fields for message format definitions.
8
///
9
/// The MIT License(MIT)
10
/// @copyright 2014 Paul M Watt
11
// ****************************************************************************
12
#ifndef DATA_PROXY_H_INCLUDED
13
#define DATA_PROXY_H_INCLUDED
14
// Includes ******************************************************************
15
16
#include <Pb/meta_fwd.h>
17
#include <Pb/length.h>
18
#include <Pb/type_list.h>
19
#include <Pb/type_at.h>
20
#include <
Hg/datum/datum.h
>
21
#include <
Hg/storage_policy.h
>
22
23
namespace
Hg
24
{
25
26
namespace
detail
27
{
28
29
// ****************************************************************************
30
/// A template to adapt all field types to the Datum assignment.
31
///
32
/// @paramt datum_trait The general category of proxy management required by
33
/// the specified field.
34
/// @paramt kt_idx
35
/// @paramt format_type
36
/// @paramt kt_offset
37
///
38
template
<
typename
datum_trait,
39
size_t
kt_idx,
40
typename
format_t
41
>
42
struct
DataProxy
43
:
public
Hg::Datum
<kt_idx, format_t>
44
{
45
typedef
46
Hg::Datum
< kt_idx,
47
format_t
48
>
datum_type
;
49
50
typedef
typename
51
datum_type::value_type
value_type
;
52
53
typedef
datum_type
&
reference
;
54
55
// **************************************************************************
56
/// Default Constructor
57
///
58
DataProxy
()
59
{ }
60
61
// **************************************************************************
62
/// Copy Constructor
63
///
64
/// Makes a complete copy of an existing Proxy object.
65
///
66
/// @param proxy A reference to the Another instance of a DataProxy.
67
///
68
DataProxy
(
const
DataProxy
& proxy)
69
{
70
this->
set
(proxy.
get
());
71
}
72
73
// **************************************************************************
74
/// Value Constructor: Construct a proxy directly from a datum instance.
75
///
76
/// @param datum A reference to a datum object used to initilize this.
77
///
78
DataProxy
(
const
datum_type
& datum)
79
:
datum_type
(datum)
80
{ }
81
82
#ifdef ALCHEMY_RVALUE_REF_SUPPORTED
83
84
// **************************************************************************
85
/// Move Constructor
86
///
87
/// Moves the current instance from one proxy to another.
88
///
89
/// @param proxy A rvalue reference to the another instance of a DataProxy.
90
///
91
DataProxy
(
DataProxy
&& proxy)
92
{
93
*
this
= std::move(proxy);
94
}
95
96
// **************************************************************************
97
/// Move Assignment operator
98
///
99
/// Moves the current instance from one proxy to another.
100
///
101
/// @param proxy A rvalue reference to the another instance of a DataProxy.
102
///
103
DataProxy
&
operator=
(
DataProxy
&& proxy)
104
{
105
this->
set
(proxy.get());
106
return
*
this
;
107
}
108
109
#endif
110
111
// **************************************************************************
112
/// Value assignment
113
///
114
DataProxy
&
operator=
(
const
datum_type
& value)
115
{
116
*
static_cast<
datum_type
*
>
(
this
) = value;
117
return
*
this
;
118
}
119
120
// **************************************************************************
121
/// Value assignment
122
///
123
DataProxy
&
operator=
(
value_type
value)
124
{
125
*
static_cast<
datum_type
*
>
(
this
) = value;
126
return
*
this
;
127
}
128
129
// **************************************************************************
130
/// Conversion operator to a base Datum Type reference.
131
///
132
/// @note The converted Datum base provides access to value interface
133
/// of the Datum object.
134
///
135
operator
reference
()
136
{
137
return
*
static_cast<
datum_type
*
>
(
this
);
138
}
139
140
// **************************************************************************
141
/// Value Conversion Operator (value_type)
142
///
143
/// Allows the entire Object-type to be extracted and assigned as a value to
144
/// the host value type.
145
///
146
operator
value_type
()
const
147
{
148
return
static_cast<
const
datum_type
*
>
(
this
)->
operator
value_type
();
149
}
150
};
151
152
}
// namespace detail
153
154
}
// namespace Hg
155
156
#endif
Generated on Sat May 9 2015 21:25:05 for Alchemy by
1.8.3.1