Matthew Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Brad Bishop | 186aa67 | 2017-05-15 22:27:57 -0400 | [diff] [blame] | 3 | #include <experimental/any> |
Matthew Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 4 | #include <sdbusplus/message.hpp> |
Brad Bishop | 186aa67 | 2017-05-15 22:27:57 -0400 | [diff] [blame] | 5 | #include "tupleref.hpp" |
| 6 | |
| 7 | namespace any_ns = std::experimental; |
Matthew Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 8 | |
| 9 | namespace phosphor |
| 10 | { |
| 11 | namespace dbus |
| 12 | { |
| 13 | namespace monitoring |
| 14 | { |
| 15 | |
Brad Bishop | 186aa67 | 2017-05-15 22:27:57 -0400 | [diff] [blame] | 16 | /** @brief A map with references as keys. */ |
| 17 | template <typename Key, typename Value> |
| 18 | using RefKeyMap = std::map<std::reference_wrapper<Key>, Value, std::less<Key>>; |
| 19 | |
| 20 | /** @brief A map with a tuple of references as keys. */ |
| 21 | template <typename Value, typename ...Keys> |
| 22 | using TupleRefMap = std::map<TupleOfRefs<Keys...>, Value, TupleOfRefsLess>; |
| 23 | |
| 24 | /** @brief A vector of references. */ |
| 25 | template <typename T> |
| 26 | using RefVector = std::vector<std::reference_wrapper<T>>; |
| 27 | |
| 28 | /** @brief |
| 29 | * |
| 30 | * The mapper has a defect such that it provides strings |
| 31 | * rather than object paths. Use an alias for easy refactoring |
| 32 | * when the mapper is fixed. |
| 33 | */ |
| 34 | using MapperPath = std::string; |
| 35 | |
| 36 | /** @brief ObjectManager.InterfacesAdded signal signature alias. */ |
| 37 | template <typename T> |
| 38 | using InterfacesAdded = std::map < |
| 39 | std::string, |
| 40 | std::map < |
| 41 | std::string, |
| 42 | sdbusplus::message::variant<T >>>; |
| 43 | |
| 44 | /** @brief ObjectMapper.GetObject response signature alias. */ |
| 45 | using GetObject = std::map<MapperPath, std::vector<std::string>>; |
| 46 | |
| 47 | /** @brief Properties.GetAll response signature alias. */ |
| 48 | template <typename T> |
| 49 | using PropertiesChanged = std::map < |
| 50 | std::string, |
| 51 | sdbusplus::message::variant<T >>; |
| 52 | |
Brad Bishop | 4b916f1 | 2017-05-23 18:06:38 -0400 | [diff] [blame] | 53 | /** @brief Lookup index for properties . */ |
| 54 | // *INDENT-OFF* |
| 55 | using PropertyIndex = TupleRefMap < |
| 56 | TupleOfRefs< |
| 57 | const std::string, |
| 58 | const std::string, |
| 59 | any_ns::any>, |
| 60 | const std::string, |
| 61 | const std::string, |
| 62 | const std::string >; |
| 63 | // *INDENT-ON* |
Brad Bishop | 893b348 | 2017-05-23 18:17:25 -0400 | [diff] [blame] | 64 | |
| 65 | /** @brief Convert some C++ types to others. |
| 66 | * |
| 67 | * Remove type decorators to reduce template specializations. |
| 68 | * |
| 69 | * 1. Remove references. |
| 70 | * 2. Remove 'const' and 'volatile'. |
| 71 | */ |
| 72 | template <typename T> struct Downcast |
| 73 | { |
| 74 | using Type = std::remove_cv_t<std::remove_reference_t<T>>; |
| 75 | }; |
| 76 | template <typename T> using DowncastType = |
| 77 | typename Downcast<T>::Type; |
| 78 | |
Matthew Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 79 | } // namespace monitoring |
| 80 | } // namespace dbus |
| 81 | } // namespace phosphor |