xref: /openbmc/phosphor-dbus-monitor/src/main.cpp (revision 1ada93be00378c94ff14bec8c2c7f5bbd85f72b0)
1 /**
2  * Copyright © 2017 IBM Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "sdbusplus.hpp"
17 #include "generated.hpp"
18 #include "monitor.hpp"
19 
20 using namespace phosphor::dbus::monitoring;
21 
22 struct Loop
23 {
24     /** @brief indefinitely process dbus traffic. */
25     static void run()
26     {
27         auto& bus = SDBusPlus::getBus();
28         auto& event = SDEvent::getEvent();
29         event.attach(bus);
30         event.loop();
31     }
32 };
33 
34 int main(void)
35 {
36     for (auto& watch : ConfigPropertyWatches::get())
37     {
38         watch->start();
39     }
40 
41     for (auto& watch : ConfigPropertyWatches::get())
42     {
43         watch->callback();
44     }
45 
46     Loop::run();
47 
48     return -1;
49 }
50