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

Convenience Class for NTScalar. More...

#include "ntscalar.h"

Public Member Functions

 POINTER_DEFINITIONS (NTScalar)
 
bool isValid ()
 
 ~NTScalar ()
 
bool attachTimeStamp (epics::pvData::PVTimeStamp &pvTimeStamp) const
 
bool attachAlarm (epics::pvData::PVAlarm &pvAlarm) const
 
bool attachDisplay (epics::pvData::PVDisplay &pvDisplay) const
 
bool attachControl (epics::pvData::PVControl &pvControl) const
 
epics::pvData::PVStructurePtr getPVStructure () const
 
epics::pvData::PVStringPtr getDescriptor () const
 
epics::pvData::PVStructurePtr getTimeStamp () const
 
epics::pvData::PVStructurePtr getAlarm () const
 
epics::pvData::PVStructurePtr getDisplay () const
 
epics::pvData::PVStructurePtr getControl () const
 
epics::pvData::PVFieldPtr 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 NTScalarBuilderPtr createBuilder ()
 

Static Public Attributes

static const std::string URI
 

Friends

class detail::NTScalarBuilder
 

Detailed Description

Convenience Class for NTScalar.

Author
mrk

Definition at line 144 of file ntscalar.h.

Constructor & Destructor Documentation

epics::nt::NTScalar::~NTScalar ( )
inline

Destructor.

Definition at line 245 of file ntscalar.h.

245 {}

Member Function Documentation

bool epics::nt::NTScalar::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 199 of file ntscalar.cpp.

200 {
201  PVStructurePtr al = getAlarm();
202  if (al)
203  return pvAlarm.attach(al);
204  else
205  return false;
206 }
epics::pvData::PVStructurePtr getAlarm() const
Definition: ntscalar.cpp:241
bool attach(PVFieldPtr const &pvField)
Definition: pvAlarm.cpp:26
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool epics::nt::NTScalar::attachControl ( epics::pvData::PVControl pvControl) const

Attaches an PVControl to the wrapped PVStructure. Does nothing if no control field.

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

Definition at line 217 of file ntscalar.cpp.

218 {
219  PVStructurePtr ctrl = getControl();
220  if (ctrl)
221  return pvControl.attach(ctrl);
222  else
223  return false;
224 }
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool attach(PVFieldPtr const &pvField)
Definition: pvControl.cpp:26
epics::pvData::PVStructurePtr getControl() const
Definition: ntscalar.cpp:251
bool epics::nt::NTScalar::attachDisplay ( epics::pvData::PVDisplay pvDisplay) const

Attaches a PVDisplay to the wrapped PVStructure. Does nothing if no display field.

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

Definition at line 208 of file ntscalar.cpp.

209 {
210  PVStructurePtr dp = getDisplay();
211  if (dp)
212  return pvDisplay.attach(dp);
213  else
214  return false;
215 }
bool attach(PVFieldPtr const &pvField)
Definition: pvDisplay.cpp:26
epics::pvData::PVStructurePtr getDisplay() const
Definition: ntscalar.cpp:246
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool epics::nt::NTScalar::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 190 of file ntscalar.cpp.

191 {
193  if (ts)
194  return pvTimeStamp.attach(ts);
195  else
196  return false;
197 }
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool attach(PVFieldPtr const &pvField)
Definition: pvTimeStamp.cpp:26
epics::pvData::PVStructurePtr getTimeStamp() const
Definition: ntscalar.cpp:236
NTScalarBuilderPtr epics::nt::NTScalar::createBuilder ( )
static

Creates an NTScalar builder instance.

Returns
builder instance.

Definition at line 185 of file ntscalar.cpp.

186 {
187  return NTScalarBuilderPtr(new detail::NTScalarBuilder());
188 }
std::tr1::shared_ptr< detail::NTScalarBuilder > NTScalarBuilderPtr
Definition: ntscalar.h:135
PVStructurePtr epics::nt::NTScalar::getAlarm ( ) const

Returns the alarm field.

Returns
the alarm field or null if no alarm field.

Definition at line 241 of file ntscalar.cpp.

242 {
243  return pvNTScalar->getSubField<PVStructure>("alarm");
244 }
Data interface for a structure,.
Definition: pvData.h:712
PVStructurePtr epics::nt::NTScalar::getControl ( ) const

Returns the control.

Returns
PVStructurePtr which may be null.

Definition at line 251 of file ntscalar.cpp.

252 {
253  return pvNTScalar->getSubField<PVStructure>("control");
254 }
Data interface for a structure,.
Definition: pvData.h:712
PVStringPtr epics::nt::NTScalar::getDescriptor ( ) const

Returns the descriptor field.

Returns
the descriptor field or null if no descriptor field.

Definition at line 231 of file ntscalar.cpp.

232 {
233  return pvNTScalar->getSubField<PVString>("descriptor");
234 }
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
PVStructurePtr epics::nt::NTScalar::getDisplay ( ) const

Returns the display.

Returns
PVStructurePtr which may be null.

Definition at line 246 of file ntscalar.cpp.

