Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CommandPrinter.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  * CommandPrinter.h
17  * Write out RDMCommands in a human-readable format.
18  * Copyright (C) 2012 Simon Newton
19  */
20 
21 #ifndef INCLUDE_OLA_RDM_COMMANDPRINTER_H_
22 #define INCLUDE_OLA_RDM_COMMANDPRINTER_H_
23 
24 #include <stdint.h>
25 #include <ola/rdm/RDMEnums.h>
26 #include <string>
27 
28 namespace ola {
29 namespace rdm {
30 
32  public:
33  CommandPrinter(std::ostream *output,
34  class PidStoreHelper *pid_helper);
35  ~CommandPrinter() {}
36 
37  // New style overloaded methods.
38  void Print(const class RDMCommand *command,
39  bool summarize = false,
40  bool unpack_param_data = true);
41  void Print(const class RDMRequest *request,
42  bool summarize = false,
43  bool unpack_param_data = true);
44  void Print(const class RDMResponse *response,
45  bool summarize = false,
46  bool unpack_param_data = true);
47  void Print(const class RDMDiscoveryRequest *request,
48  bool summarize = false,
49  bool unpack_param_data = true);
50  void Print(const class RDMDiscoveryResponse *response,
51  bool summarize = false,
52  bool unpack_param_data = true);
53 
54  // Deprecated
55  void DisplayRequest(const class RDMRequest *request,
56  bool summarize = false,
57  bool unpack_param_data = true);
58  void DisplayResponse(const class RDMResponse *response,
59  bool summarize = false,
60  bool unpack_param_data = true);
61 
62  void DisplayDiscoveryRequest(const class RDMDiscoveryRequest *request,
63  bool summarize = false,
64  bool unpack_param_data = true);
65 
66  void DisplayDiscoveryResponse(const class RDMDiscoveryResponse *response,
67  bool summarize = false,
68  bool unpack_param_data = true);
69 
70  private:
71  std::ostream *m_output;
72  PidStoreHelper *m_pid_helper;
73 
74  void AppendUIDsAndType(const class RDMCommand *command,
75  const char *message_type);
76  void AppendPortId(const class RDMRequest *request);
77  void AppendVerboseUIDs(const class RDMCommand *command);
78  void AppendPidString(const class RDMCommand *command,
79  const class PidDescriptor *pid_descriptor);
80  void AppendResponseType(const class RDMResponse *response);
81  void AppendVerboseResponseType(const class RDMResponse *response);
82  void AppendHeaderFields(const class RDMCommand *command,
83  const char *command_class);
84 
85  void DisplayParamData(
86  const class PidDescriptor *pid_descriptor,
87  bool unpack_param_data,
88  bool is_request,
89  bool is_get,
90  const uint8_t *param_data,
91  unsigned int param_length);
92  bool GetNackReason(const class RDMCommand *command, uint16_t *reason);
93 };
94 } // namespace rdm
95 } // namespace ola
96 #endif // INCLUDE_OLA_RDM_COMMANDPRINTER_H_