Open Lighting Architecture  Latest Git
ResponderOps.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * ResponderOps.h
17  * A framework for building RDM responders.
18  * Copyright (C) 2013 Simon Newton
19  */
20 
29 #ifndef INCLUDE_OLA_RDM_RESPONDEROPS_H_
30 #define INCLUDE_OLA_RDM_RESPONDEROPS_H_
31 
32 #include <ola/rdm/RDMCommand.h>
35 
36 #include <map>
37 
38 namespace ola {
39 namespace rdm {
40 
59 template <class Target>
60 class ResponderOps {
61  public:
68  typedef RDMResponse *(Target::*RDMHandler)(const RDMRequest *request);
69 
76  struct ParamHandler {
77  uint16_t pid;
80  };
81 
90  explicit ResponderOps(const ParamHandler param_handlers[],
91  bool include_required_pids = false);
92 
101  void HandleRDMRequest(Target *target,
102  const UID &target_uid,
103  uint16_t sub_device,
104  const RDMRequest *request,
105  RDMCallback *on_complete);
106 
107  private:
108  struct InternalParamHandler {
111  };
112  typedef std::map<uint16_t, InternalParamHandler> RDMHandlers;
113 
114  bool m_include_required_pids;
115  RDMHandlers m_handlers;
116 
117  RDMResponse *HandleSupportedParams(const RDMRequest *request);
118 };
119 
120 } // namespace rdm
121 } // namespace ola
122 #include <ola/rdm/ResponderOpsPrivate.h> // NOLINT(build/include_order)
123 #endif // INCLUDE_OLA_RDM_RESPONDEROPS_H_
Definitions and Interfaces to implement an RDMController that sends a single message at a time...
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition: RDMCommand.h:457
RDMResponse *(Target::* RDMHandler)(const RDMRequest *request)
The member function to call on the target to handle a request.
Definition: ResponderOps.h:68
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition: RDMCommand.h:234
RDMHandler set_handler
Definition: ResponderOps.h:79
Private helper functions for building RDM responders.
the structure that defines the behaviour for a specific PID.o
Definition: ResponderOps.h:76
Enums representing the states of a response. This is generated from the proto file.
A class which dispatches RDM requests to registered PID handlers.
Definition: ResponderOps.h:60
uint16_t pid
Definition: ResponderOps.h:77
ResponderOps(const ParamHandler param_handlers[], bool include_required_pids=false)
Construct a new ResponderOps object.
Definition: ResponderOpsPrivate.h:49
void HandleRDMRequest(Target *target, const UID &target_uid, uint16_t sub_device, const RDMRequest *request, RDMCallback *on_complete)
Handle a RDMRequest.
Definition: ResponderOpsPrivate.h:68
RDMHandler get_handler
Definition: ResponderOps.h:78
The base class for all 1 argument callbacks.
Definition: Callback.h:982
Represents a RDM UID.
Definition: UID.h:57
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Classes that represent RDM commands.