From 6e154d84b43ac61ca0982014440c4bae4f7a6548 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 12 Jun 2017 16:17:04 +0200 Subject: [PATCH] STYLE: use Enum instead of NamedEnum in fileFormats --- src/conversion/fire/FIREMeshWriter.C | 8 +-- src/fileFormats/coordSet/coordSet.C | 25 +++----- src/fileFormats/coordSet/coordSet.H | 3 +- src/fileFormats/fire/FIRECore.C | 22 ++----- src/fileFormats/fire/FIRECore.H | 9 +-- src/fileFormats/starcd/STARCDCore.C | 40 ++++--------- src/fileFormats/starcd/STARCDCore.H | 6 +- .../vtk/read/vtkUnstructuredReader.C | 57 ++++++++----------- .../vtk/read/vtkUnstructuredReader.H | 11 ++-- .../surfaceFormats/fire/FLMAsurfaceFormat.C | 2 +- 10 files changed, 67 insertions(+), 116 deletions(-) diff --git a/src/conversion/fire/FIREMeshWriter.C b/src/conversion/fire/FIREMeshWriter.C index 9c6146c3e00..2fc9de6e1f3 100644 --- a/src/conversion/fire/FIREMeshWriter.C +++ b/src/conversion/fire/FIREMeshWriter.C @@ -281,22 +281,22 @@ bool Foam::fileFormats::FIREMeshWriter::write(const fileName& meshName) const if (FIRECore::file3dExtensions.hasEnum(ext)) { FIRECore::fileExt3d fireFileType = FIRECore::file3dExtensions[ext]; - if (fireFileType == FIRECore::POLY_ASCII) + if (fireFileType == FIRECore::fileExt3d::POLY_ASCII) { useBinary = false; useCompress = false; } - else if (fireFileType == FIRECore::POLY_BINARY) + else if (fireFileType == FIRECore::fileExt3d::POLY_BINARY) { useBinary = true; useCompress = false; } - else if (fireFileType == FIRECore::POLY_ASCII_COMPRESSED) + else if (fireFileType == FIRECore::fileExt3d::POLY_ASCII_Z) { useBinary = false; useCompress = true; } - else if (fireFileType == FIRECore::POLY_BINARY_COMPRESSED) + else if (fireFileType == FIRECore::fileExt3d::POLY_BINARY_Z) { useBinary = true; useCompress = true; diff --git a/src/fileFormats/coordSet/coordSet.C b/src/fileFormats/coordSet/coordSet.C index 5d7dd92b79a..c4149dc9435 100644 --- a/src/fileFormats/coordSet/coordSet.C +++ b/src/fileFormats/coordSet/coordSet.C @@ -27,26 +27,15 @@ License // * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * // -namespace Foam -{ - template<> - const char* Foam::NamedEnum - < - Foam::coordSet::coordFormat, - 5 - >::names[] = +const Foam::Enum<Foam::coordSet::coordFormat> + Foam::coordSet::coordFormatNames_ { - "xyz", - "x", - "y", - "z", - "distance" + { coordFormat::XYZ, "xyz" }, + { coordFormat::X, "x" }, + { coordFormat::Y, "y" }, + { coordFormat::Z, "z" }, + { coordFormat::DISTANCE, "distance" } }; -} - - -const Foam::NamedEnum<Foam::coordSet::coordFormat, 5> - Foam::coordSet::coordFormatNames_; // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/fileFormats/coordSet/coordSet.H b/src/fileFormats/coordSet/coordSet.H index 5492f37b435..bf764cc143c 100644 --- a/src/fileFormats/coordSet/coordSet.H +++ b/src/fileFormats/coordSet/coordSet.H @@ -37,6 +37,7 @@ SourceFiles #include "pointField.H" #include "word.H" +#include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -70,7 +71,7 @@ public: private: //- String representation of coordFormat enums - static const NamedEnum<coordFormat, 5> coordFormatNames_; + static const Enum<coordFormat> coordFormatNames_; protected: diff --git a/src/fileFormats/fire/FIRECore.C b/src/fileFormats/fire/FIRECore.C index ab576116348..4cf98960801 100644 --- a/src/fileFormats/fire/FIRECore.C +++ b/src/fileFormats/fire/FIRECore.C @@ -27,24 +27,14 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const Foam::NamedEnum<Foam::fileFormats::FIRECore::fileExt3d, 4> - Foam::fileFormats::FIRECore::file3dExtensions; - -namespace Foam -{ - template<> - const char* Foam::NamedEnum - < - Foam::fileFormats::FIRECore::fileExt3d, - 4 - >::names[] = +const Foam::Enum<Foam::fileFormats::FIRECore::fileExt3d> + Foam::fileFormats::FIRECore::file3dExtensions { - "fpma", - "fpmb", - "fpmaz", - "fpmbz" + { fileExt3d::POLY_ASCII, "fpma" }, + { fileExt3d::POLY_BINARY, "fpmb" }, + { fileExt3d::POLY_ASCII_Z, "fpmaz" }, + { fileExt3d::POLY_BINARY_Z, "fpmbz" } }; -} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/fileFormats/fire/FIRECore.H b/src/fileFormats/fire/FIRECore.H index 3f9c654cc1e..96eb73ee5f3 100644 --- a/src/fileFormats/fire/FIRECore.H +++ b/src/fileFormats/fire/FIRECore.H @@ -40,7 +40,7 @@ SourceFiles #include "labelList.H" #include "pointField.H" #include "IOstreams.H" -#include "NamedEnum.H" +#include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -86,8 +86,8 @@ public: { POLY_ASCII, POLY_BINARY, - POLY_ASCII_COMPRESSED, - POLY_BINARY_COMPRESSED + POLY_ASCII_Z, + POLY_BINARY_Z }; @@ -97,11 +97,12 @@ public: //- Float type (binary format) typedef double fireReal_t; + protected: // Protected Data - static const NamedEnum<fileExt3d, 4> file3dExtensions; + static const Enum<fileExt3d> file3dExtensions; // Protected Member Functions diff --git a/src/fileFormats/starcd/STARCDCore.C b/src/fileFormats/starcd/STARCDCore.C index 7ea833b488a..412738131e2 100644 --- a/src/fileFormats/starcd/STARCDCore.C +++ b/src/fileFormats/starcd/STARCDCore.C @@ -33,40 +33,22 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const Foam::NamedEnum<Foam::fileFormats::STARCDCore::fileHeader, 3> - Foam::fileFormats::STARCDCore::fileHeaders_; - -const Foam::NamedEnum<Foam::fileFormats::STARCDCore::fileExt, 4> - Foam::fileFormats::STARCDCore::fileExtensions_; - -namespace Foam -{ - template<> - const char* Foam::NamedEnum - < - Foam::fileFormats::STARCDCore::fileHeader, - 3 - >::names[] = +const Foam::Enum<Foam::fileFormats::STARCDCore::fileHeader> + Foam::fileFormats::STARCDCore::fileHeaders_ { - "PROSTAR_CELL", - "PROSTAR_VERTEX", - "PROSTAR_BOUNDARY" + { fileHeader::HEADER_CEL, "PROSTAR_CELL" }, + { fileHeader::HEADER_VRT, "PROSTAR_VERTEX" }, + { fileHeader::HEADER_BND, "PROSTAR_BOUNDARY" } }; - template<> - const char* Foam::NamedEnum - < - Foam::fileFormats::STARCDCore::fileExt, - 4 - >::names[] = +const Foam::Enum<Foam::fileFormats::STARCDCore::fileExt> + Foam::fileFormats::STARCDCore::fileExtensions_ { - "cel", - "vrt", - "bnd", - "inp" + { fileExt::CEL_FILE, "cel" }, + { fileExt::VRT_FILE, "vrt" }, + { fileExt::BND_FILE, "bnd" }, + { fileExt::INP_FILE, "inp" } }; -} - const char* const Foam::fileFormats::STARCDCore::defaultBoundaryName = "Default_Boundary_Region"; diff --git a/src/fileFormats/starcd/STARCDCore.H b/src/fileFormats/starcd/STARCDCore.H index cae3d1e7c0d..21f64cae72c 100644 --- a/src/fileFormats/starcd/STARCDCore.H +++ b/src/fileFormats/starcd/STARCDCore.H @@ -36,7 +36,7 @@ SourceFiles #define STARCDCore_H #include "IFstream.H" -#include "NamedEnum.H" +#include "Enum.H" #include "pointField.H" #include "Map.H" #include "FixedList.H" @@ -113,8 +113,8 @@ private: // Private Data - static const NamedEnum<fileHeader, 3> fileHeaders_; - static const NamedEnum<fileExt, 4> fileExtensions_; + static const Enum<fileHeader> fileHeaders_; + static const Enum<fileExt> fileExtensions_; protected: diff --git a/src/fileFormats/vtk/read/vtkUnstructuredReader.C b/src/fileFormats/vtk/read/vtkUnstructuredReader.C index d834f4d5eba..153c1657826 100644 --- a/src/fileFormats/vtk/read/vtkUnstructuredReader.C +++ b/src/fileFormats/vtk/read/vtkUnstructuredReader.C @@ -35,49 +35,38 @@ License namespace Foam { defineTypeNameAndDebug(vtkUnstructuredReader, 1); +} - template<> - const char* - NamedEnum<vtkUnstructuredReader::vtkDataType, 8>::names[] = +const Foam::Enum<Foam::vtkUnstructuredReader::vtkDataType> + Foam::vtkUnstructuredReader::vtkDataTypeNames { - "int", - "unsigned_int", - "long", - "unsigned_long", - "float", - "double", - "string", - "vtkIdType" + { vtkDataType::VTK_INT, "int" }, + { vtkDataType::VTK_UINT, "unsigned_int" }, + { vtkDataType::VTK_LONG, "long" }, + { vtkDataType::VTK_ULONG, "unsigned_long" }, + { vtkDataType::VTK_FLOAT, "float" }, + { vtkDataType::VTK_DOUBLE, "double" }, + { vtkDataType::VTK_STRING, "string" }, + { vtkDataType::VTK_ID, "vtkIdType" } }; - const NamedEnum<vtkUnstructuredReader::vtkDataType, 8> - vtkUnstructuredReader::vtkDataTypeNames; - - template<> - const char* - NamedEnum<vtkUnstructuredReader::vtkDataSetType, 3>::names[] = +const Foam::Enum<Foam::vtkUnstructuredReader::vtkDataSetType> + Foam::vtkUnstructuredReader::vtkDataSetTypeNames { - "FIELD", - "SCALARS", - "VECTORS" + { vtkDataSetType::VTK_FIELD, "FIELD" }, + { vtkDataSetType::VTK_SCALARS, "SCALARS" }, + { vtkDataSetType::VTK_VECTORS, "VECTORS" } }; - const NamedEnum<vtkUnstructuredReader::vtkDataSetType, 3> - vtkUnstructuredReader::vtkDataSetTypeNames; - - template<> - const char* - NamedEnum<vtkUnstructuredReader::parseMode, 5>::names[] = +const Foam::Enum<Foam::vtkUnstructuredReader::parseMode> + Foam::vtkUnstructuredReader::parseModeNames { - "NOMODE", - "UNSTRUCTURED_GRID", - "POLYDATA", - "CELL_DATA", - "POINT_DATA" + { parseMode::NOMODE, "NOMODE" }, + { parseMode::UNSTRUCTURED_GRID, "UNSTRUCTURED_GRID" }, + { parseMode::POLYDATA, "POLYDATA" }, + { parseMode::CELL_DATA, "CELL_DATA" }, + { parseMode::POINT_DATA, "POINT_DATA" } }; - const NamedEnum<vtkUnstructuredReader::parseMode, 5> - vtkUnstructuredReader::parseModeNames; -} // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/fileFormats/vtk/read/vtkUnstructuredReader.H b/src/fileFormats/vtk/read/vtkUnstructuredReader.H index 77bd71b4aac..48dc38890a8 100644 --- a/src/fileFormats/vtk/read/vtkUnstructuredReader.H +++ b/src/fileFormats/vtk/read/vtkUnstructuredReader.H @@ -51,7 +51,7 @@ SourceFiles #include "objectRegistry.H" #include "cellShapeList.H" #include "HashSet.H" -#include "NamedEnum.H" +#include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -83,7 +83,7 @@ public: VTK_ID }; - static const NamedEnum<vtkDataType, 8> vtkDataTypeNames; + static const Enum<vtkDataType> vtkDataTypeNames; //- Enumeration defining the vtk dataset types @@ -94,11 +94,10 @@ public: VTK_VECTORS }; - static const NamedEnum<vtkDataSetType, 3> vtkDataSetTypeNames; + static const Enum<vtkDataSetType> vtkDataSetTypeNames; - //- Enumeration defining the parse mode - what type of data is being - // read + //- Enumeration defining the parse mode - type of data being read enum parseMode { NOMODE, @@ -108,7 +107,7 @@ public: POINT_DATA }; - static const NamedEnum<parseMode, 5> parseModeNames; + static const Enum<parseMode> parseModeNames; private: diff --git a/src/surfMesh/surfaceFormats/fire/FLMAsurfaceFormat.C b/src/surfMesh/surfaceFormats/fire/FLMAsurfaceFormat.C index 4cbfb60d561..de258c1010b 100644 --- a/src/surfMesh/surfaceFormats/fire/FLMAsurfaceFormat.C +++ b/src/surfMesh/surfaceFormats/fire/FLMAsurfaceFormat.C @@ -222,7 +222,7 @@ void Foam::fileFormats::FLMAsurfaceFormat<Face>::write // Set the precision of the points data to 10 os.precision(10); - Info<< "points: " << pointLst.size() << endl; + Info<< nl << "points: " << pointLst.size() << endl; putFireLabel(os, pointLst.size()); newline(os); -- GitLab