29 #ifndef INCLUDE_OLA_RDM_RESPONDEROPSPRIVATE_H_
30 #define INCLUDE_OLA_RDM_RESPONDEROPSPRIVATE_H_
33 #include <ola/network/NetworkUtils.h>
36 #include <ola/rdm/RDMResponseCodes.h>
48 template <
class Target>
50 bool include_required_pids)
51 : m_include_required_pids(include_required_pids) {
53 struct InternalParamHandler placeholder = {NULL, NULL};
54 STLReplace(&m_handlers, PID_SUPPORTED_PARAMETERS, placeholder);
58 struct InternalParamHandler pid_handler = {
67 template <
class Target>
69 const UID &target_uid,
74 std::auto_ptr<const RDMRequest> request(raw_request);
85 OLA_WARN <<
"Received request for the wrong UID, "
86 <<
"expected " << target_uid <<
", got "
106 OLA_WARN <<
"Received broadcast GET command";
112 RDMStatusCode status_code = RDM_COMPLETED_OK;
115 bool for_our_subdevice = request->
SubDevice() == sub_device ||
116 request->
SubDevice() == ALL_RDM_SUBDEVICES;
118 if (!for_our_subdevice) {
124 on_complete->Run(&reply);
130 if (request->
SubDevice() == ALL_RDM_SUBDEVICES &&
135 on_complete->Run(&reply);
139 InternalParamHandler *handler =
STLFind(&m_handlers, request->
ParamId());
146 on_complete->Run(&reply);
154 status_code = RDM_WAS_BROADCAST;
156 if (handler->get_handler) {
157 response = (target->*(handler->get_handler))(request.get());
160 case PID_SUPPORTED_PARAMETERS:
161 response = HandleSupportedParams(request.get());
165 NR_UNSUPPORTED_COMMAND_CLASS);
170 if (handler->set_handler) {
171 response = (target->*(handler->set_handler))(request.get());
173 response =
NackWithReason(request.get(), NR_UNSUPPORTED_COMMAND_CLASS);
183 RDMReply reply(status_code, response);
184 on_complete->Run(&reply);
188 template <
class Target>
194 std::vector<uint16_t> params;
195 params.reserve(m_handlers.size());
196 typename RDMHandlers::const_iterator iter = m_handlers.begin();
197 for (; iter != m_handlers.end(); ++iter) {
198 uint16_t pid = iter->first;
200 if (m_include_required_pids || (
201 pid != PID_SUPPORTED_PARAMETERS &&
202 pid != PID_PARAMETER_DESCRIPTION &&
203 pid != PID_DEVICE_INFO &&
204 pid != PID_SOFTWARE_VERSION_LABEL &&
205 pid != PID_DMX_START_ADDRESS &&
206 pid != PID_IDENTIFY_DEVICE)) {
207 params.push_back(iter->first);
210 sort(params.begin(), params.end());
212 std::vector<uint16_t>::iterator param_iter = params.begin();
213 for (; param_iter != params.end(); ++param_iter) {
214 *param_iter = ola::network::HostToNetwork(*param_iter);
219 reinterpret_cast<uint8_t*>(¶ms[0]),
220 params.size() *
sizeof(uint16_t));
224 #endif // INCLUDE_OLA_RDM_RESPONDEROPSPRIVATE_H_