normativeTypesCPP 6.0.2
nttable.h
Go to the documentation of this file.
1/* nttable.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 NTTABLE_H
7#define NTTABLE_H
8
9#include <vector>
10#include <string>
11
12#ifdef epicsExportSharedSymbols
13# define nttableEpicsExportSharedSymbols
14# undef epicsExportSharedSymbols
15#endif
16
17#include <pv/pvDisplay.h>
18#include <pv/pvControl.h>
19
20#ifdef nttableEpicsExportSharedSymbols
21# define epicsExportSharedSymbols
22# undef nttableEpicsExportSharedSymbols
23#endif
24
25#include <pv/ntfield.h>
26
27#include <shareLib.h>
28
29namespace epics { namespace nt {
30
31class NTTable;
32typedef std::tr1::shared_ptr<NTTable> NTTablePtr;
33
34namespace detail {
35
43 class epicsShareClass NTTableBuilder :
44 public std::tr1::enable_shared_from_this<NTTableBuilder>
45 {
46 public:
48
55 shared_pointer addColumn(std::string const & name, epics::pvData::ScalarType elementType);
56
61 shared_pointer addDescriptor();
62
67 shared_pointer addAlarm();
68
73 shared_pointer addTimeStamp();
74
80 epics::pvData::StructureConstPtr createStructure();
81
88 epics::pvData::PVStructurePtr createPVStructure();
89
97 NTTablePtr create();
98
105 shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
106
107 private:
109
110 void reset();
111
112 std::vector<std::string> columnNames;
113 std::vector<epics::pvData::ScalarType> types;
114
115 bool descriptor;
116 bool alarm;
117 bool timeStamp;
118
119 // NOTE: this preserves order, however it does not handle duplicates
120 epics::pvData::StringArray extraFieldNames;
121 epics::pvData::FieldConstPtrArray extraFields;
122
123 friend class ::epics::nt::NTTable;
124 };
125
126}
127
128typedef std::tr1::shared_ptr<detail::NTTableBuilder> NTTableBuilderPtr;
129
130
131
137class epicsShareClass NTTable
138{
139public:
141
142 static const std::string URI;
143
155 static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
156
166 static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
167
179 static bool is_a(epics::pvData::StructureConstPtr const & structure);
180
192 static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
193
203 static bool isCompatible(
204 epics::pvData::StructureConstPtr const &structure);
205
215 static bool isCompatible(
216 epics::pvData::PVStructurePtr const &pvStructure);
217
226 bool isValid();
227
232 static NTTableBuilderPtr createBuilder();
233
238
245 bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
246
253 bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
254
259 epics::pvData::PVStructurePtr getPVStructure() const;
260
265 epics::pvData::PVStringPtr getDescriptor() const;
266
271 epics::pvData::PVStructurePtr getTimeStamp() const;
272
277 epics::pvData::PVStructurePtr getAlarm() const;
278
283 epics::pvData::PVStringArrayPtr getLabels() const;
284
290 epics::pvData::StringArray const & getColumnNames() const;
291
297 epics::pvData::PVFieldPtr getColumn(std::string const & columnName) const;
298
308 template<typename PVT>
309 std::tr1::shared_ptr<PVT> getColumn(std::string const & columnName) const
310 {
311 epics::pvData::PVFieldPtr pvField = getColumn(columnName);
312 if (pvField.get())
313 return std::tr1::dynamic_pointer_cast<PVT>(pvField);
314 else
315 return std::tr1::shared_ptr<PVT>();
316 }
317
318private:
319 NTTable(epics::pvData::PVStructurePtr const & pvStructure);
320 epics::pvData::PVStructurePtr pvNTTable;
321 epics::pvData::PVStructurePtr pvValue;
323};
324
325}}
326#endif /* NTTABLE_H */
Convenience Class for NTTable.
Definition nttable.h:138
POINTER_DEFINITIONS(NTTable)
static bool is_a(epics::pvData::StructureConstPtr const &structure)
std::tr1::shared_ptr< PVT > getColumn(std::string const &columnName) const
Definition nttable.h:309
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
static const std::string URI
Definition nttable.h:142
static bool isCompatible(epics::pvData::PVStructurePtr const &pvStructure)
static bool is_a(epics::pvData::PVStructurePtr const &pvStructure)
Interface for in-line creating of NTTable.
Definition nttable.h:45
std::tr1::shared_ptr< detail::NTTableBuilder > NTTableBuilderPtr
Definition nttable.h:128
std::tr1::shared_ptr< NTTable > NTTablePtr
Definition nttable.h:32