Directory: | ./ |
---|---|
File: | pdserv/src/ProcessParameter.cpp |
Date: | 2025-08-17 04:10:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 17 | 17 | 100.0% |
Branches: | 4 | 8 | 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 | |||
24 | #include "ProcessParameter.h" | ||
25 | #include "Main.h" | ||
26 | |||
27 | using namespace PdServ; | ||
28 | |||
29 | ////////////////////////////////////////////////////////////////////// | ||
30 | 942 | ProcessParameter::ProcessParameter( | |
31 | Main* main, | ||
32 | const char* const* addr, | ||
33 | const struct timespec* mtime, | ||
34 | const std::string& path, | ||
35 | unsigned int mode, | ||
36 | const PdServ::DataType& dtype, | ||
37 | size_t ndims, | ||
38 | 942 | const size_t *dim): | |
39 | Parameter(path, mode, dtype, ndims, dim), | ||
40 |
1/2✓ Branch 14 taken 942 times.
✗ Branch 15 not taken.
|
942 | main(main), valueBuf(addr), mtime(mtime) |
41 | { | ||
42 | 942 | } | |
43 | |||
44 | ////////////////////////////////////////////////////////////////////// | ||
45 | 43 | int ProcessParameter::setValue(const PdServ::Session* session, | |
46 | const char *buf, size_t offset, size_t count) const | ||
47 | { | ||
48 | 86 | pthread::WriteLock lock(mutex); | |
49 | |||
50 |
1/2✓ Branch 16 taken 43 times.
✗ Branch 17 not taken.
|
86 | return main->setValue(this, session, buf, offset, count); |
51 | } | ||
52 | |||
53 | ////////////////////////////////////////////////////////////////////// | ||
54 | 109 | int ProcessParameter::getValue(const PdServ::Session* /*session*/, | |
55 | void* buf, struct timespec *time) const | ||
56 | { | ||
57 | 218 | pthread::ReadLock lock(mutex); | |
58 | |||
59 |
1/2✓ Branch 12 taken 109 times.
✗ Branch 13 not taken.
|
109 | std::copy(*valueBuf, *valueBuf + memSize, reinterpret_cast<char*>(buf)); |
60 |
1/2✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
|
109 | if (time) |
61 | 109 | *time = *mtime; | |
62 | |||
63 | 218 | return 0; | |
64 | } | ||
65 | |||
66 | ////////////////////////////////////////////////////////////////////// | ||
67 | 43 | void ProcessParameter::print( | |
68 | std::ostream& os, size_t offset, size_t count) const | ||
69 | { | ||
70 | 172 | dtype.print(os, | |
71 | 129 | *valueBuf, *valueBuf + offset, *valueBuf + offset + count); | |
72 | 43 | } | |
73 |