diff --git a/src/nt/nttable.cpp b/src/nt/nttable.cpp index 8cc46bd..61368f0 100644 --- a/src/nt/nttable.cpp +++ b/src/nt/nttable.cpp @@ -24,10 +24,10 @@ NTTableBuilder::shared_pointer NTTableBuilder::add( std::string const & name, epics::pvData::ScalarType scalarType ) { - if (std::find(labels.begin(), labels.end(), name) != labels.end()) + if (std::find(columnNames.begin(), columnNames.end(), name) != columnNames.end()) throw std::runtime_error("duplicate column name"); - labels.push_back(name); + columnNames.push_back(name); types.push_back(scalarType); return shared_from_this(); @@ -43,9 +43,9 @@ StructureConstPtr NTTableBuilder::createStructure() addArray("labels", pvString)-> addNestedStructure("value"); - vector::size_type len = labels.size(); + vector::size_type len = columnNames.size(); for (vector::size_type i = 0; i < len; i++) - nestedBuilder->addArray(labels[i], types[i]); + nestedBuilder->addArray(columnNames[i], types[i]); builder = nestedBuilder->endNested(); @@ -88,10 +88,12 @@ NTTableBuilder::shared_pointer NTTableBuilder::addTimeStamp() PVStructurePtr NTTableBuilder::createPVStructure() { - size_t len = labels.size(); - shared_vector l(len); - for(size_t i=0; icreatePVStructure(createStructure()); + + // fill in labels with default values (the column names) + size_t len = columnNames.size(); + shared_vector l(len); + for(size_t i=0; igetSubField("labels")->replace(freeze(l)); return s; } @@ -108,7 +110,7 @@ NTTableBuilder::NTTableBuilder() void NTTableBuilder::reset() { - labels.clear(); + columnNames.clear(); types.clear(); descriptor = false; alarm = false; diff --git a/src/nt/nttable.h b/src/nt/nttable.h index 38a427a..857ad94 100644 --- a/src/nt/nttable.h +++ b/src/nt/nttable.h @@ -82,6 +82,7 @@ namespace detail { /** * Create 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. * @return a new instance of PVStructure. */ @@ -89,6 +90,8 @@ namespace detail { /** * Create 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. * @return a new instance of NTTable. */ @@ -106,7 +109,7 @@ namespace detail { void reset(); - std::vector labels; + std::vector columnNames; std::vector types; bool descriptor; @@ -192,7 +195,7 @@ public: * Attach an pvAlarm. * @param pvAlarm The pvAlarm that will be attached. * Does nothing if no alarm. - * @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false. + * @return true if the operation was successfull (i.e. this instance has a timeStamp field), otherwise false. */ bool attachAlarm(epics::pvData::PVAlarm &pvAlarm) const;