Open Lighting Architecture: common/rdm/PidStoreLoader.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
PidStoreLoader.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 * PidStoreLoader.h
17 * This class does the heavy lifting for loading the PidStore from a protobuf.
18 * It's separate so that PidStore.h doesn't have to include the Pids.pb.h
19 * header.
20 * Copyright (C) 2011 Simon Newton
21 */
22
23#ifndef COMMON_RDM_PIDSTORELOADER_H_
24#define COMMON_RDM_PIDSTORELOADER_H_
25
26#include <ola/messaging/Descriptor.h>
27#include <ola/rdm/PidStore.h>
28#include <map>
29#include <istream>
30#include <string>
31#include <vector>
32#include "common/rdm/DescriptorConsistencyChecker.h"
33#include "common/rdm/Pids.pb.h"
34
35namespace ola {
36namespace rdm {
37
41 class PidStoreLoader {
42 public:
43 PidStoreLoader() {}
44
52 const RootPidStore *LoadFromFile(const std::string &file,
53 bool validate = true);
54
64 const RootPidStore *LoadFromDirectory(const std::string &directory,
65 bool validate = true);
66
74 const RootPidStore *LoadFromStream(std::istream *data,
75 bool validate = true);
76
77 private:
78 typedef std::map<uint16_t, const PidDescriptor*> PidMap;
79 typedef std::map<uint16_t, PidMap*> ManufacturerMap;
80
81 DescriptorConsistencyChecker m_checker;
82
83 bool ReadFile(const std::string &file_path,
84 ola::rdm::pid::PidStore *proto);
85
86 const RootPidStore *BuildStore(const ola::rdm::pid::PidStore &store_pb,
87 const ola::rdm::pid::PidStore &override_pb,
88 bool validate);
89
90 bool LoadFromProto(ManufacturerMap *pid_data,
91 const ola::rdm::pid::PidStore &proto,
92 bool validate);
93
94 template <typename pb_object>
95 bool GetPidList(PidMap *pid_map,
96 const pb_object &store,
97 bool validate,
98 bool limit_pid_values);
99
100 PidDescriptor *PidToDescriptor(const ola::rdm::pid::Pid &pid,
101 bool validate);
102 const ola::messaging::Descriptor* FrameFormatToDescriptor(
103 const ola::rdm::pid::FrameFormat &format,
104 bool validate);
105 const ola::messaging::FieldDescriptor *FieldToFieldDescriptor(
106 const ola::rdm::pid::Field &field);
107
108 template <typename descriptor_class>
109 const ola::messaging::FieldDescriptor *IntegerFieldToFieldDescriptor(
110 const ola::rdm::pid::Field &field);
111
112 const ola::messaging::FieldDescriptor *StringFieldToFieldDescriptor(
113 const ola::rdm::pid::Field &field);
114 const ola::messaging::FieldDescriptor *GroupFieldToFieldDescriptor(
115 const ola::rdm::pid::Field &field);
116 PidDescriptor::sub_device_validator ConvertSubDeviceValidator(
117 const ola::rdm::pid::SubDeviceRange &sub_device_range);
118
119 void FreeManufacturerMap(ManufacturerMap *data);
120
121 static const char OVERRIDE_FILE_NAME[];
122 static const uint16_t ESTA_MANUFACTURER_ID;
123 static const uint16_t MANUFACTURER_PID_MIN;
124 static const uint16_t MANUFACTURER_PID_MAX;
125
126 PidStoreLoader(const PidStoreLoader &) = delete;
127 const PidStoreLoader &operator=(const PidStoreLoader &) = delete;
128};
129} // namespace rdm
130} // namespace ola
131#endif // COMMON_RDM_PIDSTORELOADER_H_
PidStore.h
Holds information about RDM PIDs.
ola::messaging::Descriptor
Definition Descriptor.h:399
ola::messaging::FieldDescriptor
Definition Descriptor.h:66
ola::rdm::DescriptorConsistencyChecker
Definition DescriptorConsistencyChecker.h:44
ola::rdm::PidDescriptor
Definition PidStore.h:248
ola::rdm::PidStoreLoader::LoadFromDirectory
const RootPidStore * LoadFromDirectory(const std::string &directory, bool validate=true)
Load PID information from a directory, including overrides.
Definition PidStoreLoader.cpp:71
ola::rdm::PidStoreLoader::LoadFromStream
const RootPidStore * LoadFromStream(std::istream *data, bool validate=true)
Load Pid information from a stream.
Definition PidStoreLoader.cpp:129
ola::rdm::PidStoreLoader::LoadFromFile
const RootPidStore * LoadFromFile(const std::string &file, bool validate=true)
Load PID information from a file.
Definition PidStoreLoader.cpp:57
ola::rdm::RootPidStore
The root of the RDM parameter descriptor store.
Definition PidStore.h:68
ola::rdm
PLASA E1.20 Remote Device Management.
Definition AckTimerResponder.cpp:38
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44