normativeTypesCPP 6.0.2
ntscalar.h
Go to the documentation of this file.
1/* ntscalar.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 NTSCALAR_H
7#define NTSCALAR_H
8
9#ifdef epicsExportSharedSymbols
10# define ntscalarEpicsExportSharedSymbols
11# undef epicsExportSharedSymbols
12#endif
13
14#include <pv/pvDisplay.h>
15#include <pv/pvControl.h>
16
17#ifdef ntscalarEpicsExportSharedSymbols
18# define epicsExportSharedSymbols
19# undef ntscalarEpicsExportSharedSymbols
20#endif
21
22#include <pv/ntfield.h>
23
24#include <shareLib.h>
25
26namespace epics { namespace nt {
27
28class NTScalar;
29typedef std::tr1::shared_ptr<NTScalar> NTScalarPtr;
30
31namespace detail {
32
40 class epicsShareClass NTScalarBuilder :
41 public std::tr1::enable_shared_from_this<NTScalarBuilder>
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
75 shared_pointer addDisplay();
76
81 shared_pointer addControl();
82
88 epics::pvData::StructureConstPtr createStructure();
89
95 epics::pvData::PVStructurePtr createPVStructure();
96
102 NTScalarPtr create();
103
110 shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
111
112 private:
114
115 void reset();
116
117 bool valueTypeSet;
118 epics::pvData::ScalarType valueType;
119
120 bool descriptor;
121 bool alarm;
122 bool timeStamp;
123 bool display;
124 bool control;
125
126 // NOTE: this preserves order, however it does not handle duplicates
127 epics::pvData::StringArray extraFieldNames;
128 epics::pvData::FieldConstPtrArray extraFields;
129
130 friend class ::epics::nt::NTScalar;
131 };
132
133}
134
135typedef std::tr1::shared_ptr<detail::NTScalarBuilder> NTScalarBuilderPtr;
136
137
138
144class epicsShareClass NTScalar
145{
146public:
148
149 static const std::string URI;
150
162 static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
163
173 static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
174
186 static bool is_a(epics::pvData::StructureConstPtr const & structure);
187
199 static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
200
210 static bool isCompatible(
211 epics::pvData::StructureConstPtr const &structure);
212
222 static bool isCompatible(
223 epics::pvData::PVStructurePtr const &pvStructure);
224
234 bool isValid();
235
240 static NTScalarBuilderPtr createBuilder();
241
246
253 bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
254
261 bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
262
269 bool attachDisplay(epics::pvData::PVDisplay &pvDisplay) const;
270
277 bool attachControl(epics::pvData::PVControl &pvControl) const;
278
283 epics::pvData::PVStructurePtr getPVStructure() const;
284
289 epics::pvData::PVStringPtr getDescriptor() const;
290
295 epics::pvData::PVStructurePtr getTimeStamp() const;
296
301 epics::pvData::PVStructurePtr getAlarm() const;
302
307 epics::pvData::PVStructurePtr getDisplay() const;
308
313 epics::pvData::PVStructurePtr getControl() const;
314
319 epics::pvData::PVFieldPtr getValue() const;
320
327 template<typename PVT>
328 std::tr1::shared_ptr<PVT> getValue() const
329 {
330 return std::tr1::dynamic_pointer_cast<PVT>(pvValue);
331 }
332
333private:
334 NTScalar(epics::pvData::PVStructurePtr const & pvStructure);
335 epics::pvData::PVStructurePtr pvNTScalar;
336 epics::pvData::PVFieldPtr pvValue;
337
339};
340
341}}
342#endif /* NTSCALAR_H */
Convenience Class for NTScalar.
Definition ntscalar.h:145
static bool is_a(epics::pvData::StructureConstPtr const &structure)
static bool is_a(epics::pvData::PVStructurePtr const &pvStructure)
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
static bool isCompatible(epics::pvData::PVStructurePtr const &pvStructure)
POINTER_DEFINITIONS(NTScalar)
std::tr1::shared_ptr< PVT > getValue() const
Definition ntscalar.h:328
static const std::string URI
Definition ntscalar.h:149
Interface for in-line creating of NTScalar.
Definition ntscalar.h:42
std::tr1::shared_ptr< detail::NTScalarBuilder > NTScalarBuilderPtr
Definition ntscalar.h:135
std::tr1::shared_ptr< NTScalar > NTScalarPtr
Definition ntscalar.h:29