blob: f1512dbb76246c07934697710259f0257bb9306c [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;
Matt Spinlerabe43ab2018-02-19 13:34:43 -060021constexpr auto storageIndex = 2;
22constexpr auto valueIndex = 0;
Ratan Gupta90bfaea2017-10-06 20:56:31 +053023constexpr auto metaIndex = 1;
Matt Spinlerdf1b7cf2017-10-31 14:17:23 -050024
Ratan Guptaa45e0862018-02-21 19:03:13 +053025enum class Context
26{
27 START,
28 SIGNAL,
29};
30
Brad Bishop186aa672017-05-15 22:27:57 -040031/** @brief A map with references as keys. */
32template <typename Key, typename Value>
33using RefKeyMap = std::map<std::reference_wrapper<Key>, Value, std::less<Key>>;
34
35/** @brief A map with a tuple of references as keys. */
36template <typename Value, typename ...Keys>
37using TupleRefMap = std::map<TupleOfRefs<Keys...>, Value, TupleOfRefsLess>;
38
39/** @brief A vector of references. */
40template <typename T>
41using 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 */
49using MapperPath = std::string;
50
51/** @brief ObjectManager.InterfacesAdded signal signature alias. */
52template <typename T>
53using 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. */
60using GetObject = std::map<MapperPath, std::vector<std::string>>;
61
62/** @brief Properties.GetAll response signature alias. */
63template <typename T>
64using PropertiesChanged = std::map <
65 std::string,
66 sdbusplus::message::variant<T >>;
67
Brad Bishop4b916f12017-05-23 18:06:38 -040068/** @brief Lookup index for properties . */
69// *INDENT-OFF*
70using PropertyIndex = TupleRefMap <
71 TupleOfRefs<
72 const std::string,
73 const std::string,
Matt Spinlerabe43ab2018-02-19 13:34:43 -060074 std::tuple<any_ns::any, any_ns::any>>,
Brad Bishop4b916f12017-05-23 18:06:38 -040075 const std::string,
76 const std::string,
77 const std::string >;
78// *INDENT-ON*
Brad Bishop893b3482017-05-23 18:17:25 -040079
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 */
87template <typename T> struct Downcast
88{
89 using Type = std::remove_cv_t<std::remove_reference_t<T>>;
90};
91template <typename T> using DowncastType =
92 typename Downcast<T>::Type;
93
Matthew Barthb86374d2017-04-12 10:57:19 -050094} // namespace monitoring
95} // namespace dbus
96} // namespace phosphor