normativeTypesCPP 6.0.2
nthistogram.h
Go to the documentation of this file.
1/* nthistogram.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 NTHISTOGRAM_H
7#define NTHISTOGRAM_H
8
9#ifdef epicsExportSharedSymbols
10# define nthistogramEpicsExportSharedSymbols
11# undef epicsExportSharedSymbols
12#endif
13
14#ifdef nthistogramEpicsExportSharedSymbols
15# define epicsExportSharedSymbols
16# undef nthistogramEpicsExportSharedSymbols
17#endif
18
19#include <pv/ntfield.h>
20
21#include <shareLib.h>
22
23
24namespace epics { namespace nt {
25
26class NTHistogram;
27typedef std::tr1::shared_ptr<NTHistogram> NTHistogramPtr;
28
29namespace detail {
30
38 class epicsShareClass NTHistogramBuilder :
39 public std::tr1::enable_shared_from_this<NTHistogramBuilder>
40 {
41 public:
43
49 shared_pointer value(epics::pvData::ScalarType scalarType);
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 NTHistogramPtr create();
89
96 shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
97
98 private:
100
101 void reset();
102
103 bool valueTypeSet;
104 epics::pvData::ScalarType valueType;
105
106 bool descriptor;
107 bool alarm;
108 bool timeStamp;
109
110 // NOTE: this preserves order, however it does not handle duplicates
111 epics::pvData::StringArray extraFieldNames;
112 epics::pvData::FieldConstPtrArray extraFields;
113
114 friend class ::epics::nt::NTHistogram;
115 };
116
117}
118
119typedef std::tr1::shared_ptr<detail::NTHistogramBuilder> NTHistogramBuilderPtr;
120
121
122
128class epicsShareClass NTHistogram
129{
130public:
132
133 static const std::string URI;
134
146 static shared_pointer wrap(epics::pvData::PVStructurePtr const & pvStructure);
147
157 static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const & pvStructure);
158
170 static bool is_a(epics::pvData::StructureConstPtr const & structure);
171
183 static bool is_a(epics::pvData::PVStructurePtr const & pvStructure);
184
194 static bool isCompatible(
195 epics::pvData::StructureConstPtr const &structure);
196
206 static bool isCompatible(
207 epics::pvData::PVStructurePtr const &pvStructure);
208
218 bool isValid();
219
224 static NTHistogramBuilderPtr createBuilder();
225
230
237 bool attachTimeStamp(epics::pvData::PVTimeStamp &pvTimeStamp) const;
238
245 bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;
246
251 epics::pvData::PVStructurePtr getPVStructure() const;
252
257 epics::pvData::PVStringPtr getDescriptor() const;
258
263 epics::pvData::PVStructurePtr getTimeStamp() const;
264
269 epics::pvData::PVStructurePtr getAlarm() const;
270
275 epics::pvData::PVDoubleArrayPtr getRanges() const;
276
281 epics::pvData::PVScalarArrayPtr getValue() const;
282
289 template<typename PVT>
290 std::tr1::shared_ptr<PVT> getValue() const
291 {
292 return std::tr1::dynamic_pointer_cast<PVT>(pvValue);
293 }
294
295
296private:
297 NTHistogram(epics::pvData::PVStructurePtr const & pvStructure);
298 epics::pvData::PVStructurePtr pvNTHistogram;
299 epics::pvData::PVScalarArrayPtr pvValue;
300
302};
303
304}}
305#endif /* NTHISTOGRAM_H */
Convenience Class for NTHistogram.
static const std::string URI
std::tr1::shared_ptr< PVT > getValue() const
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
POINTER_DEFINITIONS(NTHistogram)
static bool isCompatible(epics::pvData::PVStructurePtr const &pvStructure)
static bool is_a(epics::pvData::PVStructurePtr const &pvStructure)
static bool is_a(epics::pvData::StructureConstPtr const &structure)
Interface for in-line creating of NTHistogram.
Definition nthistogram.h:40
POINTER_DEFINITIONS(NTHistogramBuilder)
std::tr1::shared_ptr< detail::NTHistogramBuilder > NTHistogramBuilderPtr
std::tr1::shared_ptr< NTHistogram > NTHistogramPtr
Definition nthistogram.h:27