This is Unofficial EPICS BASE Doxygen Site
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 
29 namespace epics { namespace nt {
30 
31 class NTTable;
32 typedef std::tr1::shared_ptr<NTTable> NTTablePtr;
33 
34 namespace detail {
35 
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:
108  NTTableBuilder();
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;
122 
123  friend class ::epics::nt::NTTable;
124  };
125 
126 }
127 
128 typedef std::tr1::shared_ptr<detail::NTTableBuilder> NTTableBuilderPtr;
129 
130 
131 
138 {
139 public:
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(
205 
215  static bool isCompatible(
216  epics::pvData::PVStructurePtr const &pvStructure);
217 
226  bool isValid();
227 
232  static NTTableBuilderPtr createBuilder();
233 
237  ~NTTable() {}
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 
318 private:
319  NTTable(epics::pvData::PVStructurePtr const & pvStructure);
323 };
324 
325 }}
326 #endif /* NTTABLE_H */
std::tr1::shared_ptr< detail::NTTableBuilder > NTTableBuilderPtr
Definition: nttable.h:128
TODO only here because of the Lockable.
Definition: ntaggregate.cpp:16
std::tr1::shared_ptr< const Structure > StructureConstPtr
Definition: pvIntrospect.h:162
Mark external symbols and entry points for shared libraries.
std::tr1::shared_ptr< PVStringArray > PVStringArrayPtr
Definition: pvData.h:1464
#define POINTER_DEFINITIONS(clazz)
Definition: sharedPtr.h:198
Methods for accessing a timeStamp structure.
Definition: pvTimeStamp.h:38
#define epicsShareClass
Definition: shareLib.h:206
Methods for accessing an alarm structure.
Definition: pvAlarm.h:37
std::vector< FieldConstPtr > FieldConstPtrArray
Definition: pvIntrospect.h:146
std::tr1::shared_ptr< const Field > FieldConstPtr
Definition: pvIntrospect.h:137
std::tr1::shared_ptr< PVT > getColumn(std::string const &columnName) const
Definition: nttable.h:309
static const std::string URI
Definition: nttable.h:142
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
std::tr1::shared_ptr< PVString > PVStringPtr
Definition: pvData.h:540
std::tr1::shared_ptr< NTTable > NTTablePtr
Definition: nttable.h:31
Interface for in-line creating of NTTable.
Definition: nttable.h:43
Convenience Class for NTTable.
Definition: nttable.h:137
std::vector< std::string > StringArray
Definition: pvType.h:110
std::tr1::shared_ptr< PVField > PVFieldPtr
Definition: pvData.h:66