This is Unofficial EPICS BASE Doxygen Site
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 
26 namespace epics { namespace nt {
27 
28 class NTScalar;
29 typedef std::tr1::shared_ptr<NTScalar> NTScalarPtr;
30 
31 namespace detail {
32 
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:
113  NTScalarBuilder();
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;
129 
130  friend class ::epics::nt::NTScalar;
131  };
132 
133 }
134 
135 typedef std::tr1::shared_ptr<detail::NTScalarBuilder> NTScalarBuilderPtr;
136 
137 
138 
145 {
146 public:
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(
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 
333 private:
334  NTScalar(epics::pvData::PVStructurePtr const & pvStructure);
337 
339 };
340 
341 }}
342 #endif /* NTSCALAR_H */
Definition: link.h:174
Methods for accessing an control structure.
Definition: pvControl.h:34
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.
Convenience Class for NTScalar.
Definition: ntscalar.h:144
#define POINTER_DEFINITIONS(clazz)
Definition: sharedPtr.h:198
Methods for accessing a timeStamp structure.
Definition: pvTimeStamp.h:38
Interface for in-line creating of NTScalar.
Definition: ntscalar.h:40
#define epicsShareClass
Definition: shareLib.h:206
std::tr1::shared_ptr< detail::NTScalarBuilder > NTScalarBuilderPtr
Definition: ntscalar.h:135
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
static const std::string URI
Definition: ntscalar.h:149
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
std::tr1::shared_ptr< PVString > PVStringPtr
Definition: pvData.h:540
std::vector< std::string > StringArray
Definition: pvType.h:110
std::tr1::shared_ptr< PVField > PVFieldPtr
Definition: pvData.h:66
Methods for accessing an display structure.
Definition: pvDisplay.h:39
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:808
std::tr1::shared_ptr< PVT > getValue() const
Definition: ntscalar.h:328
std::tr1::shared_ptr< NTScalar > NTScalarPtr
Definition: ntscalar.h:28