Directory: | ./ |
---|---|
File: | pdserv/src/lib/Parameter.cpp |
Date: | 2024-12-15 04:08:34 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 16 | 16 | 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 <algorithm> | ||
25 | #include <cerrno> | ||
26 | |||
27 | #include "Parameter.h" | ||
28 | #include "Main.h" | ||
29 | |||
30 | ////////////////////////////////////////////////////////////////////// | ||
31 | 942 | Parameter::Parameter( | |
32 | Main* main, | ||
33 | void *addr, | ||
34 | const char *path, | ||
35 | unsigned int mode, | ||
36 | const PdServ::DataType& dtype, | ||
37 | size_t ndims, | ||
38 | 942 | const size_t *dim): | |
39 | PdServ::ProcessParameter(main, | ||
40 | 942 | &shmAddr, &mtime, path, mode, dtype, ndims, dim), | |
41 | addr(reinterpret_cast<char*>(addr)), | ||
42 |
2/4✓ Branch 5 taken 942 times.
✗ Branch 6 not taken.
✓ Branch 9 taken 942 times.
✗ Branch 10 not taken.
|
1884 | main(main) |
43 | { | ||
44 | 942 | write_cb = copy; | |
45 | |||
46 | 942 | mtime.tv_sec = 0; | |
47 | 942 | mtime.tv_nsec = 0; | |
48 | 942 | } | |
49 | |||
50 | ////////////////////////////////////////////////////////////////////// | ||
51 | 43 | int Parameter::setValue( | |
52 | size_t offset, size_t count, struct timespec* mtime) const | ||
53 | { | ||
54 | 43 | static_cast<const PdServ::Main*>(main)->gettime(mtime); | |
55 | |||
56 | 129 | int rv = write_cb( | |
57 | reinterpret_cast<const struct pdvariable*>( | ||
58 | static_cast<const Variable*>(this)), | ||
59 | 129 | addr + offset, shmAddr + offset, count, mtime, priv_data); | |
60 | |||
61 | 43 | return rv; | |
62 | } | ||
63 | |||
64 | ////////////////////////////////////////////////////////////////////// | ||
65 | 43 | int Parameter::copy(const struct pdvariable *, | |
66 | void *buf, const void *src, size_t len, | ||
67 | struct timespec*, void *) | ||
68 | { | ||
69 | // cout << __PRETTY_FUNCTION__ << checkOnly << endl; | ||
70 | 43 | std::copy( reinterpret_cast<const char*>(src), | |
71 | reinterpret_cast<const char*>(src)+len, | ||
72 | reinterpret_cast<char*>(buf)); | ||
73 | |||
74 | 43 | return 0; | |
75 | } | ||
76 |