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

Convenience Class for NTTable. More...

#include "nttable.h"

Public Member Functions

 POINTER_DEFINITIONS (NTTable)
 
bool isValid ()
 
 ~NTTable ()
 
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 getLabels () const
 
epics::pvData::StringArray const & getColumnNames () const
 
epics::pvData::PVFieldPtr getColumn (std::string const &columnName) const
 
template<typename PVT >
std::tr1::shared_ptr< PVT > getColumn (std::string const &columnName) 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 NTTableBuilderPtr createBuilder ()
 

Static Public Attributes

static const std::string URI
 

Friends

class detail::NTTableBuilder
 

Detailed Description

Convenience Class for NTTable.

Author
mrk

Definition at line 137 of file nttable.h.

Constructor & Destructor Documentation

epics::nt::NTTable::~NTTable ( )
inline

Destructor.

Definition at line 237 of file nttable.h.

237 {}

Member Function Documentation

bool epics::nt::NTTable::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 228 of file nttable.cpp.

229 {
230  PVStructurePtr al = getAlarm();
231  if (al)
232  return pvAlarm.attach(al);
233  else
234  return false;
235 }
bool attach(PVFieldPtr const &pvField)
Definition: pvAlarm.cpp:26
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
epics::pvData::PVStructurePtr getAlarm() const
Definition: nttable.cpp:252
bool epics::nt::NTTable::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 219 of file nttable.cpp.

220 {
222  if (ts)
223  return pvTimeStamp.attach(ts);
224  else
225  return false;
226 }
epics::pvData::PVStructurePtr getTimeStamp() const
Definition: nttable.cpp:247
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool attach(PVFieldPtr const &pvField)
Definition: pvTimeStamp.cpp:26
NTTableBuilderPtr epics::nt::NTTable::createBuilder ( )
static

Creates an NTTable builder instance.

Returns
builder instance.

Definition at line 214 of file nttable.cpp.

215 {
216  return NTTableBuilderPtr(new detail::NTTableBuilder());
217 }
std::tr1::shared_ptr< detail::NTTableBuilder > NTTableBuilderPtr
Definition: nttable.h:128
PVStructurePtr epics::nt::NTTable::getAlarm ( ) const

Returns the alarm field.

Returns
the alarm field or null if no such field.

Definition at line 252 of file nttable.cpp.

253 {
254  return pvNTTable->getSubField<PVStructure>("alarm");
255 }
Data interface for a structure,.
Definition: pvData.h:712
PVFieldPtr epics::nt::NTTable::getColumn ( std::string const &  columnName) const

Returns the PVField for the column with the specified colum name.

Parameters
columnNamethe name of the column.
Returns
the field for the column or null if column does not exist.

Definition at line 267 of file nttable.cpp.

268 {
269  return pvValue->getSubField(columnName);
270 }
template<typename PVT >
std::tr1::shared_ptr<PVT> epics::nt::NTTable::getColumn ( std::string const &  columnName) const
inline

Returns the column with the specified column name and of a specified expected type (for example, PVDoubleArray).

Template Parameters
PVTthe expected type of the column which should be be PVScalarArray or a derived class.
Parameters
columnNamethe name of the column.
Returns
the field for the column or null if column does not exist or is not of the specified type.

Definition at line 309 of file nttable.h.

310  {
311  epics::pvData::PVFieldPtr pvField = getColumn(columnName);
312  if (pvField.get())
313  return std::tr1::dynamic_pointer_cast<PVT>(pvField);
314  else
315  return std::tr1::shared_ptr<PVT>();
316  }
epics::pvData::PVFieldPtr getColumn(std::string const &columnName) const
Definition: nttable.cpp:267
std::tr1::shared_ptr< PVField > PVFieldPtr
Definition: pvData.h:66
StringArray const & epics::nt::NTTable::getColumnNames ( ) const

Returns the column names for the table. For each name, calling getColumn should return the column, which should not be null.

Returns
the column names.

Definition at line 262 of file nttable.cpp.

263 {
264  return pvValue->getStructure()->getFieldNames();
265 }
PVStringPtr epics::nt::NTTable::getDescriptor ( ) const

Returns the descriptor field.

Returns
the descriptor field or null if no descriptor field.

Definition at line 242 of file nttable.cpp.

243 {
244  return pvNTTable->getSubField<PVString>("descriptor");
245 }
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
PVStringArrayPtr epics::nt::NTTable::getLabels ( ) const

Returns the labels field.

Returns
the labels field.

Definition at line 257 of file nttable.cpp.

258 {
259  return pvNTTable->getSubField<PVStringArray>("labels");
260 }
template class for all extensions of PVArray.
Definition: pvData.h:55
PVStructurePtr epics::nt::NTTable::getPVStructure ( ) const

Returns the PVStructure wrapped by this instance.

Returns
the PVStructure wrapped by this instance.

