From 39c91d844065cad67c8bf1a06c434eca2516c091 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 6 Apr 2019 16:00:21 +0200 Subject: [PATCH] ENH: support HashTable iterator pointer dereference --- .../test/HashTable2/Test-HashTable2.C | 191 +++++++++++++++++- .../test/HashTable3/Test-HashTable3.C | 1 - .../mesh/manipulation/rotateMesh/rotateMesh.C | 2 +- .../foamFormatConvert/foamFormatConvert.C | 6 +- .../PVReaders/vtkPVFoam/vtkPVFoamFields.C | 16 +- .../mapFields/MapConsistentVolFields.H | 4 +- .../mapFields/MapLagrangianFields.H | 12 +- .../preProcessing/mapFields/MapVolFields.H | 4 +- .../preProcessing/mapFields/UnMapped.H | 2 +- .../mapFieldsPar/MapLagrangianFields.H | 6 +- .../preProcessing/mapFieldsPar/UnMapped.H | 2 +- .../HashTables/HashTable/HashTable.H | 17 ++ .../db/IOobjectList/IOobjectListTemplates.C | 2 +- .../db/objectRegistry/objectRegistry.C | 14 +- .../objectRegistry/objectRegistryTemplates.C | 4 +- src/OpenFOAM/meshes/MeshObject/MeshObject.C | 12 +- .../genericFaPatchField/genericFaPatchField.C | 30 +-- .../genericFvPatchField/genericFvPatchField.C | 30 +-- .../genericFvsPatchField.C | 30 +-- .../genericPointPatchField.C | 30 +-- 20 files changed, 300 insertions(+), 115 deletions(-) diff --git a/applications/test/HashTable2/Test-HashTable2.C b/applications/test/HashTable2/Test-HashTable2.C index 288def8edc..a4a838735e 100644 --- a/applications/test/HashTable2/Test-HashTable2.C +++ b/applications/test/HashTable2/Test-HashTable2.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -31,9 +31,53 @@ Description #include "HashTable.H" #include "HashPtrTable.H" #include "Map.H" +#include "FlatOutput.H" using namespace Foam; + +// Simple wrapper for testing purposes +class Label +{ + label data_; + +public: + + Label() + : + data_(0) + {} + + Label(label val) + : + data_(val) + {} + + ~Label() + { + Info<<"delete label: " << data_ << endl; + } + + // Some arbitrary non-const method (for testing) + label increment() + { + return ++data_; + } + + // Some arbitrary method (for testing) + std::string info() const + { + return "boxed label=" + std::to_string(data_); + } + + friend Ostream& operator<<(Ostream& os, const Label& val) + { + os << val.data_; + return os; + } +}; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: @@ -46,7 +90,7 @@ int main(int argc, char *argv[]) }; Info<< "table1: " << table1 << nl - << "toc: " << table1.toc() << endl; + << "toc: " << flatOutput(table1.toc()) << nl; HashTable> table2 { @@ -56,31 +100,156 @@ int main(int argc, char *argv[]) }; Info<< "table2: " << table2 << nl - << "toc: " << table2.toc() << endl; + << "toc: " << flatOutput(table2.toc()) << nl; Map