247 {
248  return pvNTScalar->getSubField<PVStructure>("display");
249 }
Data interface for a structure,.
Definition: pvData.h:712
PVStructurePtr epics::nt::NTScalar::getPVStructure ( ) const

Returns the PVStructure wrapped by this instance.

Returns
the PVStructure wrapped by this instance.

Definition at line 226 of file ntscalar.cpp.

227 {
228  return pvNTScalar;
229 }
PVStructurePtr epics::nt::NTScalar::getTimeStamp ( ) const

Returns the timeStamp field.

Returns
the timStamp field or null if no timeStamp field.

Definition at line 236 of file ntscalar.cpp.

237 {
238  return pvNTScalar->getSubField<PVStructure>("timeStamp");
239 }
Data interface for a structure,.
Definition: pvData.h:712
PVFieldPtr epics::nt::NTScalar::getValue ( ) const

Returns the value field.

Returns
The PVField for the values.

Definition at line 256 of file ntscalar.cpp.

257 {
258  return pvValue;
259 }
template<typename PVT >
std::tr1::shared_ptr<PVT> epics::nt::NTScalar::getValue ( ) const
inline

Returns the value field of a specified type (for example, PVDouble).

Template Parameters
PVTthe expected type of the value field which should be be PVScalar or a derived class.
Returns
the value field or null if it is not of the expected type.

Definition at line 328 of file ntscalar.h.

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

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

Checks if the specified Structure reports compatibility with this version of NTScalar 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 NTScalar

Definition at line 145 of file ntscalar.cpp.

146 {
147  return NTUtils::is_a(structure->getID(), URI);
148 }
static const std::string URI
Definition: ntscalar.h:149
static bool is_a(const std::string &u1, const std::string &u2)
Definition: ntutils.cpp:14
bool epics::nt::NTScalar::is_a ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

Checks if the specified PVStructure reports compatibility with this version of NTScalar 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 NTScalar

Definition at line 150 of file ntscalar.cpp.

151 {
152  return is_a(pvStructure->getStructure());
153 }
static bool is_a(epics::pvData::StructureConstPtr const &structure)
Definition: ntscalar.cpp:145
bool epics::nt::NTScalar::isCompatible ( epics::pvData::StructureConstPtr const &  structure)
static

Returns whether the specified Structure is compatible with NTScalar.

Checks if the specified Structure is compatible with this version of NTScalar through the introspection interface.

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

Definition at line 155 of file ntscalar.cpp.

156 {
157  if (!structure)
158  return false;
159 
160  Result result(structure);
161 
162  return result
163  .is<Structure>()
164  .has<Scalar>("value")
165  .maybeHas<Scalar>("descriptor")
166  .maybeHas<&NTField::isAlarm, Structure>("alarm")
167  .maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
168  .maybeHas<&NTField::isDisplay, Structure>("display")
169  .maybeHas<&NTField::isControl, Structure>("control")
170  .valid();
171 }
This class implements introspection object for Scalar.
Definition: pvIntrospect.h:397
pvac::PutEvent result
Definition: clientSync.cpp:117
This class implements introspection object for a structure.
Definition: pvIntrospect.h:697
bool isControl(epics::pvData::FieldConstPtr const &field)
Definition: ntfield.cpp:122
bool isTimeStamp(epics::pvData::FieldConstPtr const &field)
Definition: ntfield.cpp:56
bool epics::nt::NTScalar::isCompatible ( epics::pvData::PVStructurePtr const &  pvStructure)
static

Returns whether the specified PVStructure is compatible with NTScalar.

Checks if the specified PVStructure is compatible with this version of NTScalar through the introspection interface.

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

Definition at line 173 of file ntscalar.cpp.

174 {
175  if(!pvStructure) return false;
176 
177  return isCompatible(pvStructure->getStructure());
178 }
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
Definition: ntscalar.cpp:155
bool epics::nt::NTScalar::isValid ( )

Returns whether the wrapped PVStructure is valid with respect to this version of NTScalar.

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

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

Definition at line 180 of file ntscalar.cpp.

181 {
182  return true;
183 }
epics::nt::NTScalar::POINTER_DEFINITIONS ( NTScalar  )
NTScalar::shared_pointer epics::nt::NTScalar::wrap ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

Checks the supplied PVStructure is compatible with NTScalar and if so returns an NTScalar 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
NTScalar instance wrapping pvStructure on success, null otherwise

Definition at line 134 of file ntscalar.cpp.

135 {
136  if(!isCompatible(pvStructure)) return shared_pointer();
137  return wrapUnsafe(pvStructure);
138 }
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
Definition: ntscalar.cpp:155
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const &pvStructure)
Definition: ntscalar.cpp:140
NTScalar::shared_pointer epics::nt::NTScalar::wrapUnsafe ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Parameters
pvStructurethe PVStructure to be wrapped
Returns
NTScalar instance wrapping pvStructure

Definition at line 140 of file ntscalar.cpp.

141 {
142  return shared_pointer(new NTScalar(pvStructure));
143 }

Friends And Related Function Documentation

friend class detail::NTScalarBuilder
friend

Definition at line 338 of file ntscalar.h.

Member Data Documentation

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

Definition at line 149 of file ntscalar.h.


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