This is Unofficial EPICS BASE Doxygen Site
valueBuilder.h
Go to the documentation of this file.
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 
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;
85  friend struct child_scalar_base;
86  template <typename T> struct child_scalar;
87  template <typename T> friend struct child_scalar;
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
pvd::StructureConstPtr type
TODO only here because of the Lockable.
Definition: ntaggregate.cpp:16
FORCE_INLINE ValueBuilder & add(const std::string &name, const PVStructure &V)
Definition: valueBuilder.h:56
#define epicsShareClass
Definition: shareLib.h:206
Data interface for a structure,.
Definition: pvData.h:712
FORCE_INLINE 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
FORCE_INLINE ValueBuilder & add(const std::string &name, const shared_vector< const T > &V)
Add a scalar array field.
Definition: valueBuilder.h:50
#define FORCE_INLINE
Definition: templateMeta.h:20