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