Directory: | ./ |
---|---|
File: | pdserv-1.1.0/src/lib/Parameter.cpp |
Date: | 2024-11-17 04:08:36 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 10 | 21 | 47.6% |
Branches: | 3 | 16 | 18.8% |
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 <algorithm> | ||
25 | #include <cerrno> | ||
26 | |||
27 | #include "Parameter.h" | ||
28 | #include "Main.h" | ||
29 | |||
30 | ////////////////////////////////////////////////////////////////////// | ||
31 | 60 | Parameter::Parameter( | |
32 | Main const* main, | ||
33 | const char *path, | ||
34 | unsigned int mode, | ||
35 | const PdServ::DataType& dtype, | ||
36 | void *addr, | ||
37 | size_t ndims, | ||
38 | 60 | const size_t *dim): | |
39 | PdServ::ProcessParameter(main, path, mode, dtype, ndims, dim), | ||
40 |
3/6✓ Branch 5 taken 60 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 60 times.
✗ Branch 10 not taken.
✓ Branch 24 taken 60 times.
✗ Branch 25 not taken.
|
60 | addr(reinterpret_cast<char*>(addr)), main(main), mutex(1) |
41 | { | ||
42 | 60 | trigger = copy; | |
43 | |||
44 | 60 | mtime.tv_sec = 0; | |
45 | 60 | mtime.tv_nsec = 0; | |
46 | 60 | } | |
47 | |||
48 | ////////////////////////////////////////////////////////////////////// | ||
49 | 120 | Parameter::~Parameter() | |
50 | { | ||
51 | 120 | } | |
52 | |||
53 | ////////////////////////////////////////////////////////////////////// | ||
54 | ✗ | int Parameter::setValue(const char* src, size_t offset, size_t count) const | |
55 | { | ||
56 | ✗ | ost::SemaphoreLock lock(mutex); | |
57 | |||
58 | ✗ | return main->setParameter(this, offset, count, src, &mtime); | |
59 | } | ||
60 | |||
61 | ////////////////////////////////////////////////////////////////////// | ||
62 | ✗ | void Parameter::getValue(const PdServ::Session*, | |
63 | void* valueBuf, struct timespec *time) const | ||
64 | { | ||
65 | ✗ | ost::SemaphoreLock lock(mutex); | |
66 | |||
67 | ✗ | std::copy(this->valueBuf, this->valueBuf + memSize, | |
68 | reinterpret_cast<char*>(valueBuf)); | ||
69 | ✗ | if (time) | |
70 | ✗ | *time = mtime; | |
71 | } | ||
72 | |||
73 | ////////////////////////////////////////////////////////////////////// | ||
74 | ✗ | int Parameter::copy(struct pdtask *, const struct pdvariable *, | |
75 | void *buf, const void *src, size_t len, void *) | ||
76 | { | ||
77 | // cout << __PRETTY_FUNCTION__ << checkOnly << endl; | ||
78 | ✗ | std::copy( reinterpret_cast<const char*>(src), | |
79 | reinterpret_cast<const char*>(src)+len, | ||
80 | reinterpret_cast<char*>(buf)); | ||
81 | |||
82 | ✗ | return 0; | |
83 | 3 | } | |
84 |