blob: 19a3cb483cdc1e5bc482a96fdc1e1b9215682c79 [file] [log] [blame]
Moritz Pflanzerd03b00a2017-07-17 13:50:12 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-2019 Arm Limited.
Moritz Pflanzerd03b00a2017-07-17 13:50:12 +01003 *
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_DATASET_MODES
25#define ARM_COMPUTE_TEST_DATASET_MODES
26
27#include <istream>
28#include <ostream>
29#include <sstream>
30#include <stdexcept>
31#include <string>
32
33namespace arm_compute
34{
35namespace test
36{
37namespace framework
38{
39/** Possible dataset modes. */
40enum class DatasetMode : unsigned int
41{
42 ALL = ~0U,
43 DISABLED = 0,
44 PRECOMMIT = 1,
45 NIGHTLY = 2
46};
47
48inline DatasetMode operator&(DatasetMode t1, DatasetMode t2)
49{
50 using type = std::underlying_type<DatasetMode>::type;
51 return static_cast<DatasetMode>(static_cast<type>(t1) & static_cast<type>(t2));
52}
53
54inline DatasetMode operator|(DatasetMode t1, DatasetMode t2)
55{
56 using type = std::underlying_type<DatasetMode>::type;
57 return static_cast<DatasetMode>(static_cast<type>(t1) | static_cast<type>(t2));
58}
59
60inline DatasetMode &operator|=(DatasetMode &t1, DatasetMode t2)
61{
62 using type = std::underlying_type<DatasetMode>::type;
63 t1 = static_cast<DatasetMode>(static_cast<type>(t1) | static_cast<type>(t2));
64 return t1;
65}
66
67DatasetMode dataset_mode_from_name(const std::string &name);
68
69inline ::std::istream &operator>>(::std::istream &stream, DatasetMode &mode)
70{
71 std::string value;
72 stream >> value;
73 mode = dataset_mode_from_name(value);
74 return stream;
75}
76
77inline ::std::ostream &operator<<(::std::ostream &stream, DatasetMode mode)
78{
79 switch(mode)
80 {
Georgios Pinitas557d4ae2019-04-18 18:10:34 +010081 case DatasetMode::DISABLED:
82 stream << "DISABLED";
83 break;
Moritz Pflanzerd03b00a2017-07-17 13:50:12 +010084 case DatasetMode::PRECOMMIT:
85 stream << "PRECOMMIT";
86 break;
87 case DatasetMode::NIGHTLY:
88 stream << "NIGHTLY";
89 break;
90 case DatasetMode::ALL:
91 stream << "ALL";
92 break;
93 default:
94 throw std::invalid_argument("Unsupported dataset mode");
95 }
96
97 return stream;
98}
99
100inline std::string to_string(DatasetMode mode)
101{
102 std::stringstream stream;
103 stream << mode;
104 return stream.str();
105}
106} // namespace framework
107} // namespace test
108} // namespace arm_compute
109#endif /* ARM_COMPUTE_TEST_DATASET_MODES */