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

Convenience Class for NTMatrix. More...

#include "ntmatrix.h"

Public Member Functions

 POINTER_DEFINITIONS (NTMatrix)
 
bool isValid ()
 
 ~NTMatrix ()
 
bool attachTimeStamp (epics::pvData::PVTimeStamp &pvTimeStamp) const
 
bool attachAlarm (epics::pvData::PVAlarm &pvAlarm) const
 
bool attachDisplay (epics::pvData::PVDisplay &pvDisplay) 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::PVDoubleArrayPtr getValue () const
 
epics::pvData::PVIntArrayPtr getDim () 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 NTMatrixBuilderPtr createBuilder ()
 

Static Public Attributes

static const std::string URI
 

Friends

class detail::NTMatrixBuilder
 

Detailed Description

Convenience Class for NTMatrix.

Author
dgh

Definition at line 134 of file ntmatrix.h.

Constructor & Destructor Documentation

epics::nt::NTMatrix::~NTMatrix ( )
inline

Destructor.

Definition at line 235 of file ntmatrix.h.

235 {}

Member Function Documentation

bool epics::nt::NTMatrix::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 207 of file ntmatrix.cpp.

208 {
209  PVStructurePtr al = getAlarm();
210  if (al)
211  return pvAlarm.attach(al);
212  else
213  return false;
214 }
bool attach(PVFieldPtr const &pvField)
Definition: pvAlarm.cpp:26
epics::pvData::PVStructurePtr getAlarm() const
Definition: ntmatrix.cpp:240
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool epics::nt::NTMatrix::attachDisplay ( epics::pvData::PVDisplay pvDisplay) const

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

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 216 of file ntmatrix.cpp.

217 {
218  PVStructurePtr dp = getDisplay();
219  if (dp)
220  return pvDisplay.attach(dp);
221  else
222  return false;
223 }
bool attach(PVFieldPtr const &pvField)
Definition: pvDisplay.cpp:26
epics::pvData::PVStructurePtr getDisplay() const
Definition: ntmatrix.cpp:245
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool epics::nt::NTMatrix::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 198 of file ntmatrix.cpp.

199 {
201  if (ts)
202  return pvTimeStamp.attach(ts);
203  else
204  return false;
205 }
epics::pvData::PVStructurePtr getTimeStamp() const
Definition: ntmatrix.cpp:235
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool attach(PVFieldPtr const &pvField)
Definition: pvTimeStamp.cpp:26
NTMatrixBuilderPtr epics::nt::NTMatrix::createBuilder ( )
static

Creates an NTMatrix builder instance.

Returns
builder instance.

Definition at line 193 of file ntmatrix.cpp.

194 {
195  return NTMatrixBuilderPtr(new detail::NTMatrixBuilder());
196 }
std::tr1::shared_ptr< detail::NTMatrixBuilder > NTMatrixBuilderPtr
Definition: ntmatrix.h:125
PVStructurePtr epics::nt::NTMatrix::getAlarm ( ) const

Returns the alarm field.

Returns
the alarm field or null if no such field.

Definition at line 240 of file ntmatrix.cpp.

241 {
242  return pvNTMatrix->getSubField<PVStructure>("alarm");
243 }
Data interface for a structure,.
Definition: pvData.h:712
PVStringPtr epics::nt::NTMatrix::getDescriptor ( ) const

Returns the descriptor field.

Returns
the descriptor field or null if no such field.

Definition at line 230 of file ntmatrix.cpp.

231 {
232  return pvNTMatrix->getSubField<PVString>("descriptor");
233 }
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
PVIntArrayPtr epics::nt::NTMatrix::getDim ( ) const

Returns the dim field.

Returns
the dim field or or null if no such field.

Definition at line 255 of file ntmatrix.cpp.

256 {
257  return pvNTMatrix->getSubField<PVIntArray>("dim");
258 }
template class for all extensions of PVArray.
Definition: pvData.h:55
PVStructurePtr epics::nt::NTMatrix::getDisplay ( ) const

Returns the display field.

Returns
the display field or null if no such field.

Definition at line 245 of file ntmatrix.cpp.

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

Get the PVStructure wrapped by this instance.

Returns
the PVStructure wrapped by this instance.

Definition at line 225 of file ntmatrix.cpp.

226 {
227  return pvNTMatrix;
228 }
PVStructurePtr epics::nt::NTMatrix::getTimeStamp ( ) const

Returns the timeStamp field.

Returns
the timStamp field or null if no such field.

Definition at line 235 of file ntmatrix.cpp.

