xref: /aosp_15_r20/external/ComputeLibrary/tests/datasets/ImageFileDatasets.h (revision c217d954acce2dbc11938adb493fc0abd69584f3)
1 /*
2  * Copyright (c) 2018-2019 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_IMAGE_FILE_DATASET
25 #define ARM_COMPUTE_TEST_IMAGE_FILE_DATASET
26 
27 #include "tests/framework/datasets/Datasets.h"
28 
29 #include <type_traits>
30 
31 namespace arm_compute
32 {
33 namespace test
34 {
35 namespace datasets
36 {
37 class ImageFileDataset
38 {
39 public:
40     struct iterator
41     {
iteratoriterator42         iterator(std::vector<std::string>::const_iterator name_it)
43             : _name_it{ std::move(name_it) }
44         {
45         }
46 
descriptioniterator47         std::string description() const
48         {
49             std::stringstream description;
50             description << "ImageFile=" << *_name_it;
51             return description.str();
52         }
53 
54         std::tuple<std::string> operator*() const
55         {
56             return std::make_tuple(*_name_it);
57         }
58 
59         iterator &operator++()
60         {
61             ++_name_it;
62 
63             return *this;
64         }
65 
66     private:
67         std::vector<std::string>::const_iterator _name_it;
68     };
69 
begin()70     iterator begin() const
71     {
72         return iterator(_names.begin());
73     }
74 
size()75     int size() const
76     {
77         return _names.size();
78     }
79 
add_image_file(std::string name)80     void add_image_file(std::string name)
81     {
82         _names.emplace_back(std::move(name));
83     }
84 
85 protected:
86     ImageFileDataset()                    = default;
87     ImageFileDataset(ImageFileDataset &&) = default;
88 
89 private:
90     std::vector<std::string> _names{};
91 };
92 
93 /** Data set containing names of small image files. */
94 class SmallImageFiles final : public ImageFileDataset
95 {
96 public:
SmallImageFiles()97     SmallImageFiles()
98     {
99         add_image_file("640x480.ppm");
100         add_image_file("800x600.ppm");
101     }
102 };
103 
104 /** Data set containing names of large image files. */
105 class LargeImageFiles final : public ImageFileDataset
106 {
107 public:
LargeImageFiles()108     LargeImageFiles()
109     {
110         add_image_file("1280x720.ppm");
111         add_image_file("1920x1080.ppm");
112     }
113 };
114 
115 } // namespace datasets
116 } // namespace test
117 } // namespace arm_compute
118 #endif /* ARM_COMPUTE_TEST_IMAGE_FILE_DATASET */
119