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 | |
Matt Spinler | df1b7cf | 2017-10-31 14:17:23 -0500 | [diff] [blame] | 16 | constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; |
| 17 | constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper"; |
| 18 | constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper"; |
Ratan Gupta | 90bfaea | 2017-10-06 20:56:31 +0530 | [diff] [blame] | 19 | constexpr auto pathIndex = 0; |
| 20 | constexpr auto propertyIndex = 2; |
Matt Spinler | abe43ab | 2018-02-19 13:34:43 -0600 | [diff] [blame] | 21 | constexpr auto storageIndex = 2; |
| 22 | constexpr auto valueIndex = 0; |
Ratan Gupta | 90bfaea | 2017-10-06 20:56:31 +0530 | [diff] [blame] | 23 | constexpr auto metaIndex = 1; |
Matt Spinler | df1b7cf | 2017-10-31 14:17:23 -0500 | [diff] [blame] | 24 | |
Ratan Gupta | a45e086 | 2018-02-21 19:03:13 +0530 | [diff] [blame] | 25 | enum class Context |
| 26 | { |
| 27 | START, |
| 28 | SIGNAL, |
| 29 | }; |
| 30 | |
Brad Bishop | 186aa67 | 2017-05-15 22:27:57 -0400 | [diff] [blame] | 31 | /** @brief A map with references as keys. */ |
| 32 | template <typename Key, typename Value> |
| 33 | using RefKeyMap = std::map<std::reference_wrapper<Key>, Value, std::less<Key>>; |
| 34 | |
| 35 | /** @brief A map with a tuple of references as keys. */ |
| 36 | template <typename Value, typename ...Keys> |
| 37 | using TupleRefMap = std::map<TupleOfRefs<Keys...>, Value, TupleOfRefsLess>; |
| 38 | |
| 39 | /** @brief A vector of references. */ |
| 40 | template <typename T> |
| 41 | using RefVector = std::vector<std::reference_wrapper<T>>; |
| 42 | |
| 43 | /** @brief |
| 44 | * |
| 45 | * The mapper has a defect such that it provides strings |
| 46 | * rather than object paths. Use an alias for easy refactoring |
| 47 | * when the mapper is fixed. |
| 48 | */ |
| 49 | using MapperPath = std::string; |
| 50 | |
| 51 | /** @brief ObjectManager.InterfacesAdded signal signature alias. */ |
| 52 | template <typename T> |
| 53 | using InterfacesAdded = std::map < |
| 54 | std::string, |
| 55 | std::map < |
| 56 | std::string, |
| 57 | sdbusplus::message::variant<T >>>; |
| 58 | |
| 59 | /** @brief ObjectMapper.GetObject response signature alias. */ |
| 60 | using GetObject = std::map<MapperPath, std::vector<std::string>>; |
| 61 | |
| 62 | /** @brief Properties.GetAll response signature alias. */ |
| 63 | template <typename T> |
| 64 | using PropertiesChanged = std::map < |
| 65 | std::string, |
| 66 | sdbusplus::message::variant<T >>; |
| 67 | |
Brad Bishop | 4b916f1 | 2017-05-23 18:06:38 -0400 | [diff] [blame] | 68 | /** @brief Lookup index for properties . */ |
| 69 | // *INDENT-OFF* |
| 70 | using PropertyIndex = TupleRefMap < |
| 71 | TupleOfRefs< |
| 72 | const std::string, |
| 73 | const std::string, |
Matt Spinler | abe43ab | 2018-02-19 13:34:43 -0600 | [diff] [blame] | 74 | std::tuple<any_ns::any, any_ns::any>>, |
Brad Bishop | 4b916f1 | 2017-05-23 18:06:38 -0400 | [diff] [blame] | 75 | const std::string, |
| 76 | const std::string, |
| 77 | const std::string >; |
| 78 | // *INDENT-ON* |
Brad Bishop | 893b348 | 2017-05-23 18:17:25 -0400 | [diff] [blame] | 79 | |
| 80 | /** @brief Convert some C++ types to others. |
| 81 | * |
| 82 | * Remove type decorators to reduce template specializations. |
| 83 | * |
| 84 | * 1. Remove references. |
| 85 | * 2. Remove 'const' and 'volatile'. |
| 86 | */ |
| 87 | template <typename T> struct Downcast |
| 88 | { |
| 89 | using Type = std::remove_cv_t<std::remove_reference_t<T>>; |
| 90 | }; |
| 91 | template <typename T> using DowncastType = |
| 92 | typename Downcast<T>::Type; |
| 93 | |
Matthew Barth | b86374d | 2017-04-12 10:57:19 -0500 | [diff] [blame] | 94 | } // namespace monitoring |
| 95 | } // namespace dbus |
| 96 | } // namespace phosphor |