blob: 21f2ecfe524b1ecffc7c2875497a89cc275aafd1 [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";
19
Brad Bishop186aa672017-05-15 22:27:57 -040020/** @brief A map with references as keys. */
21template <typename Key, typename Value>
22using RefKeyMap = std::map<std::reference_wrapper<Key>, Value, std::less<Key>>;
23
24/** @brief A map with a tuple of references as keys. */
25template <typename Value, typename ...Keys>
26using TupleRefMap = std::map<TupleOfRefs<Keys...>, Value, TupleOfRefsLess>;
27
28/** @brief A vector of references. */
29template <typename T>
30using RefVector = std::vector<std::reference_wrapper<T>>;
31
32/** @brief
33 *
34 * The mapper has a defect such that it provides strings
35 * rather than object paths. Use an alias for easy refactoring
36 * when the mapper is fixed.
37 */
38using MapperPath = std::string;
39
40/** @brief ObjectManager.InterfacesAdded signal signature alias. */
41template <typename T>
42using InterfacesAdded = std::map <
43 std::string,
44 std::map <
45 std::string,
46 sdbusplus::message::variant<T >>>;
47
48/** @brief ObjectMapper.GetObject response signature alias. */
49using GetObject = std::map<MapperPath, std::vector<std::string>>;
50
51/** @brief Properties.GetAll response signature alias. */
52template <typename T>
53using PropertiesChanged = std::map <
54 std::string,
55 sdbusplus::message::variant<T >>;
56
Brad Bishop4b916f12017-05-23 18:06:38 -040057/** @brief Lookup index for properties . */
58// *INDENT-OFF*
59using PropertyIndex = TupleRefMap <
60 TupleOfRefs<
61 const std::string,
62 const std::string,
63 any_ns::any>,
64 const std::string,
65 const std::string,
66 const std::string >;
67// *INDENT-ON*
Brad Bishop893b3482017-05-23 18:17:25 -040068
69/** @brief Convert some C++ types to others.
70 *
71 * Remove type decorators to reduce template specializations.
72 *
73 * 1. Remove references.
74 * 2. Remove 'const' and 'volatile'.
75 */
76template <typename T> struct Downcast
77{
78 using Type = std::remove_cv_t<std::remove_reference_t<T>>;
79};
80template <typename T> using DowncastType =
81 typename Downcast<T>::Type;
82
Matthew Barthb86374d2017-04-12 10:57:19 -050083} // namespace monitoring
84} // namespace dbus
85} // namespace phosphor