Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ClientRDMAPIShim.h
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * ClientRDMAPIShim.h
17  * An implemention of RDMAPIImplInterface that uses the OlaClient.
18  * Copyright (C) 2013 Simon Newton
19  */
20 
21 #ifndef INCLUDE_OLA_CLIENT_CLIENTRDMAPISHIM_H_
22 #define INCLUDE_OLA_CLIENT_CLIENTRDMAPISHIM_H_
23 
24 #include <ola/client/ClientTypes.h>
25 #include <ola/client/Result.h>
27 #include <ola/rdm/RDMCommand.h>
28 
29 #include <string>
30 
31 namespace ola {
32 namespace client {
33 
34 class OlaClient;
35 
40  public:
41  explicit ClientRDMAPIShim(OlaClient *client)
42  : m_client(client) {
43  }
44 
45  bool RDMGet(rdm_callback *callback,
46  unsigned int universe,
47  const ola::rdm::UID &uid,
48  uint16_t sub_device,
49  uint16_t pid,
50  const uint8_t *data = NULL,
51  unsigned int data_length = 0);
52 
53  bool RDMGet(rdm_pid_callback *callback,
54  unsigned int universe,
55  const ola::rdm::UID &uid,
56  uint16_t sub_device,
57  uint16_t pid,
58  const uint8_t *data = NULL,
59  unsigned int data_length = 0);
60 
61  bool RDMSet(rdm_callback *callback,
62  unsigned int universe,
63  const ola::rdm::UID &uid,
64  uint16_t sub_device,
65  uint16_t pid,
66  const uint8_t *data = NULL,
67  unsigned int data_length = 0);
68 
69  private:
70  OlaClient *m_client;
71 
72  void HandleResponse(
73  rdm_callback *callback,
74  const Result &result,
75  const RDMMetadata &metadata,
76  const ola::rdm::RDMResponse *response);
77 
78  void HandleResponseWithPid(
79  rdm_pid_callback *callback,
80  const Result &result,
81  const RDMMetadata &metadata,
82  const ola::rdm::RDMResponse *response);
83 
84  void GetResponseStatusAndData(
85  const Result &result,
86  ola::rdm::rdm_response_code response_code,
87  const ola::rdm::RDMResponse *response,
88  rdm::ResponseStatus *response_status,
89  std::string *data);
90 
91  void GetParamFromReply(const std::string &message_type,
92  const ola::rdm::RDMResponse *reply,
93  ola::rdm::ResponseStatus *new_status);
94 };
95 } // namespace client
96 } // namespace ola
97 #endif // INCLUDE_OLA_CLIENT_CLIENTRDMAPISHIM_H_