From b4703f4a08f42f0ff9b182f38d457be148c92226 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sun, 4 Mar 2018 21:38:33 +0100 Subject: [PATCH 01/13] ENH: pre-cleanup of Xfer class (issue #639) - This class is largely a pre-C++11 holdover, prior to having movable references. - align internals with autoPtr instead of always unconditionally allocating memory. The valid() method can be used to check for a null pointer. - Consolidate into a single file, in anticipation of future removal. --- applications/test/xfer1/Make/files | 3 - applications/test/xfer1/Make/options | 0 applications/test/xfer1/Test-xfer1.C | 233 --------------------------- src/OpenFOAM/memory/Xfer/Xfer.H | 125 ++++++++------ src/OpenFOAM/memory/Xfer/XferI.H | 186 --------------------- 5 files changed, 77 insertions(+), 470 deletions(-) delete mode 100644 applications/test/xfer1/Make/files delete mode 100644 applications/test/xfer1/Make/options delete mode 100644 applications/test/xfer1/Test-xfer1.C delete mode 100644 src/OpenFOAM/memory/Xfer/XferI.H diff --git a/applications/test/xfer1/Make/files b/applications/test/xfer1/Make/files deleted file mode 100644 index 10a272c027..0000000000 --- a/applications/test/xfer1/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -Test-xfer1.C - -EXE = $(FOAM_USER_APPBIN)/Test-xfer1 diff --git a/applications/test/xfer1/Make/options b/applications/test/xfer1/Make/options deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/applications/test/xfer1/Test-xfer1.C b/applications/test/xfer1/Test-xfer1.C deleted file mode 100644 index f1fe7c0674..0000000000 --- a/applications/test/xfer1/Test-xfer1.C +++ /dev/null @@ -1,233 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Application - -Description - -\*---------------------------------------------------------------------------*/ - -#include "OSspecific.H" - -#include "IOstreams.H" -#include "labelList.H" -#include "DynamicList.H" -#include "face.H" -#include "pointField.H" -#include "DynamicField.H" - -using namespace Foam; - - -template -void printInfo(const Xfer& xf) -{ - Info<<" address:" << long(xf.get()) << nl - <<" isNull = " << isNull(xf) << nl - <<" notNull = " << notNull(xf) << nl - <<" valid() = " << xf.valid() << nl; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Main program: - -int main(int argc, char *argv[]) -{ - labelList lstA(10); - labelList lstC - { - 1, 2, 3, 4 - }; - - forAll(lstA, i) - { - lstA[i] = 5 - i; - } - - // Information about null-object - - Info<<"nullObject:" << nl; - printInfo(Xfer::null()); - { - // This probably needs more work... - Xfer xf = Xfer::null(); - - Info<<"copy of nullObject:" << nl; - printInfo(xf); - } - - Info<< "lstA: " << lstA << nl - << "lstC: " << lstC << nl; - - Xfer xA = xferMove(lstA); - Xfer xB; - - labelList lstB( xA ); - - Info<< "xA: " << xA() << nl - << "xB: " << xB() << nl - << "lstA: " << lstA << nl - << "lstB: " << lstB << nl - << "lstC: " << lstC << nl; - - // Now illegal: xA = lstB; - - xA->transfer(lstB); - - Info<< "xA: " << xA() << nl - << "xB: " << xB() << nl - << "lstA: " << lstA << nl - << "lstB: " << lstB << nl - << "lstC: " << lstC << nl; - - xB = xA; - - // Construct with forwarding. For this example, truly ugly. - Xfer xFwdA = - Xfer::New - ( - std::initializer_list