Validator: use it in all remaining normative types
This commit is contained in:

committed by
mdavidsaver

parent
e2d95128a3
commit
452f2379a1
@ -4,6 +4,8 @@
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntaggregate.h>
|
||||
#include <pv/ntutils.h>
|
||||
@ -194,83 +196,26 @@ bool NTAggregate::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTAggregate::isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarConstPtr valueField = structure->getField<Scalar>("value");
|
||||
if (valueField.get() == 0 || valueField->getScalarType() != pvDouble)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
ScalarConstPtr nField = structure->getField<Scalar>("N");
|
||||
if (nField.get() == 0 || nField->getScalarType() != pvLong)
|
||||
return false;
|
||||
Result result(structure);
|
||||
|
||||
FieldConstPtr field = structure->getField("dispersion");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr dispersionField = structure->getField<Scalar>("dispersion");
|
||||
if (!dispersionField.get() || dispersionField->getScalarType() != pvDouble)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("first");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr firstField = structure->getField<Scalar>("first");
|
||||
if (!firstField.get() || firstField->getScalarType() != pvDouble)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("firstTimeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("last");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr lastField = structure->getField<Scalar>("last");
|
||||
if (!lastField.get() || lastField->getScalarType() != pvDouble)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("lastTimeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("max");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr maxField = structure->getField<Scalar>("max");
|
||||
if (!maxField.get() || maxField->getScalarType() != pvDouble)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("min");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr minField = structure->getField<Scalar>("min");
|
||||
if (!minField.get() || minField->getScalarType() != pvDouble)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<Scalar>("value")
|
||||
.has<Scalar>("N")
|
||||
.maybeHas<Scalar>("dispersion")
|
||||
.maybeHas<Scalar>("first")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("firstTimeStamp")
|
||||
.maybeHas<Scalar>("last")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("lastTimeStamp")
|
||||
.maybeHas<Scalar>("max")
|
||||
.maybeHas<Scalar>("min")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTAggregate::isCompatible(PVStructurePtr const & pvStructure)
|
||||
|
@ -4,6 +4,8 @@
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntcontinuum.h>
|
||||
#include <pv/ntutils.h>
|
||||
@ -122,42 +124,22 @@ bool NTContinuum::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTContinuum::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarArrayConstPtr baseField = structure->getField<ScalarArray>("base");
|
||||
if (baseField.get() == 0 || baseField->getElementType() != pvDouble)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
|
||||
if (valueField.get() == 0 || valueField->getElementType() != pvDouble)
|
||||
return false;
|
||||
Result result(structure);
|
||||
|
||||
ScalarArrayConstPtr unitsField = structure->getField<ScalarArray>("units");
|
||||
if (unitsField.get() == 0 || unitsField->getElementType() != pvString)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<ScalarArray>("base")
|
||||
.has<ScalarArray>("value")
|
||||
.has<ScalarArray>("units")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
|
||||
bool NTContinuum::isCompatible(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!pvStructure) return false;
|
||||
|
@ -4,6 +4,8 @@
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntenum.h>
|
||||
#include <pv/ntutils.h>
|
||||
@ -121,34 +123,20 @@ bool NTEnum::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTEnum::isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
FieldConstPtr valueField = structure->getField("value");
|
||||
if (!valueField.get() || !ntField->isEnumerated(valueField))
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
Result result(structure);
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<&NTField::isEnumerated, Structure>("value")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
|
||||
bool NTEnum::isCompatible(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!pvStructure) return false;
|
||||
|
@ -4,6 +4,8 @@
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/nthistogram.h>
|
||||
#include <pv/ntutils.h>
|
||||
@ -135,37 +137,19 @@ bool NTHistogram::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTHistogram::isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if(!structure.get()) return false;
|
||||
|
||||
ScalarArrayConstPtr rangesField = structure->getField<ScalarArray>("ranges");
|
||||
if(!rangesField.get() || rangesField->getElementType() != pvDouble) return false;
|
||||
|
||||
ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
|
||||
if(!valueField.get()) return false;
|
||||
|
||||
ScalarType scalarType = valueField->getElementType();
|
||||
if (scalarType != pvShort &&
|
||||
scalarType != pvInt &&
|
||||
scalarType != pvLong)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if(field)
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
Result result(structure);
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<ScalarArray>("ranges")
|
||||
.has<ScalarArray>("value")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTHistogram::isCompatible(PVStructurePtr const & pvStructure)
|
||||
|
@ -4,6 +4,8 @@
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntmatrix.h>
|
||||
#include <pv/ntutils.h>
|
||||
@ -139,43 +141,20 @@ bool NTMatrix::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTMatrix::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
|
||||
if (valueField.get() == 0 || valueField->getElementType() != pvDouble)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("dim");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr dimField = structure->getField<ScalarArray>("dim");
|
||||
if (dimField.get() == 0 || dimField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
Result result(structure);
|
||||
|
||||
field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("display");
|
||||
if (field.get() && !ntField->isDisplay(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<ScalarArray>("value")
|
||||
.maybeHas<ScalarArray>("dim")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.maybeHas<&NTField::isDisplay, Structure>("display")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTMatrix::isCompatible(PVStructurePtr const & pvStructure)
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntmultiChannel.h>
|
||||
#include <pv/ntutils.h>
|
||||
@ -232,86 +234,27 @@ bool NTMultiChannel::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTMultiChannel::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (!structure.get()) return false;
|
||||
|
||||
UnionArrayConstPtr valueField = structure->getField<UnionArray>("value");
|
||||
if (!valueField.get()) return false;
|
||||
|
||||
ScalarArrayConstPtr channelNameField = structure->getField<ScalarArray>(
|
||||
"channelName");
|
||||
if (!channelNameField.get()) return false;
|
||||
if (channelNameField->getElementType() != pvString) return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("severity");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr severityField = structure->getField<ScalarArray>("severity");
|
||||
if (!severityField.get() || severityField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("status");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr statusField = structure->getField<ScalarArray>("status");
|
||||
if (!statusField.get() || statusField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("message");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr messageField = structure->getField<ScalarArray>("message");
|
||||
if (!messageField.get() || messageField->getElementType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("secondsPastEpoch");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr secondsPastEpochField = structure->getField<ScalarArray>("secondsPastEpoch");
|
||||
if (!secondsPastEpochField.get() || secondsPastEpochField->getElementType() != pvLong)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("nanoseconds");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr nanosecondsField = structure->getField<ScalarArray>("nanoseconds");
|
||||
if (!nanosecondsField.get() || nanosecondsField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("userTag");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr userTagField = structure->getField<ScalarArray>("userTag");
|
||||
if (!userTagField.get() || userTagField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
Result result(structure);
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<UnionArray>("value")
|
||||
.has<ScalarArray>("channelName")
|
||||
.maybeHas<ScalarArray>("severity")
|
||||
.maybeHas<ScalarArray>("status")
|
||||
.maybeHas<ScalarArray>("message")
|
||||
.maybeHas<ScalarArray>("secondsPastEpoch")
|
||||
.maybeHas<ScalarArray>("nanoseconds")
|
||||
.maybeHas<ScalarArray>("userTag")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
|
||||
bool NTMultiChannel::isCompatible(PVStructurePtr const &pvStructure)
|
||||
{
|
||||
if(!pvStructure.get()) return false;
|
||||
|
@ -4,6 +4,8 @@
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntnameValue.h>
|
||||
#include <pv/ntutils.h>
|
||||
@ -134,35 +136,19 @@ bool NTNameValue::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTNameValue::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarArrayConstPtr nameField = structure->getField<ScalarArray>("name");
|
||||
if (nameField.get() == 0 || nameField->getElementType() != pvString)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
|
||||
if (valueField.get() == 0)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
Result result(structure);
|
||||
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<ScalarArray>("name")
|
||||
.has<ScalarArray>("value")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTNameValue::isCompatible(PVStructurePtr const & pvStructure)
|
||||
|
@ -4,6 +4,8 @@
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntscalar.h>
|
||||
#include <pv/ntutils.h>
|
||||
@ -152,42 +154,22 @@ bool NTScalar::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTScalar::isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarConstPtr valueField = structure->getField<Scalar>("value");
|
||||
if (valueField.get() == 0)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
Result result(structure);
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("display");
|
||||
if (field.get() && !ntField->isDisplay(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("control");
|
||||
if (field.get() && !ntField->isControl(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<Scalar>("value")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.maybeHas<&NTField::isDisplay, Structure>("display")
|
||||
.maybeHas<&NTField::isControl, Structure>("control")
|
||||
.valid();
|
||||
}
|
||||
|
||||
|
||||
bool NTScalar::isCompatible(PVStructurePtr const & pvStructure)
|
||||
{
|
||||
if(!pvStructure) return false;
|
||||
|
@ -4,6 +4,8 @@
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntscalarArray.h>
|
||||
#include <pv/ntutils.h>
|
||||
@ -161,39 +163,20 @@ bool NTScalarArray::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTScalarArray::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
|
||||
if (valueField.get() == 0)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
Result result(structure);
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("display");
|
||||
if (field.get() && !ntField->isDisplay(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("control");
|
||||
if (field.get() && !ntField->isControl(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<ScalarArray>("value")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.maybeHas<&NTField::isDisplay, Structure>("display")
|
||||
.maybeHas<&NTField::isControl, Structure>("control")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTScalarArray::isCompatible(PVStructurePtr const & pvStructure)
|
||||
|
@ -4,6 +4,7 @@
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
#include <algorithm>
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntscalarMultiChannel.h>
|
||||
@ -228,86 +229,27 @@ bool NTScalarMultiChannel::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTScalarMultiChannel::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (!structure.get()) return false;
|
||||
|
||||
ScalarArrayConstPtr valueField = structure->getField<ScalarArray>("value");
|
||||
if (!valueField.get()) return false;
|
||||
|
||||
ScalarArrayConstPtr channelNameField = structure->getField<ScalarArray>(
|
||||
"channelName");
|
||||
if (!channelNameField.get()) return false;
|
||||
if (channelNameField->getElementType() != pvString) return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("severity");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr severityField = structure->getField<ScalarArray>("severity");
|
||||
if (!severityField.get() || severityField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("status");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr statusField = structure->getField<ScalarArray>("status");
|
||||
if (!statusField.get() || statusField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("message");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr messageField = structure->getField<ScalarArray>("message");
|
||||
if (!messageField.get() || messageField->getElementType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("secondsPastEpoch");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr secondsPastEpochField = structure->getField<ScalarArray>("secondsPastEpoch");
|
||||
if (!secondsPastEpochField.get() || secondsPastEpochField->getElementType() != pvLong)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("nanoseconds");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr nanosecondsField = structure->getField<ScalarArray>("nanoseconds");
|
||||
if (!nanosecondsField.get() || nanosecondsField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("userTag");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarArrayConstPtr userTagField = structure->getField<ScalarArray>("userTag");
|
||||
if (!userTagField.get() || userTagField->getElementType() != pvInt)
|
||||
return false;
|
||||
}
|
||||
|
||||
field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
Result result(structure);
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<ScalarArray>("value")
|
||||
.has<ScalarArray>("channelName")
|
||||
.maybeHas<ScalarArray>("severity")
|
||||
.maybeHas<ScalarArray>("status")
|
||||
.maybeHas<ScalarArray>("message")
|
||||
.maybeHas<ScalarArray>("secondsPastEpoch")
|
||||
.maybeHas<ScalarArray>("nanoseconds")
|
||||
.maybeHas<ScalarArray>("userTag")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
|
||||
bool NTScalarMultiChannel::isCompatible(PVStructurePtr const &pvStructure)
|
||||
{
|
||||
if(!pvStructure.get()) return false;
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/nttable.h>
|
||||
@ -149,42 +150,32 @@ bool NTTable::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTTable::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (!structure.get()) return false;
|
||||
|
||||
StructureConstPtr valueField = structure->getField<Structure>("value");
|
||||
if (!valueField.get())
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
FieldConstPtrArray const & fields = valueField->getFields();
|
||||
for (FieldConstPtrArray::const_iterator it = fields.begin();
|
||||
it != fields.end(); ++it)
|
||||
{
|
||||
if ((*it)->getType() != scalarArray) return false;
|
||||
Result result(structure);
|
||||
|
||||
result
|
||||
.is<Structure>()
|
||||
.has<Structure>("value")
|
||||
.has<ScalarArray>("labels")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp");
|
||||
|
||||
StructureConstPtr value(structure->getField<Structure>("value"));
|
||||
if (value) {
|
||||
Result r(value);
|
||||
StringArray const & names(value->getFieldNames());
|
||||
StringArray::const_iterator it;
|
||||
|
||||
for (it = names.begin(); it != names.end(); ++it)
|
||||
r.has<ScalarArray>(*it);
|
||||
|
||||
result |= r;
|
||||
}
|
||||
|
||||
ScalarArrayConstPtr labelsField = structure->getField<ScalarArray>("labels");
|
||||
if (!labelsField.get() || labelsField->getElementType() != pvString)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result.valid();
|
||||
}
|
||||
|
||||
bool NTTable::isCompatible(PVStructurePtr const & pvStructure)
|
||||
|
@ -4,6 +4,8 @@
|
||||
* found in the file LICENSE that is included with the distribution
|
||||
*/
|
||||
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/ntunion.h>
|
||||
#include <pv/ntutils.h>
|
||||
@ -128,31 +130,18 @@ bool NTUnion::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTUnion::isCompatible(StructureConstPtr const &structure)
|
||||
{
|
||||
if (structure.get() == 0) return false;
|
||||
|
||||
UnionConstPtr valueField = structure->getField<Union>("value");
|
||||
if (valueField.get() == 0)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
FieldConstPtr field = structure->getField("descriptor");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr descriptorField = structure->getField<Scalar>("descriptor");
|
||||
if (!descriptorField.get() || descriptorField->getScalarType() != pvString)
|
||||
return false;
|
||||
}
|
||||
Result result(structure);
|
||||
|
||||
NTFieldPtr ntField = NTField::get();
|
||||
|
||||
field = structure->getField("alarm");
|
||||
if (field.get() && !ntField->isAlarm(field))
|
||||
return false;
|
||||
|
||||
field = structure->getField("timeStamp");
|
||||
if (field.get() && !ntField->isTimeStamp(field))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return result
|
||||
.is<Structure>()
|
||||
.has<Union>("value")
|
||||
.maybeHas<Scalar>("descriptor")
|
||||
.maybeHas<&NTField::isAlarm, Structure>("alarm")
|
||||
.maybeHas<&NTField::isTimeStamp, Structure>("timeStamp")
|
||||
.valid();
|
||||
}
|
||||
|
||||
bool NTUnion::isCompatible(PVStructurePtr const & pvStructure)
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "validator.h"
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include <pv/nturi.h>
|
||||
@ -149,45 +150,31 @@ bool NTURI::is_a(PVStructurePtr const & pvStructure)
|
||||
|
||||
bool NTURI::isCompatible(StructureConstPtr const & structure)
|
||||
{
|
||||
if (!structure.get()) return false;
|
||||
|
||||
ScalarConstPtr schemeField = structure->getField<Scalar>("scheme");
|
||||
if (schemeField.get() == 0 || schemeField->getScalarType() != pvString)
|
||||
if (!structure)
|
||||
return false;
|
||||
|
||||
ScalarConstPtr pathField = structure->getField<Scalar>("path");
|
||||
if (pathField.get() == 0 || pathField->getScalarType() != pvString)
|
||||
return false;
|
||||
Result result(structure);
|
||||
|
||||
FieldConstPtr field = structure->getField("authority");
|
||||
if (field.get())
|
||||
{
|
||||
ScalarConstPtr authorityField = structure->getField<Scalar>("authority");
|
||||
if (!authorityField.get() || authorityField->getScalarType() != pvString)
|
||||
return false;
|
||||
result
|
||||
.is<Structure>()
|
||||
.has<Scalar>("scheme")
|
||||
.has<Scalar>("path")
|
||||
.maybeHas<Scalar>("authority")
|
||||
.maybeHas<Structure>("query");
|
||||
|
||||
StructureConstPtr query(structure->getField<Structure>("query"));
|
||||
if (query) {
|
||||
Result r(query);
|
||||
StringArray const & names(query->getFieldNames());
|
||||
StringArray::const_iterator it;
|
||||
|
||||
for (it = names.begin(); it != names.end(); ++it)
|
||||
r.has<ScalarArray>(*it);
|
||||
|
||||
result |= r;
|
||||
}
|
||||
|
||||
field = structure->getField("query");
|
||||
if (field.get())
|
||||
{
|
||||
StructureConstPtr queryField = structure->getField<Structure>("query");
|
||||
if (!queryField.get())
|
||||
return false;
|
||||
|
||||
FieldConstPtrArray const & fields = queryField->getFields();
|
||||
for (FieldConstPtrArray::const_iterator it = fields.begin();
|
||||
it != fields.end(); ++it)
|
||||
{
|
||||
if ((*it)->getType() != scalar) return false;
|
||||
ScalarType scalarType = std::tr1::dynamic_pointer_cast<const Scalar>(
|
||||
(*it))->getScalarType();
|
||||
if (scalarType != pvString &&
|
||||
scalarType != pvInt &&
|
||||
scalarType != pvDouble) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return result.valid();
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,9 +160,21 @@ private:
|
||||
static Result& isAlarmLimit(Result&);
|
||||
static Result& isControl(Result&);
|
||||
|
||||
friend class NTAggregate;
|
||||
friend class NTAttribute;
|
||||
friend class NTContinuum;
|
||||
friend class NTEnum;
|
||||
friend class NTHistogram;
|
||||
friend class NTMatrix;
|
||||
friend class NTMultiChannel;
|
||||
friend class NTNameValue;
|
||||
friend class NTNDArray;
|
||||
friend class NTNDArrayAttribute;
|
||||
friend class NTScalar;
|
||||
friend class NTScalarArray;
|
||||
friend class NTScalarMultiChannel;
|
||||
friend class NTTable;
|
||||
friend class NTUnion;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user