1 #pragma once
2 
3 #include "associations.hpp"
4 #include "types.hpp"
5 
6 #include <boost/container/flat_map.hpp>
7 
8 #include <cassert>
9 #include <string>
10 
11 /** @brief The associations definitions interface */
12 constexpr const char* assocDefsInterface =
13     "xyz.openbmc_project.Association.Definitions";
14 
15 /** @brief The associations definitions property name */
16 constexpr const char* assocDefsProperty = "Associations";
17 
18 /** @brief InterfacesAdded represents the dbus data from the signal
19  *
20  * There are 2 pairs
21  * pair1: D-bus Interface,vector[pair2]
22  * pair2: D-bus Method,vector[Associations]
23  */
24 using InterfacesAdded = std::vector<std::pair<
25     std::string, std::vector<std::pair<
26                      std::string, std::variant<std::vector<Association>>>>>>;
27 
28 /** @brief Get well known name of input unique name
29  *
30  * If user passes in well known name then that will be returned.
31  *
32  * @param[in] owners       - Current list of owners
33  * @param[in] request      - The name to look up
34  * @param[out] wellKnown   - The well known name if found
35  *
36  * @return True if well known name is found, false otherwise
37  */
38 bool getWellKnown(
39     const boost::container::flat_map<std::string, std::string>& owners,
40     const std::string& request, std::string& wellKnown);
41 
42 /** @brief Determine if dbus service is something to monitor
43  *
44  * mapper does not monitor all DBus services.  needToIntrospect determines
45  * whether or not a service is to be monitored.
46  *
47  * @param[in] processName   - Dbus service name
48  *
49  * @return True if input processName should be monitored, false otherwise
50  */
51 bool needToIntrospect(const std::string& processName);
52 
53 /** @brief Handle the removal of an existing name in objmgr data structures
54  *
55  * @param[in] io                  - io context
56  * @param[in,out] nameOwners      - Map of unique name to well known name
57  * @param[in]     wellKnown       - Well known name that has new owner
58  * @param[in]     oldOwner        - Old unique name
59  * @param[in,out] interfaceMap    - Map of interfaces
60  * @param[in,out] assocMaps       - The association maps
61  * @param[in,out] server          - sdbus system object
62  *
63  */
64 void processNameChangeDelete(
65     boost::asio::io_context& io,
66     boost::container::flat_map<std::string, std::string>& nameOwners,
67     const std::string& wellKnown, const std::string& oldOwner,
68     InterfaceMapType& interfaceMap, AssociationMaps& assocMaps,
69     sdbusplus::asio::object_server& server);
70 
71 /** @brief Handle an interfaces added signal
72  *
73  * @param[in] io                  - io context
74  * @param[in,out] interfaceMap    - Global map of interfaces
75  * @param[in]     objPath         - New path to process
76  * @param[in]     interfacesAdded - New interfaces to process
77  * @param[in]     wellKnown       - Well known name that has new owner
78  * @param[in,out] assocMaps       - The association maps
79  * @param[in,out] server          - sdbus system object
80  *
81  */
82 void processInterfaceAdded(
83     boost::asio::io_context& io, InterfaceMapType& interfaceMap,
84     const sdbusplus::message::object_path& objPath,
85     const InterfacesAdded& intfAdded, const std::string& wellKnown,
86     AssociationMaps& assocMaps, sdbusplus::asio::object_server& server);
87