GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/io/rasterimagedata.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 7 7 100.0%
Functions: 2 2 100.0%
Branches: 8 20 40.0%

Line Branch Exec Source
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 //
4 // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 /*!
8 * \file
9 * \ingroup InputOutput
10 * \brief A data class for raster image information
11 */
12 #ifndef DUMUX_RASTER_IMAGE_DATA_HH
13 #define DUMUX_RASTER_IMAGE_DATA_HH
14
15 #include <string>
16 #include <vector>
17 #include <fstream>
18
19 namespace Dumux::Detail::RasterImageData {
20
21 /*!
22 * \brief A struct that holds all information of the image format.
23 */
24
2/4
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
20 struct Format
25 {
26 std::string magicNumber;
27 std::string type;
28 std::string encoding;
29 };
30
31 /*!
32 * \brief A struct that contains all header data of the image.
33 */
34
3/6
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 8 times.
✗ Branch 8 not taken.
30 struct HeaderData
35 {
36 Format format;
37 std::size_t nCols;
38 std::size_t nRows;
39 std::size_t maxValue = 1;
40 };
41
42 /*!
43 * \brief The return type of the reading functions.
44 * Holds the actual pixel values and the header data.
45 */
46 template<class T>
47
3/10
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
10 class Result : private std::vector<T>
48 {
49 using Parent = std::vector<T>;
50 public:
51 Result() = delete;
52
53 /*!
54 * \brief Construct from data and header by copy
55 */
56 Result(const std::vector<T>& data, const HeaderData& header)
57 : Parent(data)
58 , header_(header)
59 {}
60
61 /*!
62 * \brief Construct from data and header by move
63 */
64 14 Result(std::vector<T>&& data, HeaderData&& header)
65 14 : Parent(std::move(data))
66 28 , header_(std::move(header))
67 14 {}
68
69 //! Returns the header data.
70 const HeaderData& header() const { return header_; }
71
72 // expose some methods of std::vector
73 using Parent::operator[];
74 using Parent::begin;
75 using Parent::end;
76 using Parent::size;
77
78 private:
79 HeaderData header_;
80 };
81
82 } // end namespace Dumux::Detail::RasterImageData
83
84 #endif
85