normativeTypesCPP
ntenum.h
Go to the documentation of this file.
1 /* ntenum.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 NTENUM_H
7 #define NTENUM_H
8 
9 #ifdef epicsExportSharedSymbols
10 # define ntenumEpicsExportSharedSymbols
11 # undef epicsExportSharedSymbols
12 #endif
13 
14 #ifdef ntenumEpicsExportSharedSymbols
15 # define epicsExportSharedSymbols
16 # undef ntenumEpicsExportSharedSymbols
17 #endif
18 
19 #include <pv/ntfield.h>
20 
21 #include <shareLib.h>
22 
23 namespace epics { namespace nt {
24 
25 class NTEnum;
26 typedef std::tr1::shared_ptr<NTEnum> NTEnumPtr;
27 
28 namespace detail {
29 
37  class epicsShareClass NTEnumBuilder :
38  public std::tr1::enable_shared_from_this<NTEnumBuilder>
39  {
40  public:
41  POINTER_DEFINITIONS(NTEnumBuilder);
42 
47  shared_pointer addDescriptor();
48 
53  shared_pointer addAlarm();
54 
59  shared_pointer addTimeStamp();
60 
66  epics::pvData::StructureConstPtr createStructure();
67 
73  epics::pvData::PVStructurePtr createPVStructure();
74 
80  NTEnumPtr create();
81 
88  shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
89 
90  private:
91  NTEnumBuilder();
92 
93  void reset();
94 
95  bool descriptor;
96  bool alarm;
97  bool timeStamp;
98 
99  // NOTE: this preserves order, however it does not handle duplicates
100  epics::pvData::StringArray extraFieldNames;
101  epics::pvData::FieldConstPtrArray extraFields;
102 
103  friend class ::epics::nt::NTEnum;
104  };
105 
106 }
107 
108 typedef std::tr1::shared_ptr<detail::NTEnumBuilder> NTEnumBuilderPtr;
109 
110 
111 
117 class epicsShareClass NTEnum
118 {
119 public:
120  POINTER_DEFINITIONS(NTEnum);
121 
122  static const std::string URI;
123 
133  static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
134 
144  static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
145 
157  static bool is_a(epics::pvData::StructureConstPtr const & structure);
158 
170  static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
171 
181  static bool isCompatible(
182  epics::pvData::StructureConstPtr const &structure);
183 
193  static bool isCompatible(
194  epics::pvData::PVStructurePtr const &pvStructure);
195 
205  bool isValid();
206 
211  static NTEnumBuilderPtr createBuilder();
212 
216  ~NTEnum() {}
217 
224  bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
225 
232  bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
233 
238  epics::pvData::PVStructurePtr getPVStructure() const;
239 
244  epics::pvData::PVStringPtr getDescriptor() const;
245 
250  epics::pvData::PVStructurePtr getTimeStamp() const;
251 
256  epics::pvData::PVStructurePtr getAlarm() const;
257 
262  epics::pvData::PVStructurePtr getValue() const;
263 
264 private:
265  NTEnum(epics::pvData::PVStructurePtr const & pvStructure);
266  epics::pvData::PVStructurePtr pvNTEnum;
267  epics::pvData::PVStructurePtr pvValue;
268 
269  friend class detail::NTEnumBuilder;
270 };
271 
272 }}
273 #endif /* NTENUM_H */
std::tr1::shared_ptr< detail::NTEnumBuilder > NTEnumBuilderPtr
Definition: ntenum.h:108
Convenience Class for NTEnum.
Definition: ntenum.h:117
Interface for in-line creating of NTEnum.
Definition: ntenum.h:37
static const std::string URI
Definition: ntenum.h:122
std::tr1::shared_ptr< NTEnum > NTEnumPtr
Definition: ntenum.h:25