This is Unofficial EPICS BASE Doxygen Site
epics::nt::NTHistogram Class Reference

Convenience Class for NTHistogram. More...

#include "nthistogram.h"

Public Member Functions

 POINTER_DEFINITIONS (NTHistogram)
 
bool isValid ()
 
 ~NTHistogram ()
 
bool attachTimeStamp (epics::pvData::PVTimeStamp &pvTimeStamp) const
 
bool attachAlarm (epics::pvData::PVAlarm &pvAlarm) const
 
epics::pvData::PVStructurePtr getPVStructure () const
 
epics::pvData::PVStringPtr getDescriptor () const
 
epics::pvData::PVStructurePtr getTimeStamp () const
 
epics::pvData::PVStructurePtr getAlarm () const
 
epics::pvData::PVDoubleArrayPtr getRanges () const
 
epics::pvData::PVScalarArrayPtr getValue () const
 
template<typename PVT >
std::tr1::shared_ptr< PVT > getValue () const
 

Static Public Member Functions

static shared_pointer wrap (epics::pvData::PVStructurePtr const &pvStructure)
 
static shared_pointer wrapUnsafe (epics::pvData::PVStructurePtr const &pvStructure)
 
static bool is_a (epics::pvData::StructureConstPtr const &structure)
 
static bool is_a (epics::pvData::PVStructurePtr const &pvStructure)
 
static bool isCompatible (epics::pvData::StructureConstPtr const &structure)
 
static bool isCompatible (epics::pvData::PVStructurePtr const &pvStructure)
 
static NTHistogramBuilderPtr createBuilder ()
 

Static Public Attributes

static const std::string URI
 

Friends

class detail::NTHistogramBuilder
 

Detailed Description

Convenience Class for NTHistogram.

Author
dgh

Definition at line 128 of file nthistogram.h.

Constructor & Destructor Documentation

epics::nt::NTHistogram::~NTHistogram ( )
inline

Destructor.

Definition at line 229 of file nthistogram.h.

229 {}

Member Function Documentation

bool epics::nt::NTHistogram::attachAlarm ( epics::pvData::PVAlarm pvAlarm) const

Attaches a PVAlarm to the wrapped PVStructure. Does nothing if no alarm field.

Parameters
pvAlarmthe PVAlarm that will be attached.
Returns
true if the operation was successfull (i.e. this instance has an alarm field), otherwise false.

Definition at line 181 of file nthistogram.cpp.

182 {
183  PVStructurePtr al = getAlarm();
184  if (al)
185  return pvAlarm.attach(al);
186  else
187  return false;
188 }
bool attach(PVFieldPtr const &pvField)
Definition: pvAlarm.cpp:26
epics::pvData::PVStructurePtr getAlarm() const
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool epics::nt::NTHistogram::attachTimeStamp ( epics::pvData::PVTimeStamp pvTimeStamp) const

Attaches a PVTimeStamp to the wrapped PVStructure. Does nothing if no timeStamp field.

Parameters
pvTimeStampthe PVTimeStamp that will be attached.
Returns
true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false.

Definition at line 172 of file nthistogram.cpp.

173 {
175  if (ts)
176  return pvTimeStamp.attach(ts);
177  else
178  return false;
179 }
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
epics::pvData::PVStructurePtr getTimeStamp() const
bool attach(PVFieldPtr const &pvField)
Definition: pvTimeStamp.cpp:26
NTHistogramBuilderPtr epics::nt::NTHistogram::createBuilder ( )
static

Creates an NTHistogram builder instance.

Returns
builder instance.

Definition at line 167 of file nthistogram.cpp.

168 {
169  return NTHistogramBuilderPtr(new detail::NTHistogramBuilder());
170 }
std::tr1::shared_ptr< detail::NTHistogramBuilder > NTHistogramBuilderPtr
Definition: nthistogram.h:119
PVStructurePtr epics::nt::NTHistogram::getAlarm ( ) const

