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

Convenience Class for NTUnion. More...

#include "ntunion.h"

Public Member Functions

 POINTER_DEFINITIONS (NTUnion)
 
bool isValid ()
 
 ~NTUnion ()
 
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::PVUnionPtr 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 NTUnionBuilderPtr createBuilder ()
 

Static Public Attributes

static const std::string URI
 

Friends

class detail::NTUnionBuilder
 

Detailed Description

Convenience Class for NTUnion.

Author
dgh

Definition at line 126 of file ntunion.h.

Constructor & Destructor Documentation

epics::nt::NTUnion::~NTUnion ( )
inline

Destructor.

Definition at line 223 of file ntunion.h.

223 {}

Member Function Documentation

bool epics::nt::NTUnion::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 173 of file ntunion.cpp.

174 {
175  PVStructurePtr al = getAlarm();
176  if (al)
177  return pvAlarm.attach(al);
178  else
179  return false;
180 }
bool attach(PVFieldPtr const &pvField)
Definition: pvAlarm.cpp:26
epics::pvData::PVStructurePtr getAlarm() const
Definition: ntunion.cpp:197
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool epics::nt::NTUnion::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 164 of file ntunion.cpp.

165 {
167  if (ts)
168  return pvTimeStamp.attach(ts);
169  else
170  return false;
171 }
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
epics::pvData::PVStructurePtr getTimeStamp() const
Definition: ntunion.cpp:192
bool attach(PVFieldPtr const &pvField)
Definition: pvTimeStamp.cpp:26
NTUnionBuilderPtr epics::nt::NTUnion::createBuilder ( )
static

Creates an NTUnion builder instance.

Returns
builder instance.

Definition at line 159 of file ntunion.cpp.

160 {
161  return NTUnionBuilderPtr(new detail::NTUnionBuilder());
162 }
std::tr1::shared_ptr< detail::NTUnionBuilder > NTUnionBuilderPtr
Definition: ntunion.h:117
PVStructurePtr epics::nt::NTUnion::getAlarm ( ) const

Returns the alarm field.

Returns
the alarm field or null if no alarm field.

Definition at line 197 of file ntunion.cpp.

198 {
199  return pvNTUnion->getSubField<PVStructure>("alarm");
200 }
Data interface for a structure,.
Definition: pvData.h:712
PVStringPtr epics::nt::NTUnion::getDescriptor ( ) const

Returns the descriptor field.

Returns
the descriptor field or null if no descriptor field.

Definition at line 187 of file ntunion.cpp.

188 {
189  return pvNTUnion->getSubField<PVString>("descriptor");
190 }
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
PVStructurePtr epics::nt::NTUnion::getPVStructure ( ) const

Returns the PVStructure wrapped by this instance.

Returns
the PVStructure wrapped by this instance.

Definition at line 182 of file ntunion.cpp.

183 {
184  return pvNTUnion;
185 }
PVStructurePtr epics::nt::NTUnion::getTimeStamp ( ) const

Returns the timeStamp field.

Returns
the timStamp field or null if no timeStamp field.

Definition at line 192 of file ntunion.cpp.

193 {
194  return pvNTUnion->getSubField<PVStructure>("timeStamp");
195 }
Data interface for a structure,.
Definition: pvData.h:712
PVUnionPtr epics::nt::NTUnion::getValue ( ) const

Returns the value field.

Returns
the value field.

Definition at line 202 of file ntunion.cpp.

203 {
204  return pvValue;
205 }
bool epics::nt::NTUnion::is_a ( epics::pvData::StructureConstPtr const &  structure)
static

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

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

Definition at line 121 of file ntunion.cpp.

122 {
123  return NTUtils::is_a(structure->getID(), URI);
124 }
static const std::string URI
Definition: ntunion.h:131
static bool is_a(const std::string &u1, const std::string &u2)
Definition: ntutils.cpp:14
bool epics::nt::NTUnion::is_a ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Definition at line 126 of file ntunion.cpp.

127 {
128  return is_a(pvStructure->getStructure());
129 }
static bool is_a(epics::pvData::StructureConstPtr const &structure)
Definition: ntunion.cpp:121
bool epics::nt::NTUnion::isCompatible ( epics::pvData::StructureConstPtr const &  structure)
static

Returns whether the specified Structure is compatible with NTUnion.

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

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

Definition at line 131 of file ntunion.cpp.

132 {
133  if (!structure)
134  return false;
135 
136  Result result(structure);
137 
138  return result
139  .is<Structure>()
140  .has<Union>("value")
141  .maybeHas<Scalar>("descriptor")
142  .maybeHas<&NTField::isAlarm, Structure>("alarm")
143  .maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
144  .valid();
145 }
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 isTimeStamp(epics::pvData::FieldConstPtr const &field)
Definition: ntfield.cpp:56
bool epics::nt::NTUnion::isCompatible ( epics::pvData::PVStructurePtr const &  pvStructure)
static

Returns whether the specified PVStructure is compatible with NTUnion.

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

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

Definition at line 147 of file ntunion.cpp.

148 {
149  if(!pvStructure) return false;
150 
151  return isCompatible(pvStructure->getStructure());
152 }
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
Definition: ntunion.cpp:131
bool epics::nt::NTUnion::isValid ( )

Returns whether the wrapped PVStructure is a valid NTUnion.

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 NTUnion

Definition at line 154 of file ntunion.cpp.

155 {
156  return true;
157 }
epics::nt::NTUnion::POINTER_DEFINITIONS ( NTUnion  )
NTUnion::shared_pointer epics::nt::NTUnion::wrap ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Definition at line 110 of file ntunion.cpp.

111 {
112  if(!isCompatible(pvStructure)) return shared_pointer();
113  return wrapUnsafe(pvStructure);
114 }
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const &pvStructure)
Definition: ntunion.cpp:116
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
Definition: ntunion.cpp:131
NTUnion::shared_pointer epics::nt::NTUnion::wrapUnsafe ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Parameters
pvStructurethe PVStructure to be wrapped
Returns
NTUnion instance wrapping pvStructure

Definition at line 116 of file ntunion.cpp.

117 {
118  return shared_pointer(new NTUnion(pvStructure));
119 }

Friends And Related Function Documentation

friend class detail::NTUnionBuilder
friend

Definition at line 276 of file ntunion.h.

Member Data Documentation

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

Definition at line 131 of file ntunion.h.


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