From 830b3278241c7bb98ee035c42ffb3750be0cbd5c Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Mon, 29 Jun 2015 16:31:09 +0200 Subject: [PATCH] Use iosfwd declarations where possible. --- .../DataExplorer/VtkVis/VtkRaster.cpp | 24 +++++++------------ Applications/DataExplorer/VtkVis/VtkRaster.h | 2 +- AssemblerLib/LocalToGlobalIndexMap.h | 2 +- BaseLib/Histogram.h | 2 +- BaseLib/StringTools.h | 2 -- BaseLib/TCLAPCustomOutput.h | 2 +- FileIO/AsciiRasterInterface.h | 2 +- FileIO/CsvInterface.cpp | 3 +++ FileIO/CsvInterface.h | 4 +++- FileIO/FEFLOWInterface.h | 3 +-- FileIO/GmshIO/GMSHLine.cpp | 9 +++---- FileIO/GmshIO/GMSHLine.h | 2 +- FileIO/GmshIO/GMSHLineLoop.cpp | 17 +++++++------ FileIO/GmshIO/GMSHLineLoop.h | 5 ++-- FileIO/Legacy/MeshIO.h | 2 +- FileIO/Legacy/OGSIOVer4.h | 2 -- FileIO/MPI_IO/NodePartitionedMeshReader.h | 2 +- FileIO/PetrelInterface.h | 2 +- FileIO/Writer.cpp | 1 + FileIO/Writer.h | 1 - GeoLib/Color.cpp | 14 +++++------ GeoLib/Color.h | 4 +--- MathLib/LinAlg/Lis/LisMatrix.cpp | 1 + MathLib/LinAlg/Lis/LisMatrix.h | 5 ++-- MathLib/LinAlg/Lis/LisVector.h | 2 +- MathLib/LinAlg/Sparse/CRSMatrix.h | 6 ++--- MathLib/Vector3.h | 8 ++----- MathLib/vector_io.h | 1 - MeshLib/Location.cpp | 1 + MeshLib/Location.h | 2 +- MeshLib/PropertyVector.h | 2 +- .../NaturalCoordinatesMapping-impl.h | 4 +--- NumLib/Fem/CoordinatesMapping/ShapeMatrices.h | 2 +- Tests/FileIO/TestGLIReader.cpp | 2 ++ 34 files changed, 67 insertions(+), 76 deletions(-) diff --git a/Applications/DataExplorer/VtkVis/VtkRaster.cpp b/Applications/DataExplorer/VtkVis/VtkRaster.cpp index 18eeb2a72b3..ce318fe170c 100644 --- a/Applications/DataExplorer/VtkVis/VtkRaster.cpp +++ b/Applications/DataExplorer/VtkVis/VtkRaster.cpp @@ -16,26 +16,11 @@ #include <algorithm> #include <cmath> -#include <iomanip> #include <iostream> -#include <sstream> +#include <limits> #include <QFileInfo> -// ThirdParty/logog -#include "logog/include/logog.hpp" - -#include "StringTools.h" - -#include "AsciiRasterInterface.h" - -// GeoLib -#include "Raster.h" - -#include <vtkFloatArray.h> -#include <vtkPointData.h> - -#include <vtkImageAlgorithm.h> #include <vtkImageData.h> #include <vtkImageImport.h> #include <vtkImageReader2.h> @@ -48,6 +33,13 @@ #include "xtiffio.h" #endif +#include <logog/include/logog.hpp> + +#include "AsciiRasterInterface.h" + +#include "GeoLib/Raster.h" + + vtkImageAlgorithm* VtkRaster::loadImage(const std::string &fileName, double& x0, double& y0, double& delta) { diff --git a/Applications/DataExplorer/VtkVis/VtkRaster.h b/Applications/DataExplorer/VtkVis/VtkRaster.h index 14fb6b96ee1..dda90e6cd40 100644 --- a/Applications/DataExplorer/VtkVis/VtkRaster.h +++ b/Applications/DataExplorer/VtkVis/VtkRaster.h @@ -14,7 +14,7 @@ #ifndef VTKRASTER_H #define VTKRASTER_H -#include <fstream> +#include <string> class vtkImageAlgorithm; class vtkImageImport; diff --git a/AssemblerLib/LocalToGlobalIndexMap.h b/AssemblerLib/LocalToGlobalIndexMap.h index 9fc07401c11..c4e60af9190 100644 --- a/AssemblerLib/LocalToGlobalIndexMap.h +++ b/AssemblerLib/LocalToGlobalIndexMap.h @@ -11,7 +11,7 @@ #define ASSEMBLERLIB_LOCALTOGLOBALINDEXMAP_H_ #ifndef NDEBUG -#include <iostream> +#include <iosfwd> #endif // NDEBUG #include <vector> diff --git a/BaseLib/Histogram.h b/BaseLib/Histogram.h index 73ab76bdcb0..3df0f8f38ef 100644 --- a/BaseLib/Histogram.h +++ b/BaseLib/Histogram.h @@ -16,7 +16,7 @@ #include <algorithm> #include <cmath> #include <iterator> -#include <iostream> +#include <iosfwd> #include <fstream> #include <vector> diff --git a/BaseLib/StringTools.h b/BaseLib/StringTools.h index 19704d26369..f887ad56ec2 100644 --- a/BaseLib/StringTools.h +++ b/BaseLib/StringTools.h @@ -20,8 +20,6 @@ #include <string> #include <list> #include <sstream> -#include <fstream> -#include <iostream> namespace BaseLib { diff --git a/BaseLib/TCLAPCustomOutput.h b/BaseLib/TCLAPCustomOutput.h index 5d8e64a91d8..e5caa3a77fc 100644 --- a/BaseLib/TCLAPCustomOutput.h +++ b/BaseLib/TCLAPCustomOutput.h @@ -12,7 +12,7 @@ #include <string> #include <vector> #include <list> -#include <iostream> +#include <iosfwd> #include <algorithm> #include <tclap/CmdLineInterface.h> diff --git a/FileIO/AsciiRasterInterface.h b/FileIO/AsciiRasterInterface.h index c8c482da00f..55f06df772c 100644 --- a/FileIO/AsciiRasterInterface.h +++ b/FileIO/AsciiRasterInterface.h @@ -37,7 +37,7 @@ public: /// Reads a Surfer GRD raster file static GeoLib::Raster* getRasterFromSurferFile(std::string const& fname); - + /// Writes an Esri asc-file static void writeRasterAsASC(GeoLib::Raster const& raster, std::string const& file_name); diff --git a/FileIO/CsvInterface.cpp b/FileIO/CsvInterface.cpp index e6c43dca94a..dd3abc07ae0 100644 --- a/FileIO/CsvInterface.cpp +++ b/FileIO/CsvInterface.cpp @@ -13,6 +13,9 @@ #include "CsvInterface.h" +#include <algorithm> +#include <stdexcept> + #include "GeoLib/Point.h" namespace FileIO { diff --git a/FileIO/CsvInterface.h b/FileIO/CsvInterface.h index 31be7138cf6..d07a9c26845 100644 --- a/FileIO/CsvInterface.h +++ b/FileIO/CsvInterface.h @@ -14,14 +14,16 @@ #ifndef CSVINTERFACE_H_ #define CSVINTERFACE_H_ +#include <logog/include/logog.hpp> + #include <array> #include <fstream> +#include <iterator> #include <limits> #include <list> #include <string> #include <vector> -#include <logog/include/logog.hpp> #include "BaseLib/StringTools.h" diff --git a/FileIO/FEFLOWInterface.h b/FileIO/FEFLOWInterface.h index 32e02e461da..0d13a52c63d 100644 --- a/FileIO/FEFLOWInterface.h +++ b/FileIO/FEFLOWInterface.h @@ -9,8 +9,7 @@ #ifndef FEFLOWINTERFACE_H_ #define FEFLOWINTERFACE_H_ -#include <iostream> -#include <fstream> +#include <iosfwd> #include <string> #include <vector> diff --git a/FileIO/GmshIO/GMSHLine.cpp b/FileIO/GmshIO/GMSHLine.cpp index 9e62657e442..d277226476d 100644 --- a/FileIO/GmshIO/GMSHLine.cpp +++ b/FileIO/GmshIO/GMSHLine.cpp @@ -12,25 +12,26 @@ * */ -#include <GmshIO/GMSHLine.h> +#include <ostream> +#include "GMSHLine.h" namespace FileIO { namespace GMSH { -GMSHLine::GMSHLine(size_t start_point_id, size_t end_point_id) : +GMSHLine::GMSHLine(std::size_t start_point_id, std::size_t end_point_id) : _start_pnt_id(start_point_id), _end_pnt_id(end_point_id) {} GMSHLine::~GMSHLine() {} -void GMSHLine::write(std::ostream &os, size_t id) const +void GMSHLine::write(std::ostream &os, std::size_t id) const { os << "Line(" << id << ") = {" << _start_pnt_id << "," << _end_pnt_id << "};\n"; } -void GMSHLine::resetLineData(size_t start_point_id, size_t end_point_id) +void GMSHLine::resetLineData(std::size_t start_point_id, std::size_t end_point_id) { _start_pnt_id = start_point_id; _end_pnt_id = end_point_id; diff --git a/FileIO/GmshIO/GMSHLine.h b/FileIO/GmshIO/GMSHLine.h index 159caacad9d..0a53e8967a4 100644 --- a/FileIO/GmshIO/GMSHLine.h +++ b/FileIO/GmshIO/GMSHLine.h @@ -15,7 +15,7 @@ #ifndef GMSHLINE_H_ #define GMSHLINE_H_ -#include <ostream> +#include <iosfwd> namespace FileIO { diff --git a/FileIO/GmshIO/GMSHLineLoop.cpp b/FileIO/GmshIO/GMSHLineLoop.cpp index f19c035fb51..ef6e848e390 100644 --- a/FileIO/GmshIO/GMSHLineLoop.cpp +++ b/FileIO/GmshIO/GMSHLineLoop.cpp @@ -12,7 +12,10 @@ * */ -#include "GmshIO/GMSHLineLoop.h" +#include <ostream> + +#include "GMSHLine.h" +#include "GMSHLineLoop.h" namespace FileIO { @@ -24,8 +27,8 @@ GMSHLineLoop::GMSHLineLoop(bool is_sfc) : GMSHLineLoop::~GMSHLineLoop() { - const size_t n_lines (_lines.size()); - for (size_t k(0); k<n_lines; k++) { + const std::size_t n_lines (_lines.size()); + for (std::size_t k(0); k<n_lines; k++) { delete _lines[k]; } } @@ -35,14 +38,14 @@ void GMSHLineLoop::addLine(GMSHLine* line) _lines.push_back(line); } -void GMSHLineLoop::write(std::ostream &os, size_t line_offset, size_t sfc_offset) const +void GMSHLineLoop::write(std::ostream &os, std::size_t line_offset, std::size_t sfc_offset) const { - const size_t n_lines (_lines.size()); - for (size_t k(0); k<n_lines; k++) { + const std::size_t n_lines (_lines.size()); + for (std::size_t k(0); k<n_lines; k++) { (_lines[k])->write(os, line_offset+k); } os << "Line Loop(" << line_offset+n_lines << ") = {"; - for (size_t k(0); k < n_lines - 1; k++) + for (std::size_t k(0); k < n_lines - 1; k++) os << line_offset + k << ","; os << line_offset + n_lines - 1 << "};\n"; diff --git a/FileIO/GmshIO/GMSHLineLoop.h b/FileIO/GmshIO/GMSHLineLoop.h index 6ba80f3c81d..2cf12a12ccb 100644 --- a/FileIO/GmshIO/GMSHLineLoop.h +++ b/FileIO/GmshIO/GMSHLineLoop.h @@ -16,14 +16,15 @@ #define GMSHLINELOOP_H_ #include <vector> -#include <ostream> +#include <iosfwd> -#include "GMSHLine.h" namespace FileIO { namespace GMSH { +class GMSHLine; + class GMSHLineLoop { public: GMSHLineLoop(bool is_sfc=false); diff --git a/FileIO/Legacy/MeshIO.h b/FileIO/Legacy/MeshIO.h index 2db272a441c..62fe3c996ce 100644 --- a/FileIO/Legacy/MeshIO.h +++ b/FileIO/Legacy/MeshIO.h @@ -16,7 +16,7 @@ #ifndef MESHIO_H_ #define MESHIO_H_ -#include <iostream> +#include <iosfwd> #include <string> #include <vector> #include <boost/optional.hpp> diff --git a/FileIO/Legacy/OGSIOVer4.h b/FileIO/Legacy/OGSIOVer4.h index c6b8363be3a..c2dc8368b37 100644 --- a/FileIO/Legacy/OGSIOVer4.h +++ b/FileIO/Legacy/OGSIOVer4.h @@ -15,8 +15,6 @@ #ifndef OGSIOVER4_H_ #define OGSIOVER4_H_ -#include <fstream> -#include <sstream> #include <string> #include <vector> diff --git a/FileIO/MPI_IO/NodePartitionedMeshReader.h b/FileIO/MPI_IO/NodePartitionedMeshReader.h index b713c632711..c59cdf1d44e 100644 --- a/FileIO/MPI_IO/NodePartitionedMeshReader.h +++ b/FileIO/MPI_IO/NodePartitionedMeshReader.h @@ -14,7 +14,7 @@ #ifndef NODE_PARTITIONED_MESH_READER_H #define NODE_PARTITIONED_MESH_READER_H -#include <fstream> +#include <iosfwd> #include <string> #include <vector> diff --git a/FileIO/PetrelInterface.h b/FileIO/PetrelInterface.h index cb2cbda1f25..7139df11cff 100644 --- a/FileIO/PetrelInterface.h +++ b/FileIO/PetrelInterface.h @@ -18,7 +18,7 @@ #ifndef PETRELIO_H_ #define PETRELIO_H_ -#include <istream> +#include <iosfwd> #include <list> #include <string> #include <vector> diff --git a/FileIO/Writer.cpp b/FileIO/Writer.cpp index ecc19ff0ad6..2afa139f9e1 100644 --- a/FileIO/Writer.cpp +++ b/FileIO/Writer.cpp @@ -15,6 +15,7 @@ // ** INCLUDES ** #include "Writer.h" +#include <iostream> #include <fstream> #include <limits> diff --git a/FileIO/Writer.h b/FileIO/Writer.h index 378f84b73d2..15d876d5ce1 100644 --- a/FileIO/Writer.h +++ b/FileIO/Writer.h @@ -16,7 +16,6 @@ #define WRITER_H #include <string> -#include <iostream> #include <sstream> namespace FileIO diff --git a/GeoLib/Color.cpp b/GeoLib/Color.cpp index 26bc383a9e0..a3319f01534 100644 --- a/GeoLib/Color.cpp +++ b/GeoLib/Color.cpp @@ -13,10 +13,10 @@ */ #include <iostream> +#include <fstream> #include <sstream> -// ThirdParty/logog -#include "logog/include/logog.hpp" +#include <logog/include/logog.hpp> #include "Color.h" #include "StringTools.h" @@ -34,16 +34,16 @@ Color* getRandomColor() int readColorLookupTable(std::map<std::string, Color*> &colors, const std::string &filename) { - std::string id = "", line = ""; std::ifstream in( filename.c_str() ); - if (!in.is_open()) + if (!in) { WARN("Color::readLookupTable() - Could not open file %s.", filename.c_str()); return 0; } + std::string id = "", line = ""; while ( getline(in, line) ) { std::list<std::string> fields = BaseLib::splitString(line, '\t'); @@ -53,11 +53,11 @@ int readColorLookupTable(std::map<std::string, Color*> &colors, const std::strin Color *c = new Color(); id = fields.front(); fields.pop_front(); - (*c)[0] = atoi(fields.front().c_str()); + (*c)[0] = std::atoi(fields.front().c_str()); fields.pop_front(); - (*c)[1] = atoi(fields.front().c_str()); + (*c)[1] = std::atoi(fields.front().c_str()); fields.pop_front(); - (*c)[2] = atoi(fields.front().c_str()); + (*c)[2] = std::atoi(fields.front().c_str()); colors.insert(std::pair<std::string, Color*>(id, c)); } } diff --git a/GeoLib/Color.h b/GeoLib/Color.h index 1b52611642d..6a7ef328264 100644 --- a/GeoLib/Color.h +++ b/GeoLib/Color.h @@ -18,10 +18,8 @@ #include "TemplatePoint.h" -#include <cstdlib> -#include <fstream> -#include <list> #include <map> +#include <string> namespace GeoLib { diff --git a/MathLib/LinAlg/Lis/LisMatrix.cpp b/MathLib/LinAlg/Lis/LisMatrix.cpp index ae264c15ac4..9762ae805cd 100644 --- a/MathLib/LinAlg/Lis/LisMatrix.cpp +++ b/MathLib/LinAlg/Lis/LisMatrix.cpp @@ -14,6 +14,7 @@ #include "LisMatrix.h" +#include <cmath> #include <stdexcept> #include "LisVector.h" diff --git a/MathLib/LinAlg/Lis/LisMatrix.h b/MathLib/LinAlg/Lis/LisMatrix.h index 559d7018ac6..aea7ea7f5b7 100644 --- a/MathLib/LinAlg/Lis/LisMatrix.h +++ b/MathLib/LinAlg/Lis/LisMatrix.h @@ -15,17 +15,16 @@ #ifndef LISMATRIX_H_ #define LISMATRIX_H_ -#include <iostream> -#include <cmath> +#include <string> #include <vector> #include "MathLib/LinAlg/RowColumnIndices.h" -#include "MathLib/LinAlg/Lis/LisCheck.h" #include "MathLib/LinAlg/SetMatrixSparsity.h" #include "lis.h" #include "LisOption.h" +#include "LisCheck.h" namespace MathLib { diff --git a/MathLib/LinAlg/Lis/LisVector.h b/MathLib/LinAlg/Lis/LisVector.h index 3afea331b1f..da8a9d8c94a 100644 --- a/MathLib/LinAlg/Lis/LisVector.h +++ b/MathLib/LinAlg/Lis/LisVector.h @@ -15,7 +15,7 @@ #ifndef LISVECTOR_H_ #define LISVECTOR_H_ -#include <iostream> +#include <string> #include <vector> #include "lis.h" diff --git a/MathLib/LinAlg/Sparse/CRSMatrix.h b/MathLib/LinAlg/Sparse/CRSMatrix.h index 92fbc860901..ba04ec303b9 100644 --- a/MathLib/LinAlg/Sparse/CRSMatrix.h +++ b/MathLib/LinAlg/Sparse/CRSMatrix.h @@ -15,10 +15,10 @@ #ifndef CRSMATRIX_H #define CRSMATRIX_H -#include <string> -#include <fstream> -#include <iostream> #include <cassert> +#include <fstream> +#include <iosfwd> +#include <string> // MathLib #include "SparseMatrixBase.h" diff --git a/MathLib/Vector3.h b/MathLib/Vector3.h index e8e29efe941..381aeb6c6e5 100644 --- a/MathLib/Vector3.h +++ b/MathLib/Vector3.h @@ -17,15 +17,11 @@ #ifndef VECTOR3_H #define VECTOR3_H -// MathLib -#include "TemplatePoint.h" +#include <cmath> -// MathLib +#include "TemplatePoint.h" #include "MathTools.h" -#include <cmath> -#include <iostream> - namespace MathLib { /** diff --git a/MathLib/vector_io.h b/MathLib/vector_io.h index 175e8a919e0..b1ac3ba3c96 100644 --- a/MathLib/vector_io.h +++ b/MathLib/vector_io.h @@ -15,7 +15,6 @@ #ifndef VECTOR_IO_H #define VECTOR_IO_H -#include <iostream> #include <fstream> #include <string> diff --git a/MeshLib/Location.cpp b/MeshLib/Location.cpp index 19d0d6cc49f..5f53d24e162 100644 --- a/MeshLib/Location.cpp +++ b/MeshLib/Location.cpp @@ -8,6 +8,7 @@ */ #include "Location.h" +#include <ostream> namespace MeshLib { diff --git a/MeshLib/Location.h b/MeshLib/Location.h index 60f631eeba7..e874b2d57bf 100644 --- a/MeshLib/Location.h +++ b/MeshLib/Location.h @@ -10,7 +10,7 @@ * */ -#include <iostream> +#include <iosfwd> #ifndef LOCATION_H_ #define LOCATION_H_ diff --git a/MeshLib/PropertyVector.h b/MeshLib/PropertyVector.h index fe063916088..ad6c51fae87 100644 --- a/MeshLib/PropertyVector.h +++ b/MeshLib/PropertyVector.h @@ -12,7 +12,7 @@ #define PROPERTYVECTOR_H_ #include <algorithm> -#include <iostream> +#include <iosfwd> #include <iterator> #include <vector> #include <type_traits> diff --git a/NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping-impl.h b/NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping-impl.h index 233c07b578b..186f3538edd 100644 --- a/NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping-impl.h +++ b/NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping-impl.h @@ -11,12 +11,10 @@ */ -#include <iostream> #include <cassert> -#include "logog/include/logog.hpp" +#include <logog/include/logog.hpp> -#include "MeshLib/Node.h" #include "MeshLib/ElementCoordinatesMappingLocal.h" #include "MeshLib/CoordinateSystem.h" diff --git a/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h b/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h index 3632e5bd1a3..c1a788535f0 100644 --- a/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h +++ b/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h @@ -13,7 +13,7 @@ #ifndef SHAPEMATRICES_H_ #define SHAPEMATRICES_H_ -#include <iostream> +#include <ostream> namespace NumLib { diff --git a/Tests/FileIO/TestGLIReader.cpp b/Tests/FileIO/TestGLIReader.cpp index 4681bde76e9..5520274dc6f 100644 --- a/Tests/FileIO/TestGLIReader.cpp +++ b/Tests/FileIO/TestGLIReader.cpp @@ -10,6 +10,8 @@ * */ +#include <fstream> + #include <boost/filesystem.hpp> #include "gtest/gtest.h" -- GitLab