Open Lighting Architecture  Latest Git
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * ClientRDMAPIShim.h
17  * An implementation 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::RDMStatusCode status_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_
RDMStatusCode
RDM Status Codes.
Definition: RDMResponseCodes.h:45
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition: RDMCommand.h:457
Metadata that accompanies RDM Responses.
Definition: ClientTypes.h:332
Types used as return values from the OLA Client.
The callback based C++ client for OLA.
Definition: OlaClient.h:45
The Result object passed to OLA client callbacks.
The interface for an RDM API Implementation.
Definition: ClientRDMAPIShim.h:39
Indicates the result of a OLA API call.
Definition: Result.h:52
Represents the state of a response and/or any error codes.
Definition: RDMAPIImplInterface.h:51
This is the interface for an RDMAPI implementation.
Definition: RDMAPIImplInterface.h:83
A 3 argument callback which deletes itself after it&#39;s run.
Definition: Callback.h:2850
Represents a RDM UID.
Definition: UID.h:57
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
A 2 argument callback which deletes itself after it&#39;s run.
Definition: Callback.h:1907
Classes that represent RDM commands.