Definition at line 237 of file nttable.cpp.

238 {
239  return pvNTTable;
240 }
PVStructurePtr epics::nt::NTTable::getTimeStamp ( ) const

Returns the timeStamp field.

Returns
the timStamp field or null if no such field.

Definition at line 247 of file nttable.cpp.

248 {
249  return pvNTTable->getSubField<PVStructure>("timeStamp");
250 }
Data interface for a structure,.
Definition: pvData.h:712
bool epics::nt::NTTable::is_a ( epics::pvData::StructureConstPtr const &  structure)
static

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

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

Definition at line 141 of file nttable.cpp.

142 {
143  return NTUtils::is_a(structure->getID(), URI);
144 }
static const std::string URI
Definition: nttable.h:142
static bool is_a(const std::string &u1, const std::string &u2)
Definition: ntutils.cpp:14
bool epics::nt::NTTable::is_a ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Definition at line 146 of file nttable.cpp.

147 {
148  return is_a(pvStructure->getStructure());
149 }
static bool is_a(epics::pvData::StructureConstPtr const &structure)
Definition: nttable.cpp:141
bool epics::nt::NTTable::isCompatible ( epics::pvData::StructureConstPtr const &  structure)
static

Returns whether the specified Structure is compatible with NTTable.

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

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

Definition at line 151 of file nttable.cpp.

152 {
153  if (!structure)
154  return false;
155 
156  Result result(structure);
157 
158  result
159  .is<Structure>()
160  .has<Structure>("value")
161  .has<ScalarArray>("labels")
162  .maybeHas<Scalar>("descriptor")
163  .maybeHas<&NTField::isAlarm, Structure>("alarm")
164  .maybeHas<&NTField::isTimeStamp, Structure>("timeStamp");
165 
166  StructureConstPtr value(structure->getField<Structure>("value"));
167  if (value) {
168  Result r(value);
169  StringArray const & names(value->getFieldNames());
170  StringArray::const_iterator it;
171 
172  for (it = names.begin(); it != names.end(); ++it)
173  r.has<ScalarArray>(*it);
174 
175  result |= r;
176  }
177 
178  return result.valid();
179 }
Definition: link.h:174
pvac::PutEvent result
Definition: clientSync.cpp:117
std::tr1::shared_ptr< const Structure > StructureConstPtr
Definition: pvIntrospect.h:162
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
std::vector< std::string > StringArray
Definition: pvType.h:110
bool epics::nt::NTTable::isCompatible ( epics::pvData::PVStructurePtr const &  pvStructure)
static

Returns whether the specified PVStructure is compatible with NTTable.

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

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

Definition at line 181 of file nttable.cpp.

182 {
183  if(!pvStructure) return false;
184 
185  return isCompatible(pvStructure->getStructure());
186 }
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
Definition: nttable.cpp:151
bool epics::nt::NTTable::isValid ( )

Returns whether the specified structure is a valid NTTable.

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 NTTable

Definition at line 188 of file nttable.cpp.

189 {
190  PVFieldPtrArray const & columns = pvValue->getPVFields();
191 
192  if (getLabels()->getLength() != columns.size()) return false;
193  bool first = true;
194  int length = 0;
195  for (PVFieldPtrArray::const_iterator it = columns.begin();
196  it != columns.end();++it)
197  {
199  if (!column.get()) return false;
200  int colLength = column->getLength();
201  if (first)
202  {
203  length = colLength;
204  first = false;
205  }
206  else if (length != colLength)
207  return false;
208  }
209 
210  return true;
211 }
virtual std::size_t getLength() const =0
Base class for a scalarArray.
Definition: pvData.h:618
std::vector< PVFieldPtr > PVFieldPtrArray
Definition: pvData.h:70
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:808
std::tr1::shared_ptr< PVScalarArray > PVScalarArrayPtr
Definition: pvData.h:82
epics::pvData::PVStringArrayPtr getLabels() const
Definition: nttable.cpp:257
epics::nt::NTTable::POINTER_DEFINITIONS ( NTTable  )
NTTable::shared_pointer epics::nt::NTTable::wrap ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Definition at line 130 of file nttable.cpp.

131 {
132  if(!isCompatible(pvStructure)) return shared_pointer();
133  return wrapUnsafe(pvStructure);
134 }
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const &pvStructure)
Definition: nttable.cpp:136
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
Definition: nttable.cpp:151
NTTable::shared_pointer epics::nt::NTTable::wrapUnsafe ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Parameters
pvStructurethe PVStructure to be wrapped
Returns
NTTable instance wrapping pvStructure

Definition at line 136 of file nttable.cpp.

137 {
138  return shared_pointer(new NTTable(pvStructure));
139 }

Friends And Related Function Documentation

friend class detail::NTTableBuilder
friend

Definition at line 322 of file nttable.h.

Member Data Documentation

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

Definition at line 142 of file nttable.h.


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