GCC Code Coverage Report


Directory: ./
File: pdserv/src/lib/Event.cpp
Date: 2023-11-12 04:06:57
Exec Total Coverage
Lines: 14 17 82.4%
Branches: 8 14 57.1%

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