ntnameValue: extra fields can be added now

This commit is contained in:
Matej Sekoranja
2014-09-04 12:30:02 +02:00
parent 89396a7455
commit 63eb1aa703
3 changed files with 58 additions and 1 deletions
+13
View File
@@ -46,6 +46,10 @@ StructureConstPtr NTNameValueBuilder::createStructure()
if (timeStamp)
builder->add("timeStamp", ntField->createTimeStamp());
size_t extraCount = extraFieldNames.size();
for (size_t i = 0; i< extraCount; i++)
builder->add(extraFieldNames[i], extraFields[i]);
StructureConstPtr s = builder->createStructure();
reset();
@@ -91,8 +95,17 @@ void NTNameValueBuilder::reset()
descriptor = false;
alarm = false;
timeStamp = false;
extraFieldNames.clear();
extraFields.clear();
}
NTNameValueBuilder::shared_pointer NTNameValueBuilder::add(string const & name, FieldConstPtr const & field)
{
extraFields.push_back(field); extraFieldNames.push_back(name);
return shared_from_this();
}
}
const std::string NTNameValue::URI("uri:ev4:nt/2012/pwd:NTNameValue");
+12
View File
@@ -74,6 +74,14 @@ namespace detail {
*/
NTNameValuePtr create();
/**
* Add extra {@code Field} to the type.
* @param name name of the field.
* @param field a field to add.
* @return this instance of a {@code NTNameValueBuilder}.
*/
shared_pointer add(std::string const & name, epics::pvData::FieldConstPtr const & field);
private:
NTNameValueBuilder();
@@ -86,6 +94,10 @@ namespace detail {
bool alarm;
bool timeStamp;
// NOTE: this preserves order, however it does not handle duplicates
epics::pvData::StringArray extraFieldNames;
epics::pvData::FieldConstPtrArray extraFields;
friend class ::epics::nt::NTNameValue;
};