blob: 7e1936413b1dc0f47ed7ea02a5b0e3aa4daccde4 [file] [log] [blame]
Moritz Pflanzer80fffae2017-07-05 11:02:37 +01001/*
2 * Copyright (c) 2017 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#ifndef ARM_COMPUTE_TEST_PRINTER
25#define ARM_COMPUTE_TEST_PRINTER
26
27#include "../Profiler.h"
28
29#include <fstream>
30#include <iostream>
31#include <ostream>
32
33namespace arm_compute
34{
35namespace test
36{
37namespace framework
38{
39/** Abstract printer class used by the @ref Framework to present output. */
40class Printer
41{
42public:
43 /** Default constructor.
44 *
45 * Prints values to std::cout.
46 * */
47 Printer() = default;
48
49 /** Construct printer with given output stream.
50 *
51 * @param[out] stream Output stream.
52 */
53 Printer(std::ostream &stream);
54
55 Printer(const Printer &) = delete;
56 Printer &operator=(const Printer &) = delete;
57 Printer(Printer &&) = default;
58 Printer &operator=(Printer &&) = default;
59
60 virtual ~Printer() = default;
61
62 /** Print given string.
63 *
64 * @param[in] str String.
65 */
66 void print(const std::string &str);
67
68 /** Print an entry consisting of a (name, value) pair.
69 *
70 * @param[in] name Description of the value.
71 * @param[in] value Value.
72 */
73 virtual void print_entry(const std::string &name, const std::string &value) = 0;
74
75 /** Print global header. */
76 virtual void print_global_header() = 0;
77
78 /** Print global footer. */
79 virtual void print_global_footer() = 0;
80
81 /** Print header before running all tests. */
82 virtual void print_run_header() = 0;
83
84 /** Print footer after running all tests. */
85 virtual void print_run_footer() = 0;
86
87 /** Print header before a test.
88 *
89 * @param[in] name test_name.
90 */
91 virtual void print_test_header(const std::string &name) = 0;
92
93 /** Print footer after a test. */
94 virtual void print_test_footer() = 0;
95
96 /** Print measurements for a test.
97 *
98 * @param[in] measurements Measurements as collected by a @ref Profiler.
99 */
100 virtual void print_measurements(const Profiler::MeasurementsMap &measurements) = 0;
101
102 /** Set the output stream.
103 *
104 * @param[out] stream Output stream.
105 */
106 void set_stream(std::ostream &stream);
107
108protected:
109 std::ostream *_stream{ &std::cout };
110};
111} // namespace framework
112} // namespace test
113} // namespace arm_compute
114#endif /* ARM_COMPUTE_TEST_PRINTER */