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