GCC Code Coverage Report


Directory: ./
File: pdserv/src/lib/Event.cpp
Date: 2024-12-15 04:08:34
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 314 Event::Event( Main *main, const char* path,
31 314 size_t nelem, const char * const *messages):
32 PdServ::Event(path, nelem, messages),
33 main(main),
34
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])
35 {
36
1/2
✓ Branch 4 taken 314 times.
✗ Branch 5 not taken.
314 std::fill_n(m_state, nelem, Reset);
37 314 }
38
39 //////////////////////////////////////////////////////////////////////
40 628 Event::~Event()
41 {
42
1/2
✓ Branch 1 taken 314 times.
✗ Branch 2 not taken.
314 delete[] m_state;
43 314 }
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