diff --git a/src/factory/PVField.cpp b/src/factory/PVField.cpp index bd9a491..8553eec 100644 --- a/src/factory/PVField.cpp +++ b/src/factory/PVField.cpp @@ -187,55 +187,7 @@ void PVField::copy(const PVField& from) if (getField()->getType() != from.getField()->getType()) throw std::invalid_argument("field types do not match"); - switch(getField()->getType()) - { - case scalar: - { - const PVScalar* fromS = static_cast(&from); - PVScalar* toS = static_cast(this); - toS->copy(*fromS); - break; - } - case scalarArray: - { - const PVScalarArray* fromS = static_cast(&from); - PVScalarArray* toS = static_cast(this); - toS->copy(*fromS); - break; - } - case structure: - { - const PVStructure* fromS = static_cast(&from); - PVStructure* toS = static_cast(this); - toS->copy(*fromS); - break; - } - case structureArray: - { - const PVStructureArray* fromS = static_cast(&from); - PVStructureArray* toS = static_cast(this); - toS->copy(*fromS); - break; - } - case union_: - { - const PVUnion* fromS = static_cast(&from); - PVUnion* toS = static_cast(this); - toS->copy(*fromS); - break; - } - case unionArray: - { - const PVUnionArray* fromS = static_cast(&from); - PVUnionArray* toS = static_cast(this); - toS->copy(*fromS); - break; - } - default: - { - throw std::logic_error("PVField::copy unknown type"); - } - } + copyUnchecked(from); } void PVField::copyUnchecked(const PVField& from)