GCC Code Coverage Report


Directory: ./
File: pdserv/src/lib/Event.cpp
Date: 2025-08-17 04:10:43
Exec Total Coverage
Lines: 13 16 81.2%
Branches: 8 14 57.1%

Line Branch Exec Source
1 /*****************************************************************************
2 *
3 * Copyright 2010 Richard Hacker (lerichi at gmx dot net)
4 *
5 * This file is part of the pdserv library.
6 *
7 * The pdserv library is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation, either version 3 of the License, or (at
10 * your option) any later version.
11 *
12 * The pdserv library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 * License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with the pdserv library. If not, see <http://www.gnu.org/licenses/>.
19 *
20 ****************************************************************************/
21
22 #include "../Debug.h"
23
24 #include "Event.h"
25 #include "Main.h"
26
27 //////////////////////////////////////////////////////////////////////
28 314 Event::Event(Main *main, const char* path, size_t nelem):
29 PdServ::Event(path, nelem),
30 main(main),
31
2/4
✓ Branch 3 taken 314 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 314 times.
✗ Branch 8 not taken.
314 m_state(new Priority[nelem])
32 {
33
1/2
✓ Branch 4 taken 314 times.
✗ Branch 5 not taken.
314 std::fill_n(m_state, nelem, Reset);
34 314 }
35
36 //////////////////////////////////////////////////////////////////////
37 628 Event::~Event()
38 {
39
1/2
✓ Branch 1 taken 314 times.
✗ Branch 2 not taken.
314 delete[] m_state;
40 314 }
41
42 //////////////////////////////////////////////////////////////////////
43 27 void Event::set(size_t elem, Priority prio, const timespec *t) const
44 {
45
2/4
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27 times.
27 if (m_state[elem] == prio)
46 return;
47
48
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 16 times.
27 if (prio == Reset)
49 11 main->resetEvent(this, elem, t);
50 else
51 16 main->setEvent(this, elem, prio, t);
52
53 27 m_state[elem] = prio;
54 }
55
56 //////////////////////////////////////////////////////////////////////
57 void Event::reset(size_t elem, const timespec *t) const
58 {
59 set(elem, Reset, t);
60 }
61