PVData C++ 8.0.7
Loading...
Searching...
No Matches
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
14namespace epics{namespace pvData{
15
16class PVStructure;
17
31class epicsShareClass ValueBuilder
32{
33public:
35 explicit ValueBuilder(const std::string& id=std::string());
37 explicit ValueBuilder(const PVStructure&);
39
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
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
62 ValueBuilder& addNested(const std::string& name, Type type=structure, const std::string& id = std::string());
64 ValueBuilder& endNested();
65
70 std::tr1::shared_ptr<PVStructure> buildPVStructure() const;
71
72private:
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
constexpr complex< _Tp > & operator=(const _Tp &)
Data interface for a structure,.
Definition pvData.h:713
ValueBuilder & add(const std::string &name, const shared_vector< const T > &V)
Add a scalar array field.
ValueBuilder & add(const std::string &name, typename meta::arg_type< typename ScalarTypeTraits< ENUM >::type >::type V)
Add a scalar field with a given name and initial value.
A holder for a contiguous piece of memory.
epics
Definition convert.h:21