CVB++ 15.0
decl_device_control.hpp
1#pragma once
2
3#include "../../global.hpp"
4#include "../../string.hpp"
5
6#include "../driver.hpp"
7
8namespace Cvb
9{
10
11 CVB_BEGIN_INLINE_NS
12
13 namespace Driver
14 {
15
17
19 {
20 public:
22
27 template <class PARAM>
28 DeviceControlCommand(PARAM parameter, DeviceControlOperation operation) noexcept
29 : command_(0)
30 {
31 SetOperation(operation);
32 SetParameter(parameter);
33 }
34
36
40 template <class PARAM = std::uint32_t>
41 PARAM Parameter() const noexcept
42 {
43 return static_cast<PARAM>(command_ & ParameterMask);
44 }
45
47
51 template <class PARAM = std::uint32_t>
52 void SetParameter(PARAM parameter) noexcept
53 {
54 command_ = (command_ & OperationMask) | static_cast<std::uint32_t>(parameter);
55 }
56
58
63 {
64 return static_cast<DeviceControlOperation>(command_ & OperationMask);
65 }
66
68
72 void SetOperation(DeviceControlOperation operation) noexcept
73 {
74 command_ = static_cast<std::int32_t>(operation) | (command_ & ParameterMask);
75 }
76
77 explicit operator std::uint32_t() const noexcept
78 {
79 return command_;
80 }
81
82 private:
83 static const std::uint32_t OperationMask = static_cast<std::uint32_t>(CExports::DC_OPERATION_MASK);
84 static const std::uint32_t ParameterMask = static_cast<std::uint32_t>(CExports::DC_PARAM_MASK);
85
86 std::uint32_t command_;
87 };
88
90
91 class DeviceControl
92 {
93 public:
94 explicit DeviceControl(const DevicePtr &device)
95 : parent_(device)
96 {
97 }
98
100
104 DevicePtr Parent() const noexcept
105 {
106 return parent_;
107 }
108
110
117
119
127 template <class IN_TYPE, class OUT_TYPE>
128 void SendCommand(DeviceControlCommand command, IN_TYPE value, OUT_TYPE &result)
129 {
130 std::size_t outputSize = static_cast<int>(sizeof(OUT_TYPE));
131 SendCommand(command, &value, sizeof(IN_TYPE), &result, outputSize);
132 }
133
135
142 template <class OUT_TYPE>
143 void SendCommand(DeviceControlCommand command, OUT_TYPE &result)
144 {
145 std::size_t outputSize = static_cast<int>(sizeof(OUT_TYPE));
146 SendCommand(command, nullptr, 0, &result, outputSize);
147 }
148
150
161 void SendCommand(DeviceControlCommand command, void *inputBuffer, std::size_t inputBufferSize, void *outputBuffer,
162 std::size_t &outputBufferSize);
163
164 private:
165 DevicePtr parent_;
166 };
167
168 } // namespace Driver
169
170 using Driver::DeviceControl;
171 using Driver::DeviceControlCommand;
172
173 CVB_END_INLINE_NS
174
175} // namespace Cvb
DeviceControlCommand(PARAM parameter, DeviceControlOperation operation) noexcept
Creates a command from the given operation and command parameter.
Definition decl_device_control.hpp:28
A specific command to send to the driver.
Definition decl_device_control.hpp:19
void SetParameter(PARAM parameter) noexcept
Sets the parameter part of the command.
Definition decl_device_control.hpp:52
void SetOperation(DeviceControlOperation operation) noexcept
Sets the operation part of the command.
Definition decl_device_control.hpp:72
DeviceControlCommand(PARAM parameter, DeviceControlOperation operation) noexcept
Creates a command from the given operation and command parameter.
Definition decl_device_control.hpp:28
DeviceControlOperation Operation() const noexcept
Gets the operation part of the command.
Definition decl_device_control.hpp:62
PARAM Parameter() const noexcept
Gets the parameter part of the command.
Definition decl_device_control.hpp:41
void SendCommand(DeviceControlCommand command, OUT_TYPE &result)
Sends the given command value to the driver.
Definition decl_device_control.hpp:143
String SendStringCommand(DeviceControlCommand command, const String &value)
Sends the given command value to the driver.
Definition detail_device_control.hpp:19
void SendCommand(DeviceControlCommand command, IN_TYPE value, OUT_TYPE &result)
Sends the given command value to the driver.
Definition decl_device_control.hpp:128
DevicePtr Parent() const noexcept
Gets the parent device of this interface.
Definition decl_device_control.hpp:104
Namespace for driver or device related operations.
Definition decl_composite.hpp:28
DeviceControlOperation
Operation on driver specific parameter.
Definition driver.hpp:526
@ String
String value.
Definition driver.hpp:366
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
std::shared_ptr< Device > DevicePtr
Convenience shared pointer for Device.
Definition global.hpp:98