@@ -17,8 +17,6 @@ namespace loader {
1717
1818class AdapterRegistry {
1919 public:
20- std::vector<std::string> discoveredPlatforms;
21-
2220 AdapterRegistry () {
2321 std::optional<std::string> altPlatforms;
2422
@@ -29,24 +27,70 @@ class AdapterRegistry {
2927 logger::error (e.what ());
3028 }
3129 if (!altPlatforms) {
32- discoverKnownPlatforms ();
30+ discoverKnownAdapters ();
3331 }
3432
3533 std::stringstream ss (*altPlatforms);
3634 while (ss.good ()) {
3735 std::string substr;
3836 getline (ss, substr, ' ,' );
39- discoveredPlatforms.emplace_back (substr);
37+ discovered_adapters.emplace_back (substr);
38+ }
39+ }
40+
41+ struct Iterator {
42+ using value_type = const std::string;
43+ using pointer = value_type *;
44+
45+ Iterator (pointer ptr) noexcept : current_adapter(ptr) {}
46+
47+ Iterator &operator ++() noexcept {
48+ current_adapter++;
49+ return *this ;
50+ }
51+
52+ Iterator operator ++(int ) {
53+ Iterator tmp = *this ;
54+ ++(*this );
55+ return tmp;
56+ }
57+
58+ bool operator !=(const Iterator &other) const noexcept {
59+ return this ->current_adapter != other.current_adapter ;
4060 }
61+
62+ const value_type operator *() const { return *this ->current_adapter ; }
63+
64+ private:
65+ pointer current_adapter;
66+ };
67+
68+ const std::string &operator [](size_t i) const {
69+ return discovered_adapters[i];
70+ }
71+
72+ bool empty () const noexcept { return discovered_adapters.size () == 0 ; }
73+
74+ size_t size () const noexcept { return discovered_adapters.size (); }
75+
76+ const Iterator begin () const noexcept {
77+ return Iterator (&(*discovered_adapters.cbegin ()));
78+ }
79+
80+ const Iterator end () const noexcept {
81+ return Iterator (&(*discovered_adapters.cbegin ()) +
82+ discovered_adapters.size ());
4183 }
4284
4385 private:
86+ std::vector<std::string> discovered_adapters;
87+
4488 static constexpr std::array<const char *, 1 > knownPlatformNames{
4589 MAKE_LIBRARY_NAME (" ur_adapter_level_zero" , " 0" )};
4690
47- void discoverKnownPlatforms () {
91+ void discoverKnownAdapters () {
4892 for (const auto &path : knownPlatformNames) {
49- discoveredPlatforms .emplace_back (path);
93+ discovered_adapters .emplace_back (path);
5094 }
5195 }
5296};
0 commit comments