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

Convenience Class for NTNameValue. More...

#include "ntnameValue.h"

Public Member Functions

 POINTER_DEFINITIONS (NTNameValue)
 
bool isValid ()
 
 ~NTNameValue ()
 
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::PVStringArrayPtr getName () 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 NTNameValueBuilderPtr createBuilder ()
 

Static Public Attributes

static const std::string URI
 

Friends

class detail::NTNameValueBuilder
 

Detailed Description

Convenience Class for NTNameValue.

Author
mrk

Definition at line 128 of file ntnameValue.h.

Constructor & Destructor Documentation

epics::nt::NTNameValue::~NTNameValue ( )
inline

Destructor.

Definition at line 227 of file ntnameValue.h.

227 {}

Member Function Documentation

bool epics::nt::NTNameValue::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 180 of file ntnameValue.cpp.

181 {
182  PVStructurePtr al = getAlarm();
183  if (al)
184  return pvAlarm.attach(al);
185  else
186  return false;
187 }
bool attach(PVFieldPtr const &pvField)
Definition: pvAlarm.cpp:26
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
epics::pvData::PVStructurePtr getAlarm() const
bool epics::nt::NTNameValue::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 171 of file ntnameValue.cpp.

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

Creates an NTNameValue builder instance.

Returns
builder instance.

Definition at line 166 of file ntnameValue.cpp.

167 {
168  return NTNameValueBuilderPtr(new detail::NTNameValueBuilder());
169 }
std::tr1::shared_ptr< detail::NTNameValueBuilder > NTNameValueBuilderPtr
Definition: ntnameValue.h:121
PVStructurePtr epics::nt::NTNameValue::getAlarm ( ) const

Returns the alarm field.

Returns
the alarm field or null if no alarm field.

Definition at line 204 of file ntnameValue.cpp.

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

Returns the descriptor field.

Returns
the descriptor field or null if no descriptor field.

Definition at line 194 of file ntnameValue.cpp.

195 {
196  return pvNTNameValue->getSubField<PVString>("descriptor");
197 }
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
PVStringArrayPtr epics::nt::NTNameValue::getName ( ) const

Returns the name array field.

Returns
The PVStringArray for the name.

Definition at line 209 of file ntnameValue.cpp.

210 {
211  return pvNTNameValue->getSubField<PVStringArray>("name");
212 }
template class for all extensions of PVArray.
Definition: pvData.h:55
PVStructurePtr epics::nt::NTNameValue::getPVStructure ( ) const

Returns the PVStructure wrapped by this instance.

Returns
the PVStructure wrapped by this instance.

Definition at line 189 of file ntnameValue.cpp.

190 {
191  return pvNTNameValue;
192 }
PVStructurePtr epics::nt::NTNameValue::getTimeStamp ( ) const

Returns the timeStamp field.

Returns
the timStamp field or null if no timeStamp field.

Definition at line 199 of file ntnameValue.cpp.

200 {
201  return pvNTNameValue->getSubField<PVStructure>("timeStamp");
202 }
Data interface for a structure,.
Definition: pvData.h:712
PVFieldPtr epics::nt::NTNameValue::getValue ( ) const

Returns the value array field.

Returns
The PVField for the value.

Definition at line 214 of file ntnameValue.cpp.

215 {
216  return pvNTNameValue->getSubField("value");
217 }
template<typename PVT >
std::tr1::shared_ptr<PVT> epics::nt::NTNameValue::getValue ( ) const
inline

Returns the value array field of a specified expected type (e.g. PVDoubleArray).

Template Parameters
PVTThe expected type of the value field which should be be PVScalarArray or a derived class.
Returns
The PVT array for the value.

Definition at line 289 of file ntnameValue.h.

290  {
292  if (pvField.get())
293  return std::tr1::dynamic_pointer_cast<PVT>(pvField);
294  else
295  return std::tr1::shared_ptr<PVT>();
296  }
std::tr1::shared_ptr< PVField > PVFieldPtr
Definition: pvData.h:66
epics::pvData::PVFieldPtr getValue() const
bool epics::nt::NTNameValue::is_a ( epics::pvData::StructureConstPtr const &  structure)
static

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

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

Definition at line 127 of file ntnameValue.cpp.

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

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

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

Definition at line 132 of file ntnameValue.cpp.

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

Returns whether the specified Structure is compatible with NTNameValue.

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

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

Definition at line 137 of file ntnameValue.cpp.

138 {
139  if (!structure)
140  return false;
141 
142  Result result(structure);
143 
144  return result
145  .is<Structure>()
146  .has<ScalarArray>("name")
147  .has<ScalarArray>("value")
148  .maybeHas<Scalar>("descriptor")
149  .maybeHas<&NTField::isAlarm, Structure>("alarm")
150  .maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
151  .valid();
152 }
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::NTNameValue::isCompatible ( epics::pvData::PVStructurePtr const &  pvStructure)
static

Returns whether the specified PVStructure is compatible with NTNameValue.

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

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

Definition at line 154 of file ntnameValue.cpp.

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

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

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 NTNameValue

Definition at line 161 of file ntnameValue.cpp.

162 {
163  return (getValue<PVScalarArray>()->getLength() == getName()->getLength());
164 }
epics::pvData::PVStringArrayPtr getName() const
epics::nt::NTNameValue::POINTER_DEFINITIONS ( NTNameValue  )
NTNameValue::shared_pointer epics::nt::NTNameValue::wrap ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Definition at line 116 of file ntnameValue.cpp.

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

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

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

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

Definition at line 122 of file ntnameValue.cpp.

123 {
124  return shared_pointer(new NTNameValue(structure));
125 }

Friends And Related Function Documentation

friend class detail::NTNameValueBuilder
friend

Definition at line 301 of file ntnameValue.h.

Member Data Documentation

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

Definition at line 133 of file ntnameValue.h.


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