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