GCC Code Coverage Report


Directory: ./
File: pdserv/src/lib/Signal.cpp
Date: 2024-12-15 04:08:34
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 942 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 942 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 942 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 942 times.
✗ Branch 10 not taken.
942 index(index)
51 {
52 942 read_cb = copy;
53 942 }
54
55 //////////////////////////////////////////////////////////////////////
56 47 void Signal::subscribe(PdServ::SessionTask *st) const
57 {
58 // log_debug("%s", path.c_str());
59 47 st->sessionTaskData->subscribe(this);
60 47 }
61
62 //////////////////////////////////////////////////////////////////////
63 44 void Signal::unsubscribe(PdServ::SessionTask *st) const
64 {
65 // log_debug("%s", path.c_str());
66 44 st->sessionTaskData->unsubscribe(this);
67 44 }
68
69 //////////////////////////////////////////////////////////////////////
70 57 int Signal::getValue(const PdServ::Session* /*session*/,
71 void *dest, struct timespec *t) const
72 {
73 57 return task->main->getValue(this, dest, t);
74 }
75
76 //////////////////////////////////////////////////////////////////////
77 1181 const char *Signal::getValue(const PdServ::SessionTask* st) const
78 {
79 1181 return st->sessionTaskData->getValue(this);
80 }
81
82 //////////////////////////////////////////////////////////////////////
83 57 void Signal::pollValue(void* dst, struct timespec* mtime) const
84 {
85 57 task->getCurrentTime(mtime);
86
87 114 read_cb(reinterpret_cast<const struct pdvariable*>(
88 static_cast<const Variable*>(this)),
89 57 dst, addr, memSize, mtime, priv_data);
90 57 }
91
92 //////////////////////////////////////////////////////////////////////
93 57 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 57 std::copy( reinterpret_cast<const char*>(src),
99 reinterpret_cast<const char*>(src)+len,
100 reinterpret_cast<char*>(buf));
101
102 57 return 0;
103 }
104