1 #include "src/associations.hpp"
2 
3 const std::string DEFAULT_SOURCE_PATH = "/logging/entry/1";
4 const std::string DEFAULT_DBUS_SVC = "xyz.openbmc_project.New.Interface";
5 const std::string DEFAULT_FWD_PATH = {DEFAULT_SOURCE_PATH + "/" + "inventory"};
6 const std::string DEFAULT_ENDPOINT =
7     "/xyz/openbmc_project/inventory/system/chassis";
8 const std::string DEFAULT_REV_PATH = {DEFAULT_ENDPOINT + "/" + "error"};
9 const std::string EXTRA_ENDPOINT = "/xyz/openbmc_project/differnt/endpoint";
10 
11 // Create a default AssociationOwnersType object
12 AssociationOwnersType createDefaultOwnerAssociation()
13 {
14     AssociationPaths assocPathMap = {{DEFAULT_FWD_PATH, {DEFAULT_ENDPOINT}},
15                                      {DEFAULT_REV_PATH, {DEFAULT_SOURCE_PATH}}};
16     boost::container::flat_map<std::string, AssociationPaths> serviceMap = {
17         {DEFAULT_DBUS_SVC, assocPathMap}};
18     AssociationOwnersType ownerAssoc = {{DEFAULT_SOURCE_PATH, serviceMap}};
19     return ownerAssoc;
20 }
21 
22 // Create a default AssociationInterfaces object
23 AssociationInterfaces
24     createDefaultInterfaceAssociation(sdbusplus::asio::object_server* server)
25 {
26     AssociationInterfaces interfaceAssoc;
27 
28     auto& iface = interfaceAssoc[DEFAULT_FWD_PATH];
29     auto& endpoints = std::get<endpointsPos>(iface);
30     endpoints.push_back(DEFAULT_ENDPOINT);
31     server->add_interface(DEFAULT_FWD_PATH, DEFAULT_DBUS_SVC);
32 
33     auto& iface2 = interfaceAssoc[DEFAULT_REV_PATH];
34     auto& endpoints2 = std::get<endpointsPos>(iface2);
35     endpoints2.push_back(DEFAULT_SOURCE_PATH);
36     server->add_interface(DEFAULT_REV_PATH, DEFAULT_DBUS_SVC);
37 
38     return interfaceAssoc;
39 }
40 
41 // Just add an extra endpoint to the first association
42 void addEndpointToInterfaceAssociation(AssociationInterfaces& interfaceAssoc)
43 {
44     auto iface = interfaceAssoc[DEFAULT_FWD_PATH];
45     auto endpoints = std::get<endpointsPos>(iface);
46     endpoints.push_back(EXTRA_ENDPOINT);
47 }
48