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

Interface for in-line creating of NTURI. More...

#include "nturi.h"

+ Inheritance diagram for epics::nt::detail::NTURIBuilder:
+ Collaboration diagram for epics::nt::detail::NTURIBuilder:

Public Member Functions

 POINTER_DEFINITIONS (NTURIBuilder)
 
shared_pointer addAuthority ()
 
shared_pointer addQueryString (std::string const &name)
 
shared_pointer addQueryDouble (std::string const &name)
 
shared_pointer addQueryInt (std::string const &name)
 
epics::pvData::StructureConstPtr createStructure ()
 
epics::pvData::PVStructurePtr createPVStructure ()
 
NTURIPtr create ()
 
shared_pointer add (std::string const &name, epics::pvData::FieldConstPtr const &field)
 

Friends

class ::epics::nt::NTURI
 

Detailed Description

Interface for in-line creating of NTURI.

One instance can be used to create multiple instances. An instance of this object must not be used concurrently (an object has a state).

Author
dgh

Definition at line 40 of file nturi.h.

Member Function Documentation

NTURIBuilder::shared_pointer epics::nt::detail::NTURIBuilder::add ( std::string const &  name,
epics::pvData::FieldConstPtr const &  field 
)

Adds extra Field to the type.

Parameters
namethe name of the field.
fieldthe field to be added.
Returns
this instance of NTURIBuilder.

Definition at line 119 of file nturi.cpp.

120 {
121  extraFields.push_back(field);
122  extraFieldNames.push_back(name);
123  return shared_from_this();
124 }
NTURIBuilder::shared_pointer epics::nt::detail::NTURIBuilder::addAuthority ( )

Adds authority field to the NTURI.

Returns
this instance of NTURIBuilder.

Definition at line 91 of file nturi.cpp.

92 {
93  authority = true;
94  return shared_from_this();
95 }
NTURIBuilder::shared_pointer epics::nt::detail::NTURIBuilder::addQueryDouble ( std::string const &  name)

Adds extra Scalar of ScalarType pvDouble to the query field of the type.

Parameters
namename of the field.
Returns
this instance of NTURIBuilder.

Definition at line 35 of file nturi.cpp.

36 {
37  if (std::find(queryFieldNames.begin(), queryFieldNames.end(), name) != queryFieldNames.end())
38  throw std::runtime_error("duplicate query field name");
39 
40  queryFieldNames.push_back(name);
41  queryTypes.push_back(pvDouble);
42 
43  return shared_from_this();
44 }
NTURIBuilder::shared_pointer epics::nt::detail::NTURIBuilder::addQueryInt ( std::string const &  name)

Adds extra Scalar of ScalarType pvInt to the query field of the type.

Parameters
namename of the field.
Returns
this instance of NTURIBuilder.

Definition at line 46 of file nturi.cpp.

47 {
48  if (std::find(queryFieldNames.begin(), queryFieldNames.end(), name) != queryFieldNames.end())
49  throw std::runtime_error("duplicate query field name");
50 
51  queryFieldNames.push_back(name);
52  queryTypes.push_back(pvInt);
53 
54  return shared_from_this();
55 }
NTURIBuilder::shared_pointer epics::nt::detail::NTURIBuilder::addQueryString ( std::string const &  name)

Adds extra Scalar of ScalarType pvString to the query field of the type.

Parameters
namename of the field.
Returns
this instance of NTURIBuilder.

Definition at line 24 of file nturi.cpp.

25 {
26  if (std::find(queryFieldNames.begin(), queryFieldNames.end(), name) != queryFieldNames.end())
27  throw std::runtime_error("duplicate query field name");
28 
29  queryFieldNames.push_back(name);
30  queryTypes.push_back(pvString);
31 
32  return shared_from_this();
33 }
NTURIPtr epics::nt::detail::NTURIBuilder::create ( )

Creates a NTURI instance. The returned NTURI will wrap a PVStructure which will have labels equal to the column names. This resets this instance state and allows new instance to be created.

Returns
a new instance of NTURI.

Definition at line 102 of file nturi.cpp.

103 {
104  return NTURIPtr(new NTURI(createPVStructure()));
105 }
std::tr1::shared_ptr< NTURI > NTURIPtr
Definition: nturi.h:28
epics::pvData::PVStructurePtr createPVStructure()
Definition: nturi.cpp:97
PVStructurePtr epics::nt::detail::NTURIBuilder::createPVStructure ( )

Creates a PVStructure that represents NTURI. The returned PVStructure will have labels equal to the column names. This resets this instance state and allows new instance to be created.

Returns
a new instance of PVStructure.

Definition at line 97 of file nturi.cpp.

98 {
99  return getPVDataCreate()->createPVStructure(createStructure());
100 }
epics::pvData::StructureConstPtr createStructure()
Definition: nturi.cpp:57
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
Definition: pvData.h:1648
StructureConstPtr epics::nt::detail::NTURIBuilder::createStructure ( )

Creates a Structure that represents NTURI. This resets this instance state and allows new instance to be created.

Returns
a new instance of Structure.

Definition at line 57 of file nturi.cpp.

58 {
59  FieldBuilderPtr builder = getFieldCreate()->
60  createFieldBuilder()->
61  setId(NTURI::URI)->
62  add("scheme", pvString);
63 
64  if (authority)
65  builder->add("authority", pvString);
66 
67  builder->add("path", pvString);
68 
69  if (!queryFieldNames.empty())
70  {
71  FieldBuilderPtr nestedBuilder = builder->
72  addNestedStructure("query");
73 
74  vector<string>::size_type len = queryFieldNames.size();
75  for (vector<string>::size_type i = 0; i < len; i++)
76  nestedBuilder->add(queryFieldNames[i], queryTypes[i]);
77 
78  builder = nestedBuilder->endNested();
79  }
80 
81  size_t extraCount = extraFieldNames.size();
82  for (size_t i = 0; i< extraCount; i++)
83  builder->add(extraFieldNames[i], extraFields[i]);
84 
85  StructureConstPtr s = builder->createStructure();
86 
87  reset();
88  return s;
89 }
static const std::string URI
Definition: nturi.h:141
int i
Definition: scan.c:967
std::tr1::shared_ptr< const Structure > StructureConstPtr
Definition: pvIntrospect.h:162
std::tr1::shared_ptr< FieldBuilder > FieldBuilderPtr
shared_pointer add(std::string const &name, epics::pvData::FieldConstPtr const &field)
Definition: nturi.cpp:119
FORCE_INLINE const FieldCreatePtr & getFieldCreate()
epics::nt::detail::NTURIBuilder::POINTER_DEFINITIONS ( NTURIBuilder  )

Friends And Related Function Documentation

friend class ::epics::nt::NTURI
friend

Definition at line 122 of file nturi.h.


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