Directory: | ./ |
---|---|
File: | pdserv/src/lib/Parameter.cpp |
Date: | 2025-08-17 04:10:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 16 | 16 | 100.0% |
Branches: | 2 | 4 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /***************************************************************************** | ||
2 | * | ||
3 | * Copyright 2010 Richard Hacker (lerichi at gmx dot net) | ||
4 | * | ||
5 | * This file is part of the pdserv library. | ||
6 | * | ||
7 | * The pdserv library is free software: you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU Lesser General Public License as published | ||
9 | * by the Free Software Foundation, either version 3 of the License, or (at | ||
10 | * your option) any later version. | ||
11 | * | ||
12 | * The pdserv library is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | ||
15 | * License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public License | ||
18 | * along with the pdserv library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <algorithm> | ||
23 | #include <cerrno> | ||
24 | |||
25 | #include "Parameter.h" | ||
26 | #include "Main.h" | ||
27 | |||
28 | ////////////////////////////////////////////////////////////////////// | ||
29 | 942 | Parameter::Parameter( | |
30 | Main* main, | ||
31 | void *addr, | ||
32 | const char *path, | ||
33 | unsigned int mode, | ||
34 | const PdServ::DataType& dtype, | ||
35 | size_t ndims, | ||
36 | 942 | const size_t *dim): | |
37 | PdServ::ProcessParameter(main, | ||
38 | 942 | &shmAddr, &mtime, path, mode, dtype, ndims, dim), | |
39 | addr(reinterpret_cast<char*>(addr)), | ||
40 |
2/4✓ Branch 5 taken 942 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 942 times.
✗ Branch 10 not taken.
|
1884 | main(main) |
41 | { | ||
42 | 942 | write_cb = copy; | |
43 | |||
44 | 942 | mtime.tv_sec = 0; | |
45 | 942 | mtime.tv_nsec = 0; | |
46 | 942 | } | |
47 | |||
48 | ////////////////////////////////////////////////////////////////////// | ||
49 | 43 | int Parameter::setValue( | |
50 | size_t offset, size_t count, struct timespec* mtime) const | ||
51 | { | ||
52 | 43 | static_cast<const PdServ::Main*>(main)->gettime(mtime); | |
53 | |||
54 | 129 | int rv = write_cb( | |
55 | reinterpret_cast<const struct pdvariable*>( | ||
56 | static_cast<const Variable*>(this)), | ||
57 | 129 | addr + offset, shmAddr + offset, count, mtime, priv_data); | |
58 | |||
59 | 43 | return rv; | |
60 | } | ||
61 | |||
62 | ////////////////////////////////////////////////////////////////////// | ||
63 | 43 | int Parameter::copy(const struct pdvariable *, | |
64 | void *buf, const void *src, size_t len, | ||
65 | struct timespec*, void *) | ||
66 | { | ||
67 | // cout << __PRETTY_FUNCTION__ << checkOnly << endl; | ||
68 | 43 | std::copy( reinterpret_cast<const char*>(src), | |
69 | reinterpret_cast<const char*>(src)+len, | ||
70 | reinterpret_cast<char*>(buf)); | ||
71 | |||
72 | 43 | return 0; | |
73 | } | ||
74 |