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

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

#include "nttable.h"

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

Public Member Functions

 POINTER_DEFINITIONS (NTTableBuilder)
 
shared_pointer addColumn (std::string const &name, epics::pvData::ScalarType elementType)
 
shared_pointer addDescriptor ()
 
shared_pointer addAlarm ()
 
shared_pointer addTimeStamp ()
 
epics::pvData::StructureConstPtr createStructure ()
 
epics::pvData::PVStructurePtr createPVStructure ()
 
NTTablePtr create ()
 
shared_pointer add (std::string const &name, epics::pvData::FieldConstPtr const &field)
 

Friends

class ::epics::nt::NTTable
 

Detailed Description

Interface for in-line creating of NTTable.

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
mse

Definition at line 43 of file nttable.h.

Member Function Documentation

NTTableBuilder::shared_pointer epics::nt::detail::NTTableBuilder::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 NTTableBuilder.

Definition at line 119 of file nttable.cpp.

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

Adds alarm field to the NTTable.

Returns
this instance of NTTableBuilder.

Definition at line 77 of file nttable.cpp.

78 {
79  alarm = true;
80  return shared_from_this();
81 }
NTTableBuilder::shared_pointer epics::nt::detail::NTTableBuilder::addColumn ( std::string const &  name,
epics::pvData::ScalarType  elementType 
)

Adds a column of given Scalar type.

Parameters
namename of the column.
elementTypecolumn type, a scalar array.
Returns
this instance of NTTableBuilder.

Definition at line 23 of file nttable.cpp.

26 {
27  if (std::find(columnNames.begin(), columnNames.end(), name) != columnNames.end())
28  throw std::runtime_error("duplicate column name");
29 
30  columnNames.push_back(name);
31  types.push_back(scalarType);
32 
33  return shared_from_this();
34 }
NTTableBuilder::shared_pointer epics::nt::detail::NTTableBuilder::addDescriptor ( )

Adds descriptor field to the NTTable.

Returns
this instance of NTTableBuilder.

Definition at line 71 of file nttable.cpp.

72 {
73  descriptor = true;
74  return shared_from_this();
75 }
NTTableBuilder::shared_pointer epics::nt::detail::NTTableBuilder::addTimeStamp ( )

Adds timeStamp field to the NTTable.

Returns
this instance of NTTableBuilder.

Definition at line 83 of file nttable.cpp.

84 {
85  timeStamp = true;
86  return shared_from_this();
87 }
NTTablePtr epics::nt::detail::NTTableBuilder::create ( )

Creates a NTTable instance. The returned NTTable 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 NTTable.

Definition at line 100 of file nttable.cpp.

101 {
102  return NTTablePtr(new NTTable(createPVStructure()));
103 }
std::tr1::shared_ptr< NTTable > NTTablePtr
Definition: nttable.h:31
epics::pvData::PVStructurePtr createPVStructure()
Definition: nttable.cpp:89
PVStructurePtr epics::nt::detail::NTTableBuilder::createPVStructure ( )

Creates a PVStructure that represents NTTable. 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 89 of file nttable.cpp.

90 {
91  // fill in labels with default values (the column names)
92  size_t len = columnNames.size();
93  shared_vector<string> l(len);
94  for(size_t i=0; i<len; ++i) l[i] = columnNames[i];
95  PVStructurePtr s = getPVDataCreate()->createPVStructure(createStructure());
96  s->getSubField<PVStringArray>("labels")->replace(freeze(l));
97  return s;
98 }
A holder for a contiguous piece of memory.
Definition: sharedVector.h:27
int i
Definition: scan.c:967
template class for all extensions of PVArray.
Definition: pvData.h:55
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
epics::pvData::StructureConstPtr createStructure()
Definition: nttable.cpp:36
FORCE_INLINE const PVDataCreatePtr & getPVDataCreate()
Definition: pvData.h:1648
StructureConstPtr epics::nt::detail::NTTableBuilder::createStructure ( )

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

Returns
a new instance of Structure.

Definition at line 36 of file nttable.cpp.

37 {
38  FieldBuilderPtr builder = getFieldCreate()->createFieldBuilder();
39 
40  FieldBuilderPtr nestedBuilder =
41  builder->
42  setId(NTTable::URI)->
43  addArray("labels", pvString)->
44  addNestedStructure("value");
45 
46  vector<string>::size_type len = columnNames.size();
47  for (vector<string>::size_type i = 0; i < len; i++)
48  nestedBuilder->addArray(columnNames[i], types[i]);
49 
50  builder = nestedBuilder->endNested();
51 
52  if (descriptor)
53  builder->add("descriptor", pvString);
54 
55  if (alarm)
56  builder->add("alarm", ntField->createAlarm());
57 
58  if (timeStamp)
59  builder->add("timeStamp", ntField->createTimeStamp());
60 
61  size_t extraCount = extraFieldNames.size();
62  for (size_t i = 0; i< extraCount; i++)
63  builder->add(extraFieldNames[i], extraFields[i]);
64 
65  StructureConstPtr s = builder->createStructure();
66 
67  reset();
68  return s;
69 }
int i
Definition: scan.c:967
std::tr1::shared_ptr< const Structure > StructureConstPtr
Definition: pvIntrospect.h:162
std::tr1::shared_ptr< FieldBuilder > FieldBuilderPtr
static const std::string URI
Definition: nttable.h:142
FORCE_INLINE const FieldCreatePtr & getFieldCreate()
epics::nt::detail::NTTableBuilder::POINTER_DEFINITIONS ( NTTableBuilder  )

Friends And Related Function Documentation

friend class ::epics::nt::NTTable
friend

Definition at line 123 of file nttable.h.


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