ntnameValue: extra fields can be added now
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user