236 {
237  return pvNTMatrix->getSubField<PVStructure>("timeStamp");
238 }
Data interface for a structure,.
Definition: pvData.h:712
PVDoubleArrayPtr epics::nt::NTMatrix::getValue ( ) const

Returns the value field.

Returns
the value field.

Definition at line 250 of file ntmatrix.cpp.

251 {
252  return pvValue;
253 }
bool epics::nt::NTMatrix::is_a ( epics::pvData::StructureConstPtr const &  structure)
static

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

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

Definition at line 132 of file ntmatrix.cpp.

133 {
134  return NTUtils::is_a(structure->getID(), URI);
135 }
static const std::string URI
Definition: ntmatrix.h:139
static bool is_a(const std::string &u1, const std::string &u2)
Definition: ntutils.cpp:14
bool epics::nt::NTMatrix::is_a ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Definition at line 137 of file ntmatrix.cpp.

138 {
139  return is_a(pvStructure->getStructure());
140 }
static bool is_a(epics::pvData::StructureConstPtr const &structure)
Definition: ntmatrix.cpp:132
bool epics::nt::NTMatrix::isCompatible ( epics::pvData::StructureConstPtr const &  structure)
static

Returns whether the specified Structure is compatible with NTMatrix.

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

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

Definition at line 142 of file ntmatrix.cpp.

143 {
144  if (!structure)
145  return false;
146 
147  Result result(structure);
148 
149  return result
150  .is<Structure>()
151  .has<ScalarArray>("value")
152  .maybeHas<ScalarArray>("dim")
153  .maybeHas<Scalar>("descriptor")
154  .maybeHas<&NTField::isAlarm, Structure>("alarm")
155  .maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
156  .maybeHas<&NTField::isDisplay, Structure>("display")
157  .valid();
158 }
pvac::PutEvent result
Definition: clientSync.cpp:117
This class implements introspection object for a structure.
Definition: pvIntrospect.h:697
bool isDisplay(epics::pvData::FieldConstPtr const &field)
Definition: ntfield.cpp:87
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::NTMatrix::isCompatible ( epics::pvData::PVStructurePtr const &  pvStructure)
static

Returns whether the specified PVStructure is compatible with NTMatrix.

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

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

Definition at line 160 of file ntmatrix.cpp.

161 {
162  if(!pvStructure) return false;
163 
164  return isCompatible(pvStructure->getStructure());
165 }
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
Definition: ntmatrix.cpp:142
bool epics::nt::NTMatrix::isValid ( )

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

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 NTMatrix

Definition at line 167 of file ntmatrix.cpp.

168 {
169  int valueLength = getValue()->getLength();
170  if (valueLength == 0)
171  return false;
172 
173  PVIntArrayPtr pvDim = getDim();
174  if (pvDim.get())
175  {
176  int length = pvDim->getLength();
177  if (length != 1 && length !=2)
178  return false;
179 
180  PVIntArray::const_svector data = pvDim->view();
181  int expectedLength = 1;
182  for (PVIntArray::const_svector::const_iterator it = data.begin();
183  it != data.end(); ++it)
184  {
185  expectedLength *= *it;
186  }
187  if (expectedLength != valueLength)
188  return false;
189  }
190  return true;
191 }
std::tr1::shared_ptr< PVIntArray > PVIntArrayPtr
Definition: pvData.h:1440
epics::pvData::PVDoubleArrayPtr getValue() const
Definition: ntmatrix.cpp:250
epics::pvData::PVIntArrayPtr getDim() const
Definition: ntmatrix.cpp:255
epics::nt::NTMatrix::POINTER_DEFINITIONS ( NTMatrix  )
NTMatrix::shared_pointer epics::nt::NTMatrix::wrap ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Definition at line 121 of file ntmatrix.cpp.

122 {
123  if(!isCompatible(pvStructure)) return shared_pointer();
124  return wrapUnsafe(pvStructure);
125 }
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const &pvStructure)
Definition: ntmatrix.cpp:127
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
Definition: ntmatrix.cpp:142
NTMatrix::shared_pointer epics::nt::NTMatrix::wrapUnsafe ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Parameters
pvStructurethe PVStructure to be wrapped
Returns
NTMatrix instance wrapping pvStructure

Definition at line 127 of file ntmatrix.cpp.

128 {
129  return shared_pointer(new NTMatrix(pvStructure));
130 }

Friends And Related Function Documentation

friend class detail::NTMatrixBuilder
friend

Definition at line 308 of file ntmatrix.h.

Member Data Documentation

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

Definition at line 139 of file ntmatrix.h.


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