From c1f4ce95096118122114c1581a0e2bc2d5aaad29 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Sun, 18 Sep 2022 12:19:10 -0600 Subject: [PATCH] Per #1908, define operator += and operator /= functions for the DataPlane and DataPlaneArray classes. --- src/basic/vx_util/data_plane.cc | 86 ++++++++++++++++++++++++++++++++- src/basic/vx_util/data_plane.h | 6 ++- 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/src/basic/vx_util/data_plane.cc b/src/basic/vx_util/data_plane.cc index 618627dd63..bde7f982bc 100644 --- a/src/basic/vx_util/data_plane.cc +++ b/src/basic/vx_util/data_plane.cc @@ -69,6 +69,51 @@ DataPlane & DataPlane::operator=(const DataPlane &d) { /////////////////////////////////////////////////////////////////////////////// +DataPlane & DataPlane::operator+=(const DataPlane &d) { + const char *method_name = "DataPlane::operator+=(const DataPlane &) -> "; + + // Check for matching dimensions + if(Nx != d.Nx || Ny != d.Ny) { + mlog << Error << "\n" << method_name + << "the dimensions do not match: (" + << Nx << ", " << Ny << ") != (" + << d.Nx << ", " << d.Ny << ")\n\n"; + exit(1); + } + + // Increment values, checking for bad data + double v; + for(int i=0; i & buf(); @@ -187,6 +189,8 @@ class DataPlaneArray { ~DataPlaneArray(); DataPlaneArray(const DataPlaneArray &); DataPlaneArray & operator=(const DataPlaneArray &); + DataPlaneArray & operator+=(const DataPlaneArray &); + DataPlaneArray & operator/=(const double); void clear();