Open Lighting Architecture  0.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
34 #include <ola/rdm/RDMResponseCodes.h>
35 
36 #include <map>
37 
38 namespace ola {
39 namespace rdm {
40 
59 template <class Target>
60 class ResponderOps {
61  public:
68  typedef const 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 {
109  RDMHandler get_handler;
110  RDMHandler set_handler;
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_