Returns the alarm field.

Returns
the alarm field or null if no such field.

Definition at line 205 of file nthistogram.cpp.

206 {
207  return pvNTHistogram->getSubField<PVStructure>("alarm");
208 }
Data interface for a structure,.
Definition: pvData.h:712
PVStringPtr epics::nt::NTHistogram::getDescriptor ( ) const

Returns the descriptor field.

Returns
the descriptor field or null if no such field.

Definition at line 195 of file nthistogram.cpp.

196 {
197  return pvNTHistogram->getSubField<PVString>("descriptor");
198 }
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
PVStructurePtr epics::nt::NTHistogram::getPVStructure ( ) const

Get the PVStructure wrapped by this instance.

Returns
the PVStructure wrapped by this instance.

Definition at line 190 of file nthistogram.cpp.

191 {
192  return pvNTHistogram;
193 }
PVDoubleArrayPtr epics::nt::NTHistogram::getRanges ( ) const

Returns the ranges field.

Returns
the ranges field.

Definition at line 210 of file nthistogram.cpp.

211 {
212  return pvNTHistogram->getSubField<PVDoubleArray>("ranges");
213 }
template class for all extensions of PVArray.
Definition: pvData.h:55
PVStructurePtr epics::nt::NTHistogram::getTimeStamp ( ) const

Returns the timeStamp field.

Returns
the timStamp field or null if no such field.

Definition at line 200 of file nthistogram.cpp.

201 {
202  return pvNTHistogram->getSubField<PVStructure>("timeStamp");
203 }
Data interface for a structure,.
Definition: pvData.h:712
PVScalarArrayPtr epics::nt::NTHistogram::getValue ( ) const

Returns the value field.

Returns
the value field.

Definition at line 215 of file nthistogram.cpp.

216 {
217  return pvValue;
218 }
template<typename PVT >
std::tr1::shared_ptr<PVT> epics::nt::NTHistogram::getValue ( ) const
inline

Returns the value field of a specified type (e.g. PVIntArray).

Template Parameters
PVTthe expected type of the value field which should be be PVShortArray, PVIntArray pr PVLongArray.
Returns
the value field or null if it is not of the expected type.

Definition at line 290 of file nthistogram.h.

291  {
292  return std::tr1::dynamic_pointer_cast<PVT>(pvValue);
293  }
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:808
bool epics::nt::NTHistogram::is_a ( epics::pvData::StructureConstPtr const &  structure)
static

Returns whether the specified Structure reports to be a compatible NTHistogram.

Checks whether the specified Structure reports compatibility with this version of NTHistogram through its type ID, including checking version numbers. The return value does not depend on whether the structure is actually compatible in terms of its introspection type.

Parameters
structurethe Structure to test.
Returns
(false,true) if the specified Structure (is not, is) a compatible NTHistogram

Definition at line 128 of file nthistogram.cpp.

129 {
130  return NTUtils::is_a(structure->getID(), URI);
131 }
static const std::string URI
Definition: nthistogram.h:133
static bool is_a(const std::string &u1, const std::string &u2)
Definition: ntutils.cpp:14
bool epics::nt::NTHistogram::is_a ( epics::pvData::PVStructurePtr const &  pvStructure)
static

Returns whether the specified PVStructure reports to be a compatible NTHistogram.

Checks whether the specified PVStructure reports compatibility with this version of NTHistogram through its type ID, including checking version numbers. The return value does not depend on whether the structure is actually compatible in terms of its introspection type.

Parameters
pvStructurethe PVStructure to test
Returns
(false,true) if the specified PVStructure (is not, is) a compatible NTHistogram

Definition at line 133 of file nthistogram.cpp.

134 {
135  return is_a(pvStructure->getStructure());
136 }
static bool is_a(epics::pvData::StructureConstPtr const &structure)
bool epics::nt::NTHistogram::isCompatible ( epics::pvData::StructureConstPtr const &  structure)
static

