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