| 1 | /* |
| 2 | * %injeqt copyright begin% |
| 3 | * Copyright 2014 Rafał Malinowski ([email protected]) |
| 4 | * %injeqt copyright end% |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #pragma once |
| 22 | |
| 23 | #include <injeqt/injeqt.h> |
| 24 | #include <injeqt/type.h> |
| 25 | |
| 26 | #include "provider.h" |
| 27 | #include "sorted-unique-vector.h" |
| 28 | |
| 29 | #include <memory> |
| 30 | |
| 31 | /** |
| 32 | * @file |
| 33 | * @brief Contains classes and functions for representing set of Injeqt providers sorted by provider::provided_type(). |
| 34 | */ |
| 35 | |
| 36 | namespace injeqt { namespace internal { |
| 37 | |
| 38 | /** |
| 39 | * @brief Extract provided_type from pointer to provider for storting purposes. |
| 40 | */ |
| 41 | inline type type_from_provider(const std::unique_ptr<provider> &c) |
| 42 | { |
| 43 | return c->provided_type(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @brief Abstraction of Injeqt set of providers. |
| 48 | * |
| 49 | * As provider is an abstract class it stores set of pointers to it. |
| 50 | * |
| 51 | * This set is used to represent all providers available to module and injector. It is |
| 52 | * not possible to store two providers with the same provider::provided_type() values in it. |
| 53 | * Set is sorted by provider::provided_type(). |
| 54 | */ |
| 55 | using providers = sorted_unique_vector<type, std::unique_ptr<provider>, type_from_provider>; |
| 56 | |
| 57 | }} |