PVData C++
8.0.5
pv
valueBuilder.h
1
/*
2
* Copyright information and license terms for this software can be
3
* found in the file LICENSE that is included with the distribution
4
*/
5
#
ifndef
VALUEBUILDER_H
6
#
define
VALUEBUILDER_H
7
8
#
include
<
map
>
9
10
#
include
<
pv
/
templateMeta
.
h
>
11
#
include
<
pv
/
pvIntrospect
.
h
>
12
#
include
<
pv
/
sharedVector
.
h
>
13
14
namespace
epics{
namespace
pvData
{
15
16
class
PVStructure;
17
18
/** Incrementally define and initialize a PVStructure
19
*
20
* Equivalent to FieldBuilder with the added ability to assign initial values.
21
*
22
@code
23
epics::pvData::PVStructurePtr val(epics::pvData::ValueBuilder()
24
.add<pvInt>("intfld", 42)
25
.addNested("sub")
26
.add<pvString>("strfld", "testing")
27
.endNested()
28
.buildPVStructure());
29
@endcode
30
*/
31
class
epicsShareClass
ValueBuilder
32
{
33
public
:
34
//! empty structure
35
explicit
ValueBuilder
(
const
std
::
string
&
id
=
std
::
string
());
36
//! Clone existing definition and value
37
explicit
ValueBuilder
(
const
PVStructure
&);
38
~
ValueBuilder
();
39
40
//! Add a scalar field with a given name and initial value
41
template
<
ScalarType
ENUM
>
42
FORCE_INLINE
ValueBuilder
&
add
(
const
std
::
string
&
name
,
typename
meta
::
arg_type
<
typename
ScalarTypeTraits
<
ENUM
>::
type
>::
type
V
)
43
{
44
_add
(
name
,
ENUM
, &
V
);
45
return
*
this
;
46
}
47
48
//! Add a scalar array field
49
template
<
class
T
>
50
FORCE_INLINE
ValueBuilder
&
add
(
const
std
::
string
&
name
,
const
shared_vector
<
const
T
>&
V
)
51
{
52
_add
(
name
,
V
);
53
return
*
this
;
54
}
55
56
FORCE_INLINE
ValueBuilder
&
add
(
const
std
::
string
&
name
,
const
PVStructure
&
V
) {
57
_add
(
name
,
V
);
58
return
*
this
;
59
}
60
61
//! Start a sub-structure
62
ValueBuilder
&
addNested
(
const
std
::
string
&
name
,
Type
type
=
structure
,
const
std
::
string
&
id
=
std
::
string
());
63
//! End a sub-structure
64
ValueBuilder
&
endNested
();
65
66
/** Complete building structure
67
*
68
* @note ValueBuilder may be re-used after calling buildPVStructure()
69
*/
70
std
::
tr1
::
shared_ptr
<
PVStructure
>
buildPVStructure
()
const
;
71
72
private
:
73
void
_add
(
const
std
::
string
&
name
,
ScalarType
stype
,
const
void
*
V
);
74
void
_add
(
const
std
::
string
&
name
,
const
shared_vector
<
const
void
> &
V
);
75
void
_add
(
const
std
::
string
&
name
,
const
PVStructure
&
V
);
76
77
ValueBuilder
(
ValueBuilder
*,
const
std
::
string
&
id
=
std
::
string
());
78
79
ValueBuilder
*
const
parent
;
80
struct
child
;
81
friend
struct
child
;
82
struct
child_struct
;
83
friend
struct
child_struct
;
84
struct
child_scalar_base
;
85
friend
struct
child_scalar_base
;
86
template
<
typename
T
>
struct
child_scalar
;
87
template
<
typename
T
>
friend
struct
child_scalar
;
88
struct
child_scalar_array
;
89
friend
struct
child_scalar_array
;
90
91
typedef
std
::
map
<
std
::
string
,
child
*>
children_t
;
92
children_t
children
;
93
std
::
string
id
;
94
95
ValueBuilder
(
const
ValueBuilder
&);
96
ValueBuilder
&
operator
=(
const
ValueBuilder
&);
97
};
98
99
}}
// namespace epics::pvData
100
101
#
endif
// VALUEBUILDER_H
epics::pvData::ValueBuilder
Definition:
valueBuilder.h:31
FORCE_INLINE
#define FORCE_INLINE
Definition:
templateMeta.h:20
epics::pvData::yajl_parse_helper
epicsShareFunc bool yajl_parse_helper(std::istream &src, yajl_handle handle)
Generated on Wed Sep 7 2022 15:52:58 for PVData C++ by
1.8.13