PVData C++  8.0.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 
31 class epicsShareClass ValueBuilder
32 {
33 public:
35  explicit ValueBuilder(const std::string& id=std::string());
37  explicit ValueBuilder(const PVStructure&);
38  ~ValueBuilder();
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 
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
ValueBuilder & add(const std::string &name, const shared_vector< const T > &V)
Add a scalar array field.
Definition: valueBuilder.h:50
Data interface for a structure,.
Definition: pvData.h:712
constexpr complex< _Tp > & operator=(const _Tp &)
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.
Definition: valueBuilder.h:42