normativeTypesCPP 6.0.2
ntunion.h
Go to the documentation of this file.
1/* ntunion.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 NTUNION_H
7#define NTUNION_H
8
9#ifdef epicsExportSharedSymbols
10# define ntunionEpicsExportSharedSymbols
11# undef epicsExportSharedSymbols
12#endif
13
14#ifdef ntunionEpicsExportSharedSymbols
15# define epicsExportSharedSymbols
16# undef ntunionEpicsExportSharedSymbols
17#endif
18
19#include <pv/ntfield.h>
20
21#include <shareLib.h>
22
23namespace epics { namespace nt {
24
25class NTUnion;
26typedef std::tr1::shared_ptr<NTUnion> NTUnionPtr;
27
28namespace detail {
29
37 class epicsShareClass NTUnionBuilder :
38 public std::tr1::enable_shared_from_this<NTUnionBuilder>
39 {
40 public:
42
49 shared_pointer value(epics::pvData::UnionConstPtr unionType);
50
55 shared_pointer addDescriptor();
56
61 shared_pointer addAlarm();
62
67 shared_pointer addTimeStamp();
68
74 epics::pvData::StructureConstPtr createStructure();
75
81 epics::pvData::PVStructurePtr createPVStructure();
82
88 NTUnionPtr create();
95 shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
96
97 private:
99
100 epics::pvData::UnionConstPtr valueType;
101
102 void reset();
103
104 bool descriptor;
105 bool alarm;
106 bool timeStamp;
107
108 // NOTE: this preserves order, however it does not handle duplicates
109 epics::pvData::StringArray extraFieldNames;
110 epics::pvData::FieldConstPtrArray extraFields;
111
112 friend class ::epics::nt::NTUnion;
113 };
114
115}
116
117typedef std::tr1::shared_ptr<detail::NTUnionBuilder> NTUnionBuilderPtr;
118
119
120
126class epicsShareClass NTUnion
127{
128public:
130
131 static const std::string URI;
132
144 static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
145
154 static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
155
167 static bool is_a(epics::pvData::StructureConstPtr const & structure);
168
180 static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
181
190 static bool isCompatible(
191 epics::pvData::StructureConstPtr const &structure);
192
201 static bool isCompatible(
202 epics::pvData::PVStructurePtr const &pvStructure);
203
212 bool isValid();
213
218 static NTUnionBuilderPtr createBuilder();
219
224
231 bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
232
239 bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
240
245 epics::pvData::PVStructurePtr getPVStructure() const;
246
251 epics::pvData::PVStringPtr getDescriptor() const;
252
257 epics::pvData::PVStructurePtr getTimeStamp() const;
258
263 epics::pvData::PVStructurePtr getAlarm() const;
264
269 epics::pvData::PVUnionPtr getValue() const;
270
271private:
272 NTUnion(epics::pvData::PVStructurePtr const & pvStructure);
273 epics::pvData::PVStructurePtr pvNTUnion;
274 epics::pvData::PVUnionPtr pvValue;
275
277};
278
279}}
280#endif /* NTUNION_H */
Convenience Class for NTUnion.
Definition ntunion.h:127
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
static bool is_a(epics::pvData::PVStructurePtr const &pvStructure)
static bool isCompatible(epics::pvData::PVStructurePtr const &pvStructure)
POINTER_DEFINITIONS(NTUnion)
static bool is_a(epics::pvData::StructureConstPtr const &structure)
static const std::string URI
Definition ntunion.h:131
Interface for in-line creating of NTUnion.
Definition ntunion.h:39
std::tr1::shared_ptr< detail::NTUnionBuilder > NTUnionBuilderPtr
Definition ntunion.h:117
std::tr1::shared_ptr< NTUnion > NTUnionPtr
Definition ntunion.h:26