normativeTypesCPP 6.0.2
ntnameValue.h
Go to the documentation of this file.
1/* ntnameValue.h */
2/*
3 * Copyright information and license terms for this software can be
4 * found in the file LICENSE that is included with the distribution
5 */
6#ifndef NTNAMEVALUE_H
7#define NTNAMEVALUE_H
8
9#ifdef epicsExportSharedSymbols
10# define ntnameValueEpicsExportSharedSymbols
11# undef epicsExportSharedSymbols
12#endif
13
14#include <pv/pvDisplay.h>
15#include <pv/pvControl.h>
16
17#ifdef ntnameValueEpicsExportSharedSymbols
18# define epicsExportSharedSymbols
19# undef ntnameValueEpicsExportSharedSymbols
20#endif
21
22#include <pv/ntfield.h>
23
24#include <shareLib.h>
25
26namespace epics { namespace nt {
27
28class NTNameValue;
29typedef std::tr1::shared_ptr<NTNameValue> NTNameValuePtr;
30
31namespace detail {
32
40 class epicsShareClass NTNameValueBuilder :
41 public std::tr1::enable_shared_from_this<NTNameValueBuilder>
42 {
43 public:
45
51 shared_pointer value(epics::pvData::ScalarType scalarType);
52
57 shared_pointer addDescriptor();
58
63 shared_pointer addAlarm();
64
69 shared_pointer addTimeStamp();
70
76 epics::pvData::StructureConstPtr createStructure();
77
83 epics::pvData::PVStructurePtr createPVStructure();
84
90 NTNameValuePtr create();
91
98 shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
99
100 private:
102
103 void reset();
104
105 bool valueTypeSet;
106 epics::pvData::ScalarType valueType;
107
108 bool descriptor;
109 bool alarm;
110 bool timeStamp;
111
112 // NOTE: this preserves order, however it does not handle duplicates
113 epics::pvData::StringArray extraFieldNames;
114 epics::pvData::FieldConstPtrArray extraFields;
115
116 friend class ::epics::nt::NTNameValue;
117 };
118
119}
120
121typedef std::tr1::shared_ptr<detail::NTNameValueBuilder> NTNameValueBuilderPtr;
122
128class epicsShareClass NTNameValue
129{
130public:
132
133 static const std::string URI;
134
146 static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
147
157 static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
158
170 static bool is_a(epics::pvData::StructureConstPtr const & structure);
171
182 static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
183
192 static bool isCompatible(
193 epics::pvData::StructureConstPtr const &structure);
194
204 static bool isCompatible(
205 epics::pvData::PVStructurePtr const &pvStructure);
206
216 bool isValid();
217
222 static NTNameValueBuilderPtr createBuilder();
223
228
235 bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
236
243 bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
244
249 epics::pvData::PVStructurePtr getPVStructure() const;
250
255 epics::pvData::PVStringPtr getDescriptor() const;
256
261 epics::pvData::PVStructurePtr getTimeStamp() const;
262
267 epics::pvData::PVStructurePtr getAlarm() const;
268
273 epics::pvData::PVStringArrayPtr getName() const;
274
279 epics::pvData::PVFieldPtr getValue() const;
280
288 template<typename PVT>
289 std::tr1::shared_ptr<PVT> getValue() const
290 {
291 epics::pvData::PVFieldPtr pvField = getValue();
292 if (pvField.get())
293 return std::tr1::dynamic_pointer_cast<PVT>(pvField);
294 else
295 return std::tr1::shared_ptr<PVT>();
296 }
297
298private:
299 NTNameValue(epics::pvData::PVStructurePtr const & pvStructure);
300 epics::pvData::PVStructurePtr pvNTNameValue;
302};
303
304}}
305#endif /* NTNAMEVALUE_H */
Convenience Class for NTNameValue.
POINTER_DEFINITIONS(NTNameValue)
std::tr1::shared_ptr< PVT > getValue() const
static bool is_a(epics::pvData::PVStructurePtr const &pvStructure)
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
static const std::string URI
static bool is_a(epics::pvData::StructureConstPtr const &structure)
static bool isCompatible(epics::pvData::PVStructurePtr const &pvStructure)
Interface for in-line creating of NTNameValue.
Definition ntnameValue.h:42
POINTER_DEFINITIONS(NTNameValueBuilder)
std::tr1::shared_ptr< NTNameValue > NTNameValuePtr
Definition ntnameValue.h:29
std::tr1::shared_ptr< detail::NTNameValueBuilder > NTNameValueBuilderPtr