Returns whether the specified Structure is compatible with NTHistogram.

Checks whether the specified Structure is compatible with this version of NTHistogram through the introspection interface.

Parameters
structurethe Structure to test
Returns
(false,true) if the specified Structure (is not, is) a compatible NTHistogram

Definition at line 138 of file nthistogram.cpp.

139 {
140  if (!structure)
141  return false;
142 
143  Result result(structure);
144 
145  return result
146  .is<Structure>()
147  .has<ScalarArray>("ranges")
148  .has<ScalarArray>("value")
149  .maybeHas<Scalar>("descriptor")
150  .maybeHas<&NTField::isAlarm, Structure>("alarm")
151  .maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
152  .valid();
153 }
pvac::PutEvent result
Definition: clientSync.cpp:117
This class implements introspection object for a structure.
Definition: pvIntrospect.h:697
bool isAlarm(epics::pvData::FieldConstPtr const &field)
Definition: ntfield.cpp:70
This class implements introspection object for scalar array.
Definition: pvIntrospect.h:497
bool epics::nt::NTHistogram::isCompatible ( epics::pvData::PVStructurePtr const &  pvStructure)
static

Returns whether the specified PVStructure is compatible with NTHistogram.

Checks whether the specified PVStructure is compatible with this version of NTHistogram through the introspection interface.

Parameters
pvStructurethe PVStructure to test
Returns
(false,true) if the specified PVStructure (is not, is) a compatible NTHistogram

Definition at line 155 of file nthistogram.cpp.

156 {
157  if(!pvStructure.get()) return false;
158 
159  return isCompatible(pvStructure->getStructure());
160 }
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
bool epics::nt::NTHistogram::isValid ( )

Returns whether the wrapped structure is valid with respect to this version of NTHistogram.

Unlike isCompatible(), isValid() may perform checks on the value data as well as the introspection data.

Returns
(false,true) if the wrapped PVStructure (is not, is) a valid NTHistogram

Definition at line 162 of file nthistogram.cpp.

163 {
164  return (getValue()->getLength()+1 == getRanges()->getLength());
165 }
epics::pvData::PVScalarArrayPtr getValue() const
epics::pvData::PVDoubleArrayPtr getRanges() const
epics::nt::NTHistogram::POINTER_DEFINITIONS ( NTHistogram  )
NTHistogram::shared_pointer epics::nt::NTHistogram::wrap ( epics::pvData::PVStructurePtr const &  pvStructure)
static

Creates an NTHistogram wrapping the specified PVStructure if the latter is compatible.

Checks the supplied PVStructure is compatible with NTHistogram and if so returns an NTHistogram which wraps it. This method will return null if the structure is is not compatible or is null.

Parameters
pvStructurethe PVStructure to be wrapped
Returns
NTHistogram instance wrapping pvStructure on success, null otherwise

Definition at line 117 of file nthistogram.cpp.

118 {
119  if(!isCompatible(pvStructure)) return shared_pointer();
120  return wrapUnsafe(pvStructure);
121 }
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const &pvStructure)
NTHistogram::shared_pointer epics::nt::NTHistogram::wrapUnsafe ( epics::pvData::PVStructurePtr const &  pvStructure)
static

Creates an NTHistogram wrapping the specified PVStructure, regardless of the latter's compatibility.

No checks are made as to whether the specified PVStructure is compatible with NTHistogram or is non-null.

Parameters
pvStructurethe PVStructure to be wrapped.
Returns
NTHistogram instance wrapping pvStructure.

Definition at line 123 of file nthistogram.cpp.

124 {
125  return shared_pointer(new NTHistogram(pvStructure));
126 }

Friends And Related Function Documentation

friend class detail::NTHistogramBuilder
friend

Definition at line 301 of file nthistogram.h.

Member Data Documentation

const std::string epics::nt::NTHistogram::URI
static

Definition at line 133 of file nthistogram.h.


The documentation for this class was generated from the following files: