GCC Code Coverage Report


Directory: ./
File: pdserv/src/lib/Signal.h
Date: 2024-11-17 04:08:36
Exec Total Coverage
Lines: 1 1 100.0%
Branches: 0 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 #ifndef LIB_SIGNAL
25 #define LIB_SIGNAL
26
27 #include <set>
28
29 #include "../PThread.h"
30 #include "../Signal.h"
31 #include "pdserv.h"
32
33 namespace PdServ {
34 class Session;
35 class SessionTask;
36 }
37
38 class Task;
39 class SessionTaskData;
40
41 1884 class Signal: public PdServ::Signal {
42 public:
43 Signal( Task *task,
44 size_t index,
45 unsigned int decimation,
46 const char *path,
47 const PdServ::DataType& dtype,
48 const void *addr,
49 size_t ndims = 1,
50 const size_t *dim = 0);
51
52 Task* const task;
53
54 const char * const addr;
55
56 static const size_t dataTypeIndex[PdServ::DataType::maxWidth+1];
57 const size_t index;
58
59 read_signal_t read_cb;
60 void* priv_data;
61
62 void pollValue(void* dst, struct timespec* mtime) const;
63
64 // Required by Task in nrt to manage subscriptions
65 typedef std::set<SessionTaskData*> SessionSet;
66 SessionSet sessions;
67 unsigned int subscriptionId;
68 size_t copyListPos;
69
70 private:
71 // Reimplemented from PdServ::Signal
72 void subscribe(PdServ::SessionTask *) const;
73 void unsubscribe(PdServ::SessionTask *) const;
74 double sampleTime() const;
75 const char *getValue(const PdServ::SessionTask*) const;
76
77 // Reimplemented from PdServ::Variable
78 int getValue(const PdServ::Session*,
79 void *, struct timespec * = 0) const;
80
81 // A default function used when read_cb is not specified by the user
82 static int copy(const struct pdvariable *signal,
83 void *dst, const void *src, size_t len,
84 struct timespec* time, void *priv_data);
85 };
86
87 #endif //LIB_SIGNAL
88