#include "convert.h" #include #include #include namespace epics { namespace pvData { // Introspection object comparision /** Field equality conditions: * 1) same instance * 2) same type (field and scalar/element) * Note: not the same name */ bool operator==(const Field& a, const Field& b) { if(&a==&b) return true; if(a.getType()!=b.getType()) return false; switch(a.getType()) { case scalar: { const Scalar &A=static_cast(a); const Scalar &B=static_cast(b); return A==B; } case scalarArray: { const ScalarArray &A=static_cast(a); const ScalarArray &B=static_cast(b); return A==B; } case structure: { const Structure &A=static_cast(a); const Structure &B=static_cast(b); return A==B; } case structureArray: { const StructureArray &A=static_cast(a); const StructureArray &B=static_cast(b); return A==B; } default: throw std::logic_error("Invalid Field type in comparision"); } } bool operator==(const Scalar& a, const Scalar& b) { if(&a==&b) return true; return a.getScalarType()==b.getScalarType(); } bool operator==(const ScalarArray& a, const ScalarArray& b) { if(&a==&b) return true; return a.getElementType()==b.getElementType(); } bool operator==(const Structure& a, const Structure& b) { if(&a==&b) return true; int nflds=a.getNumberFields(); if (b.getNumberFields()!=nflds) return false; return std::equal(a.getFields(), a.getFields()+nflds, b.getFields()); } bool operator==(const StructureArray& a, const StructureArray& b) { return a.structure() == b.structure(); } namespace nconvert { } // namespace nconvert }} // namespace epics::pvData