1 /*  Copyright (C) 2012-2021 by László Nagy
2     This file is part of Bear.
3 
4     Bear is a tool to generate compilation database for clang tooling.
5 
6     Bear is free software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10 
11     Bear is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "report/wrapper/EventReporter.h"
21 
22 namespace wr {
23 
EventReporter(const SessionLocator & session_locator)24     EventReporter::EventReporter(const SessionLocator &session_locator) noexcept
25             : event_factory()
26             , client(session_locator)
27     { }
28 
report_start(ProcessId pid,const Execution & execution)29     void EventReporter::report_start(ProcessId pid, const Execution &execution) {
30         auto event = event_factory.start(pid, getppid(), execution);
31         client.report(event);
32     }
33 
report_wait(sys::ExitStatus exit_status)34     void EventReporter::report_wait(sys::ExitStatus exit_status) {
35         auto event = (exit_status.is_signaled())
36                 ? event_factory.signal(exit_status.signal().value())
37                 : event_factory.terminate(exit_status.code().value());
38         client.report(event);
39     }
40 }
41