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

Convenience Class for NTURI. More...

#include "nturi.h"

Public Member Functions

 POINTER_DEFINITIONS (NTURI)
 
bool isValid ()
 
 ~NTURI ()
 
epics::pvData::PVStructurePtr getPVStructure () const
 
epics::pvData::PVStringPtr getScheme () const
 
epics::pvData::PVStringPtr getAuthority () const
 
epics::pvData::PVStringPtr getPath () const
 
epics::pvData::PVStructurePtr getQuery () const
 
epics::pvData::StringArray const & getQueryNames () const
 
epics::pvData::PVFieldPtr getQueryField (std::string const &name) const
 
template<typename PVT >
std::tr1::shared_ptr< PVT > getQueryField (std::string const &name) 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 NTURIBuilderPtr createBuilder ()
 

Static Public Attributes

static const std::string URI
 

Friends

class detail::NTURIBuilder
 

Detailed Description

Convenience Class for NTURI.

Author
dgh

Definition at line 136 of file nturi.h.

Constructor & Destructor Documentation

epics::nt::NTURI::~NTURI ( )
inline

Destructor.

Definition at line 236 of file nturi.h.

236 {}

Member Function Documentation

NTURIBuilderPtr epics::nt::NTURI::createBuilder ( )
static

Creates an NTURI builder instance.

Returns
builder instance.

Definition at line 193 of file nturi.cpp.

194 {
195  return NTURIBuilderPtr(new detail::NTURIBuilder());
196 }
std::tr1::shared_ptr< detail::NTURIBuilder > NTURIBuilderPtr
Definition: nturi.h:127
PVStringPtr epics::nt::NTURI::getAuthority ( ) const

Returns the authority field.

Returns
the authority field or null if no such field.

Definition at line 210 of file nturi.cpp.

211 {
212  return pvNTURI->getSubField<PVString>("authority");
213 }
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
PVStringPtr epics::nt::NTURI::getPath ( ) const

Returns the path field.

Returns
the path field.

Definition at line 215 of file nturi.cpp.

216 {
217  return pvNTURI->getSubField<PVString>("path");
218 }
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
PVStructurePtr epics::nt::NTURI::getPVStructure ( ) const

Returns the PVStructure wrapped by this instance.

Returns
the PVStructure wrapped by this instance.

Definition at line 199 of file nturi.cpp.

200 {
201  return pvNTURI;
202 }
PVStructurePtr epics::nt::NTURI::getQuery ( ) const

Returns the query field.

Returns
the query field or null if no such field.

Definition at line 220 of file nturi.cpp.

221 {
222  return pvNTURI->getSubField<PVStructure>("query");
223 }
Data interface for a structure,.
Definition: pvData.h:712
PVFieldPtr epics::nt::NTURI::getQueryField ( std::string const &  name) const

Returns the subfield of the query field with the specified name.

Parameters
namethe name of the subfield.
Returns
the the subfield of the query field or null if the field does not exist.

Definition at line 230 of file nturi.cpp.

231 {
232  return pvNTURI->getSubField("query." + name);
233 }
template<typename PVT >
std::tr1::shared_ptr<PVT> epics::nt::NTURI::getQueryField ( std::string const &  name) const
inline

Returns the subfield of the query field (parameter) with the specified name and of a specified expected type (for example, PVString).

Template Parameters
PVTthe expected type of the subfield which should be be PVString, PVInt pr PVDouble.
Parameters
namethe subfield of the query field or null if the field does not exist or is not of the expected type.
Returns
The PVT field.

Definition at line 293 of file nturi.h.

294  {
296  if (pvField.get())
297  return std::tr1::dynamic_pointer_cast<PVT>(pvField);
298  else
299  return std::tr1::shared_ptr<PVT>();
300  }
std::tr1::shared_ptr< PVField > PVFieldPtr
Definition: pvData.h:66
epics::pvData::PVFieldPtr getQueryField(std::string const &name) const
Definition: nturi.cpp:230
StringArray const & epics::nt::NTURI::getQueryNames ( ) const

Returns the names of the query fields for the URI. For each name, calling getQueryField should return the query field, which should not be null.

Returns
The query field names.

Definition at line 225 of file nturi.cpp.

226 {
227  return pvNTURI->getSubField<PVStructure>("query")->getStructure()->getFieldNames();
228 }
Data interface for a structure,.
Definition: pvData.h:712
PVStringPtr epics::nt::NTURI::getScheme ( ) const

Returns the scheme field.

Returns
the scheme field.

Definition at line 205 of file nturi.cpp.

206 {
207  return pvNTURI->getSubField<PVString>("scheme");
208 }
PVString is special case, since it implements SerializableArray.
Definition: pvData.h:521
bool epics::nt::NTURI::is_a ( epics::pvData::StructureConstPtr const &  structure)
static

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

Checks if the specified Structure reports compatibility with this version of NTScalar 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 (is not, is) a compatible NTScalar

Definition at line 141 of file nturi.cpp.

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

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

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

Definition at line 146 of file nturi.cpp.

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

Returns whether the specified Structure is compatible with NTURI.

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

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

Definition at line 151 of file nturi.cpp.

152 {
153  if (!structure)
154  return false;
155 
156  Result result(structure);
157 
158  result
159  .is<Structure>()
160  .has<Scalar>("scheme")
161  .has<Scalar>("path")
162  .maybeHas<Scalar>("authority")
163  .maybeHas<Structure>("query");
164 
165  StructureConstPtr query(structure->getField<Structure>("query"));
166  if (query) {
167  Result r(query);
168  StringArray const & names(query->getFieldNames());
169  StringArray::const_iterator it;
170 
171  for (it = names.begin(); it != names.end(); ++it)
172  r.has<ScalarArray>(*it);
173 
174  result |= r;
175  }
176 
177  return result.valid();
178 }
This class implements introspection object for Scalar.
Definition: pvIntrospect.h:397
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
This class implements introspection object for scalar array.
Definition: pvIntrospect.h:497
std::vector< std::string > StringArray
Definition: pvType.h:110
bool epics::nt::NTURI::isCompatible ( epics::pvData::PVStructurePtr const &  pvStructure)
static

Returns whether the specified PVStructure is compatible with NTURI.

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

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

Definition at line 181 of file nturi.cpp.

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

Returns whether the wrapped PVStructure is a valid NTURI.

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 NTURI.

Definition at line 188 of file nturi.cpp.

189 {
190  return true;
191 }
epics::nt::NTURI::POINTER_DEFINITIONS ( NTURI  )
NTURI::shared_pointer epics::nt::NTURI::wrap ( epics::pvData::PVStructurePtr const &  pvStructure)
static

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

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

Definition at line 130 of file nturi.cpp.

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

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

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

Parameters
pvStructurethe PVStructure to be wrapped
Returns
NTScalar instance wrapping pvStructure

Definition at line 136 of file nturi.cpp.

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

Friends And Related Function Documentation

friend class detail::NTURIBuilder
friend

Definition at line 305 of file nturi.h.

Member Data Documentation

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

Definition at line 141 of file nturi.h.


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