GCC Code Coverage Report


Directory: ./
File: pdserv/src/lib/Signal.cpp
Date: 2023-11-12 04:06:57
Exec Total Coverage
Lines: 23 23 100.0%
Branches: 2 4 50.0%

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 "../SessionTask.h"
27 #include "Signal.h"
28 #include "Main.h"
29 #include "SessionTaskData.h"
30 #include "../DataType.h"
31
32 //////////////////////////////////////////////////////////////////////
33 const size_t Signal::dataTypeIndex[PdServ::DataType::maxWidth+1] = {
34 3 /*0*/, 3 /*1*/, 2 /*2*/, 3 /*3*/,
35 1 /*4*/, 3 /*5*/, 3 /*6*/, 3 /*7*/, 0 /*8*/
36 };
37
38 //////////////////////////////////////////////////////////////////////
39 532 Signal::Signal( Task *task,
40 size_t index,
41 unsigned int decimation,
42 const char *path,
43 const PdServ::DataType& dtype,
44 const void *addr,
45 size_t ndims,
46 532 const size_t *dim):
47 PdServ::Signal(path, task, decimation, dtype, ndims, dim),
48 task(task),
49 addr(reinterpret_cast<const char *>(addr)),
50
2/4
✓ Branch 5 taken 532 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 532 times.
✗ Branch 10 not taken.
532 index(index)
51 {
52 532 read_cb = copy;
53 532 }
54
55 //////////////////////////////////////////////////////////////////////
56 15 void Signal::subscribe(PdServ::SessionTask *st) const
57 {
58 // log_debug("%s", path.c_str());
59 15 st->sessionTaskData->subscribe(this);
60 15 }
61
62 //////////////////////////////////////////////////////////////////////
63 12 void Signal::unsubscribe(PdServ::SessionTask *st) const
64 {
65 // log_debug("%s", path.c_str());
66 12 st->sessionTaskData->unsubscribe(this);
67 12 }
68
69 //////////////////////////////////////////////////////////////////////
70 25 int Signal::getValue(const PdServ::Session* /*session*/,
71 void *dest, struct timespec *t) const
72 {
73 25 return task->main->getValue(this, dest, t);
74 }
75
76 //////////////////////////////////////////////////////////////////////
77 68 const char *Signal::getValue(const PdServ::SessionTask* st) const
78 {
79 68 return st->sessionTaskData->getValue(this);
80 }
81
82 //////////////////////////////////////////////////////////////////////
83 25 void Signal::pollValue(void* dst, struct timespec* mtime) const
84 {
85 25 task->getCurrentTime(mtime);
86
87 50 read_cb(reinterpret_cast<const struct pdvariable*>(
88 static_cast<const Variable*>(this)),
89 25 dst, addr, memSize, mtime, priv_data);
90 25 }
91
92 //////////////////////////////////////////////////////////////////////
93 25 int Signal::copy(const struct pdvariable *,
94 void *buf, const void *src, size_t len,
95 struct timespec*, void *)
96 {
97 // cout << __PRETTY_FUNCTION__ << checkOnly << endl;
98 25 std::copy( reinterpret_cast<const char*>(src),
99 reinterpret_cast<const char*>(src)+len,
100 reinterpret_cast<char*>(buf));
101
102 25 return 0;
103 }
104