Open Lighting Architecture
 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 
31 using std::string;
32 
33 
35  public:
36  CommandPrinter(std::ostream *output,
37  class PidStoreHelper *pid_helper);
38  ~CommandPrinter() {}
39 
40  // New style overloaded methods.
41  void Print(const class RDMCommand *command,
42  bool summarize = false,
43  bool unpack_param_data = true);
44  void Print(const class RDMRequest *request,
45  bool summarize = false,
46  bool unpack_param_data = true);
47  void Print(const class RDMResponse *response,
48  bool summarize = false,
49  bool unpack_param_data = true);
50  void Print(const class RDMDiscoveryRequest *request,
51  bool summarize = false,
52  bool unpack_param_data = true);
53  void Print(const class RDMDiscoveryResponse *response,
54  bool summarize = false,
55  bool unpack_param_data = true);
56 
57  // Deprecated
58  void DisplayRequest(const class RDMRequest *request,
59  bool summarize = false,
60  bool unpack_param_data = true);
61  void DisplayResponse(const class RDMResponse *response,
62  bool summarize = false,
63  bool unpack_param_data = true);
64 
65  void DisplayDiscoveryRequest(const class RDMDiscoveryRequest *request,
66  bool summarize = false,
67  bool unpack_param_data = true);
68 
69  void DisplayDiscoveryResponse(const class RDMDiscoveryResponse *response,
70  bool summarize = false,
71  bool unpack_param_data = true);
72 
73  private:
74  std::ostream *m_output;
75  PidStoreHelper *m_pid_helper;
76 
77  void AppendUIDsAndType(const class RDMCommand *command,
78  const char *message_type);
79  void AppendPortId(const class RDMRequest *request);
80  void AppendVerboseUIDs(const class RDMCommand *command);
81  void AppendPidString(const class RDMCommand *command,
82  const class PidDescriptor *pid_descriptor);
83  void AppendResponseType(const class RDMResponse *response);
84  void AppendVerboseResponseType(const class RDMResponse *response);
85  void AppendHeaderFields(const class RDMCommand *command,
86  const char *command_class);
87 
88  void DisplayParamData(
89  const class PidDescriptor *pid_descriptor,
90  bool unpack_param_data,
91  bool is_request,
92  bool is_get,
93  const uint8_t *param_data,
94  unsigned int param_length);
95  bool GetNackReason(const class RDMCommand *command, uint16_t *reason);
96 };
97 } // namespace rdm
98 } // namespace ola
99 #endif // INCLUDE_OLA_RDM_COMMANDPRINTER_H_