diff --git a/src/nt/ntaggregate.cpp b/src/nt/ntaggregate.cpp index 071c7be..d4879a0 100644 --- a/src/nt/ntaggregate.cpp +++ b/src/nt/ntaggregate.cpp @@ -278,6 +278,11 @@ bool NTAggregate::isCompatible(PVStructurePtr const & pvStructure) return isCompatible(pvStructure->getStructure()); } +bool NTAggregate::isValid() +{ + return true; +} + NTAggregateBuilderPtr NTAggregate::createBuilder() { return NTAggregateBuilderPtr(new detail::NTAggregateBuilder()); diff --git a/src/nt/ntattribute.cpp b/src/nt/ntattribute.cpp index ae0c418..d8cfa49 100644 --- a/src/nt/ntattribute.cpp +++ b/src/nt/ntattribute.cpp @@ -175,6 +175,11 @@ bool NTAttribute::isCompatible(PVStructurePtr const & pvStructure) return isCompatible(pvStructure->getStructure()); } +bool NTAttribute::isValid() +{ + return true; +} + NTAttributeBuilderPtr NTAttribute::createBuilder() { return NTAttributeBuilderPtr(new detail::NTAttributeBuilder()); diff --git a/src/nt/ntcontinuum.cpp b/src/nt/ntcontinuum.cpp index 34817d5..5eb2866 100644 --- a/src/nt/ntcontinuum.cpp +++ b/src/nt/ntcontinuum.cpp @@ -161,6 +161,11 @@ bool NTContinuum::isCompatible(PVStructurePtr const & pvStructure) return isCompatible(pvStructure->getStructure()); } +bool NTContinuum::isValid() +{ + return ((getUnits()->getLength()-1)*getBase()->getLength() == + getValue()->getLength()); +} NTContinuumBuilderPtr NTContinuum::createBuilder() { diff --git a/src/nt/ntenum.cpp b/src/nt/ntenum.cpp index b99a028..2ee0d44 100644 --- a/src/nt/ntenum.cpp +++ b/src/nt/ntenum.cpp @@ -154,6 +154,11 @@ bool NTEnum::isCompatible(PVStructurePtr const & pvStructure) return isCompatible(pvStructure->getStructure()); } +bool NTEnum::isValid() +{ + return true; +} + NTEnumBuilderPtr NTEnum::createBuilder() { return NTEnumBuilderPtr(new detail::NTEnumBuilder()); diff --git a/src/nt/nthistogram.cpp b/src/nt/nthistogram.cpp index 303e63c..08ca949 100644 --- a/src/nt/nthistogram.cpp +++ b/src/nt/nthistogram.cpp @@ -171,6 +171,10 @@ bool NTHistogram::isCompatible(PVStructurePtr const & pvStructure) return isCompatible(pvStructure->getStructure()); } +bool NTHistogram::isValid() +{ + return (getValue()->getLength()+1 == getRanges()->getLength()); +} NTHistogramBuilderPtr NTHistogram::createBuilder() { diff --git a/src/nt/ntmatrix.cpp b/src/nt/ntmatrix.cpp index 3470d5b..a809946 100644 --- a/src/nt/ntmatrix.cpp +++ b/src/nt/ntmatrix.cpp @@ -181,6 +181,31 @@ bool NTMatrix::isCompatible(PVStructurePtr const & pvStructure) return isCompatible(pvStructure->getStructure()); } +bool NTMatrix::isValid() +{ + int valueLength = getValue()->getLength(); + if (valueLength == 0) + return false; + + PVIntArrayPtr pvDim = getDim(); + if (pvDim.get()) + { + int length = pvDim->getLength(); + if (length != 1 && length !=2) + return false; + + PVIntArray::const_svector data = pvDim->view(); + int expectedLength = 1; + for (PVIntArray::const_svector::const_iterator it = data.begin(); + it != data.end(); ++it) + { + expectedLength *= *it; + } + if (expectedLength != valueLength) + return false; + } + return true; +} NTMatrixBuilderPtr NTMatrix::createBuilder() { diff --git a/src/nt/ntnameValue.cpp b/src/nt/ntnameValue.cpp index 7a6590d..4128768 100644 --- a/src/nt/ntnameValue.cpp +++ b/src/nt/ntnameValue.cpp @@ -168,6 +168,11 @@ bool NTNameValue::isCompatible(PVStructurePtr const & pvStructure) return isCompatible(pvStructure->getStructure()); } +bool NTNameValue::isValid() +{ + return (getValue()->getLength() == getName()->getLength()); +} + NTNameValueBuilderPtr NTNameValue::createBuilder() { return NTNameValueBuilderPtr(new detail::NTNameValueBuilder()); diff --git a/src/nt/ntndarrayAttribute.cpp b/src/nt/ntndarrayAttribute.cpp index 60dcd2e..44e647e 100644 --- a/src/nt/ntndarrayAttribute.cpp +++ b/src/nt/ntndarrayAttribute.cpp @@ -158,6 +158,11 @@ bool NTNDArrayAttribute::isCompatible(PVStructurePtr const & pvStructure) return isCompatible(pvStructure->getStructure()); } +bool NTNDArrayAttribute::isValid() +{ + return true; +} + NTNDArrayAttributeBuilderPtr NTNDArrayAttribute::createBuilder() { return NTNDArrayAttributeBuilderPtr(new detail::NTNDArrayAttributeBuilder()); diff --git a/src/nt/ntscalar.cpp b/src/nt/ntscalar.cpp index e9d64ca..e51af6c 100644 --- a/src/nt/ntscalar.cpp +++ b/src/nt/ntscalar.cpp @@ -193,6 +193,11 @@ bool NTScalar::isCompatible(PVStructurePtr const & pvStructure) return isCompatible(pvStructure->getStructure()); } +bool NTScalar::isValid() +{ + return true; +} + NTScalarBuilderPtr NTScalar::createBuilder() { return NTScalarBuilderPtr(new detail::NTScalarBuilder()); diff --git a/src/nt/ntscalarArray.cpp b/src/nt/ntscalarArray.cpp index 8dfea9c..ba7abf5 100644 --- a/src/nt/ntscalarArray.cpp +++ b/src/nt/ntscalarArray.cpp @@ -189,6 +189,10 @@ bool NTScalarArray::isCompatible(PVStructurePtr const & pvStructure) return isCompatible(pvStructure->getStructure()); } +bool NTScalarArray::isValid() +{ + return true; +} NTScalarArrayBuilderPtr NTScalarArray::createBuilder() { diff --git a/src/nt/ntunion.cpp b/src/nt/ntunion.cpp index b4ddd86..c873b7a 100644 --- a/src/nt/ntunion.cpp +++ b/src/nt/ntunion.cpp @@ -154,6 +154,11 @@ bool NTUnion::isCompatible(PVStructurePtr const & pvStructure) return isCompatible(pvStructure->getStructure()); } +bool NTUnion::isValid() +{ + return true; +} + NTUnionBuilderPtr NTUnion::createBuilder() { return NTUnionBuilderPtr(new detail::NTUnionBuilder());