Open Lighting Architecture
 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 
50 using std::string;
51 using std::vector;
52 
53 
55  public:
56  explicit PidStoreHelper(const string &pid_location,
57  unsigned int initial_indent = 0);
59 
60  bool Init();
61 
63  const string &pid_name,
64  uint16_t manufacturer_id) const;
66  uint16_t param_id,
67  uint16_t manufacturer_id) const;
68 
70  const ola::messaging::Descriptor *descriptor,
71  const vector<string> &inputs);
72 
73  const uint8_t *SerializeMessage(const ola::messaging::Message *message,
74  unsigned int *data_length);
75 
77  const ola::messaging::Descriptor *descriptor,
78  const uint8_t *data,
79  unsigned int data_length);
80 
81  const string MessageToString(const ola::messaging::Message *message);
82 
83  const string PrettyPrintMessage(
84  uint16_t manufacturer_id,
85  bool is_set,
86  uint16_t pid,
87  const ola::messaging::Message *message);
88 
89  const string SchemaAsString(const ola::messaging::Descriptor *descriptor);
90 
91  void SupportedPids(uint16_t manufacturer_id,
92  vector<string> *pid_names) const;
93 
94  void SupportedPids(
95  uint16_t manufacturer_id,
96  vector<const ola::rdm::PidDescriptor*> *descriptors) const;
97 
98  private:
99  const string m_pid_location;
100  const ola::rdm::RootPidStore *m_root_store;
101  ola::rdm::StringMessageBuilder m_string_builder;
102  ola::rdm::MessageSerializer m_serializer;
103  ola::rdm::MessageDeserializer m_deserializer;
104  ola::rdm::RDMMessagePrinter m_message_printer;
105  ola::messaging::SchemaPrinter m_schema_printer;
106 };
107 } // namespace rdm
108 } // namespace ola
109 #endif // INCLUDE_OLA_RDM_PIDSTOREHELPER_H_