| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "profilepartprovider.h" |
| 5 | |
| 6 | #include <utility> |
| 7 | |
| 8 | std::unordered_map<std::string, std::function<std::unique_ptr<IProfilePart>()>> const & |
| 9 | ProfilePartProvider::profilePartProviders() const |
| 10 | { |
| 11 | return profilePartProviders_(); |
| 12 | } |
| 13 | |
| 14 | std::unordered_map<std::string, std::function<std::unique_ptr<IProfilePart>()>> & |
| 15 | ProfilePartProvider::profilePartProviders_() |
| 16 | { |
| 17 | static std::unordered_map<std::string, |
| 18 | std::function<std::unique_ptr<IProfilePart>()>> |
| 19 | providers; |
| 20 | return providers; |
| 21 | } |
| 22 | |
| 23 | bool ProfilePartProvider::registerProvider( |
| 24 | std::string_view componentID, |
| 25 | std::function<std::unique_ptr<IProfilePart>()> &&provider) |
| 26 | { |
| 27 | profilePartProviders_().emplace(std::string(componentID), std::move(provider)); |
| 28 | return true; |
| 29 | } |