Open Lighting Architecture  0.9.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PidStoreHelper.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  * PidStoreHelper.h
17  * Provides helper methods for loading / accessing the pid store, and dealing
18  * with pids.
19  * Copyright (C) 2011 Simon Newton
20  */
21 
31 #ifndef INCLUDE_OLA_RDM_PIDSTOREHELPER_H_
32 #define INCLUDE_OLA_RDM_PIDSTOREHELPER_H_
33 
34 #include <stdint.h>
35 #include <ola/messaging/Descriptor.h>
36 #include <ola/messaging/SchemaPrinter.h>
39 #include <ola/rdm/PidStore.h>
42 
43 #include <string>
44 #include <vector>
45 
46 
47 namespace ola {
48 namespace rdm {
49 
51  public:
52  explicit PidStoreHelper(const std::string &pid_location,
53  unsigned int initial_indent = 0);
55 
56  bool Init();
57 
59  const std::string &pid_name,
60  uint16_t manufacturer_id) const;
62  uint16_t param_id,
63  uint16_t manufacturer_id) const;
64 
66  const ola::messaging::Descriptor *descriptor,
67  const std::vector<std::string> &inputs);
68 
69  const uint8_t *SerializeMessage(const ola::messaging::Message *message,
70  unsigned int *data_length);
71 
73  const ola::messaging::Descriptor *descriptor,
74  const uint8_t *data,
75  unsigned int data_length);
76 
77  const std::string MessageToString(const ola::messaging::Message *message);
78 
79  const std::string PrettyPrintMessage(
80  uint16_t manufacturer_id,
81  bool is_set,
82  uint16_t pid,
83  const ola::messaging::Message *message);
84 
85  const std::string SchemaAsString(
86  const ola::messaging::Descriptor *descriptor);
87 
88  void SupportedPids(uint16_t manufacturer_id,
89  std::vector<std::string> *pid_names) const;
90 
91  void SupportedPids(
92  uint16_t manufacturer_id,
93  std::vector<const PidDescriptor*> *descriptors) const;
94 
95  private:
96  const std::string m_pid_location;
97  const RootPidStore *m_root_store;
98  StringMessageBuilder m_string_builder;
99  MessageSerializer m_serializer;
100  MessageDeserializer m_deserializer;
101  RDMMessagePrinter m_message_printer;
102  ola::messaging::SchemaPrinter m_schema_printer;
103 };
104 } // namespace rdm
105 } // namespace ola
106 #endif // INCLUDE_OLA_RDM_PIDSTOREHELPER_H_