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

Convenience Class for NTEnum. More...

#include "ntenum.h"

Public Member Functions

 POINTER_DEFINITIONS (NTEnum)
 
bool isValid ()
 
 ~NTEnum ()
 
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::PVStructurePtr 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 NTEnumBuilderPtr createBuilder ()
 

Static Public Attributes

static const std::string URI
 

Friends

class detail::NTEnumBuilder
 

Detailed Description

Convenience Class for NTEnum.

Author
dgh

Definition at line 117 of file ntenum.h.

Constructor & Destructor Documentation

epics::nt::NTEnum::~NTEnum ( )
inline

Destructor.

Definition at line 216 of file ntenum.h.

216 {}

Member Function Documentation

bool epics::nt::NTEnum::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 166 of file ntenum.cpp.

167 {
168  PVStructurePtr al = getAlarm();
169  if (al)
170  return pvAlarm.attach(al);
171  else
172  return false;
173 }
epics::pvData::PVStructurePtr getAlarm() const
Definition: ntenum.cpp:190
bool attach(PVFieldPtr const &pvField)
Definition: pvAlarm.cpp:26
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool epics::nt::NTEnum::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 157 of file ntenum.cpp.

158 {
160  if (ts)
161  return pvTimeStamp.attach(ts);
162  else
163  return false;
164 }
epics::pvData::PVStructurePtr getTimeStamp() const
Definition: ntenum.cpp:185
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
bool attach(PVFieldPtr const &pvField)
Definition: pvTimeStamp.cpp:26
NTEnumBuilderPtr epics::nt::NTEnum::createBuilder ( )
static

Creates an NTEnum builder instance.

Returns
builder instance.

Definition at line 152 of file ntenum.cpp.

153 {
154  return NTEnumBuilderPtr(new detail::NTEnumBuilder());
155 }
std::tr1::shared_ptr< detail::NTEnumBuilder > NTEnumBuilderPtr
Definition: ntenum.h:108
PVStructurePtr epics::nt::NTEnum::getAlarm ( ) const

Returns the alarm field.

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

Definition at line 190 of file ntenum.cpp.

191 {
192  return pvNTEnum->getSubField<PVStructure>("alarm");
193 }
Data interface for a structure,.
Definition: pvData.h:712
PVStringPtr epics::nt::NTEnum::getDescriptor ( ) const

Returns the descriptor field.

Returns
the descriptor field or null if no such field.

Definition at line 180 of file ntenum.cpp.

181 {
182  return pvNTEnum->getSubField<PVString>("descriptor");
183 }
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
PVStructurePtr epics::nt::NTEnum::getPVStructure ( ) const

Returns the PVStructure wrapped by this instance.

Returns
the PVStructure wrapped by this instance.

Definition at line 175 of file ntenum.cpp.

176 {
177  return pvNTEnum;
178 }
PVStructurePtr epics::nt::NTEnum::getTimeStamp ( ) const

Returns the timeStamp field.

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

Definition at line 185 of file ntenum.cpp.

186 {
187  return pvNTEnum->getSubField<PVStructure>("timeStamp");
188 }
Data interface for a structure,.
Definition: pvData.h:712
PVStructurePtr epics::nt::NTEnum::getValue ( ) const

Get the value field.

Returns
the value field.

Definition at line 195 of file ntenum.cpp.

196 {
197  return pvValue;
198 }
bool epics::nt::NTEnum::is_a ( epics::pvData::StructureConstPtr const &  structure)
static

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

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

Definition at line 114 of file ntenum.cpp.

115 {
116  return NTUtils::is_a(structure->getID(), URI);
117 }
static const std::string URI
Definition: ntenum.h:122
static bool is_a(const std::string &u1, const std::string &u2)
Definition: ntutils.cpp:14
bool epics::nt::NTEnum::is_a ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Definition at line 119 of file ntenum.cpp.

120 {
121  return is_a(pvStructure->getStructure());
122 }
static bool is_a(epics::pvData::StructureConstPtr const &structure)
Definition: ntenum.cpp:114
bool epics::nt::NTEnum::isCompatible ( epics::pvData::StructureConstPtr const &  structure)
static

Returns whether the specified Structure is compatible with NTEnum.

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

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

Definition at line 124 of file ntenum.cpp.

125 {
126  if (!structure)
127  return false;
128 
129  Result result(structure);
130 
131  return result
132  .is<Structure>()
133  .has<&NTField::isEnumerated, Structure>("value")
134  .maybeHas<Scalar>("descriptor")
135  .maybeHas<&NTField::isAlarm, Structure>("alarm")
136  .maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
137  .valid();
138 }
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::NTEnum::isCompatible ( epics::pvData::PVStructurePtr const &  pvStructure)
static

Returns whether the specified PVStructure is compatible with NTEnum.

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

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

Definition at line 140 of file ntenum.cpp.

141 {
142  if(!pvStructure) return false;
143 
144  return isCompatible(pvStructure->getStructure());
145 }
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
Definition: ntenum.cpp:124
bool epics::nt::NTEnum::isValid ( )

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

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 NTEnum

Definition at line 147 of file ntenum.cpp.

148 {
149  return true;
150 }
epics::nt::NTEnum::POINTER_DEFINITIONS ( NTEnum  )
NTEnum::shared_pointer epics::nt::NTEnum::wrap ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Parameters
pvStructurethe PVStructure to be wrapped
Returns
NTEnum instance wrapping pvStructure

Definition at line 103 of file ntenum.cpp.

104 {
105  if(!isCompatible(pvStructure)) return shared_pointer();
106  return wrapUnsafe(pvStructure);
107 }
static bool isCompatible(epics::pvData::StructureConstPtr const &structure)
Definition: ntenum.cpp:124
static shared_pointer wrapUnsafe(epics::pvData::PVStructurePtr const &pvStructure)
Definition: ntenum.cpp:109
NTEnum::shared_pointer epics::nt::NTEnum::wrapUnsafe ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Parameters
pvStructurethe PVStructure to be wrapped
Returns
NTEnum instance wrapping pvStructure

Definition at line 109 of file ntenum.cpp.

110 {
111  return shared_pointer(new NTEnum(pvStructure));
112 }

Friends And Related Function Documentation

friend class detail::NTEnumBuilder
friend

Definition at line 269 of file ntenum.h.

Member Data Documentation

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

Definition at line 122 of file ntenum.h.


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