blob: 1ba0b8af64f18da98f3c7d9ee57a2ff310879acd [file] [log] [blame]
Matthew Barthb86374d2017-04-12 10:57:19 -05001#pragma once
2
Brad Bishop186aa672017-05-15 22:27:57 -04003#include <experimental/any>
Matthew Barthb86374d2017-04-12 10:57:19 -05004#include <sdbusplus/message.hpp>
Brad Bishop186aa672017-05-15 22:27:57 -04005#include "tupleref.hpp"
6
7namespace any_ns = std::experimental;
Matthew Barthb86374d2017-04-12 10:57:19 -05008
9namespace phosphor
10{
11namespace dbus
12{
13namespace monitoring
14{
15
Matt Spinlerdf1b7cf2017-10-31 14:17:23 -050016constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
17constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper";
18constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper";
Ratan Gupta90bfaea2017-10-06 20:56:31 +053019constexpr auto pathIndex = 0;
20constexpr auto propertyIndex = 2;
21constexpr auto valueIndex = 2;
22constexpr auto metaIndex = 1;
Matt Spinlerdf1b7cf2017-10-31 14:17:23 -050023
Brad Bishop186aa672017-05-15 22:27:57 -040024/** @brief A map with references as keys. */
25template <typename Key, typename Value>
26using RefKeyMap = std::map<std::reference_wrapper<Key>, Value, std::less<Key>>;
27
28/** @brief A map with a tuple of references as keys. */
29template <typename Value, typename ...Keys>
30using TupleRefMap = std::map<TupleOfRefs<Keys...>, Value, TupleOfRefsLess>;
31
32/** @brief A vector of references. */
33template <typename T>
34using RefVector = std::vector<std::reference_wrapper<T>>;
35
36/** @brief
37 *
38 * The mapper has a defect such that it provides strings
39 * rather than object paths. Use an alias for easy refactoring
40 * when the mapper is fixed.
41 */
42using MapperPath = std::string;
43
44/** @brief ObjectManager.InterfacesAdded signal signature alias. */
45template <typename T>
46using InterfacesAdded = std::map <
47 std::string,
48 std::map <
49 std::string,
50 sdbusplus::message::variant<T >>>;
51
52/** @brief ObjectMapper.GetObject response signature alias. */
53using GetObject = std::map<MapperPath, std::vector<std::string>>;
54
55/** @brief Properties.GetAll response signature alias. */
56template <typename T>
57using PropertiesChanged = std::map <
58 std::string,
59 sdbusplus::message::variant<T >>;
60
Brad Bishop4b916f12017-05-23 18:06:38 -040061/** @brief Lookup index for properties . */
62// *INDENT-OFF*
63using PropertyIndex = TupleRefMap <
64 TupleOfRefs<
65 const std::string,
66 const std::string,
67 any_ns::any>,
68 const std::string,
69 const std::string,
70 const std::string >;
71// *INDENT-ON*
Brad Bishop893b3482017-05-23 18:17:25 -040072
73/** @brief Convert some C++ types to others.
74 *
75 * Remove type decorators to reduce template specializations.
76 *
77 * 1. Remove references.
78 * 2. Remove 'const' and 'volatile'.
79 */
80template <typename T> struct Downcast
81{
82 using Type = std::remove_cv_t<std::remove_reference_t<T>>;
83};
84template <typename T> using DowncastType =
85 typename Downcast<T>::Type;
86
Matthew Barthb86374d2017-04-12 10:57:19 -050087} // namespace monitoring
88} // namespace dbus
89} // namespace phosphor