Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResponderSlotData.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  * ResponderSlotData.h
17  * Manages slot data for a personality for a RDM responder.
18  * Copyright (C) 2013 Peter Newman
19  */
20 
29 #ifndef INCLUDE_OLA_RDM_RESPONDERSLOTDATA_H_
30 #define INCLUDE_OLA_RDM_RESPONDERSLOTDATA_H_
31 
32 #include <ola/rdm/RDMEnums.h>
33 
34 #include <stdint.h>
35 #include <string>
36 #include <vector>
37 
38 namespace ola {
39 namespace rdm {
40 
44 class SlotData {
45  public:
51  rdm_slot_type SlotType() const { return m_slot_type; }
52 
60  uint16_t SlotIDDefinition() const { return m_slot_id; }
61 
67  uint8_t DefaultSlotValue() const { return m_default_slot_value; }
68 
73  bool HasDescription() const { return m_has_description; }
74 
80  std::string Description() const { return m_description; }
81 
88  static SlotData PrimarySlot(
89  rdm_slot_definition slot_definition,
90  uint8_t default_slot_value);
91 
99  static SlotData PrimarySlot(
100  rdm_slot_definition slot_definition,
101  uint8_t default_slot_value,
102  const std::string &description);
103 
111  static SlotData SecondarySlot(
112  rdm_slot_type slot_type,
113  uint16_t primary_slot,
114  uint8_t default_slot_value);
115 
124  static SlotData SecondarySlot(
125  rdm_slot_type slot_type,
126  uint16_t primary_slot,
127  uint8_t default_slot_value,
128  const std::string &description);
129 
130  private:
131  SlotData(rdm_slot_type slot_type,
132  uint16_t slot_id,
133  uint8_t default_slot_value);
134 
135  SlotData(rdm_slot_type slot_type,
136  uint16_t slot_id,
137  uint8_t default_slot_value,
138  const std::string &description);
139 
140  rdm_slot_type m_slot_type;
141  uint16_t m_slot_id;
142  uint8_t m_default_slot_value;
143  bool m_has_description;
144  std::string m_description;
145 };
146 
147 
152  public:
153  typedef std::vector<SlotData> SlotDataList;
154 
155  explicit SlotDataCollection(const SlotDataList &slot_data);
156  SlotDataCollection() {}
157 
162  uint16_t SlotCount() const;
163 
168  const SlotData *Lookup(uint16_t slot) const;
169 
170  private:
171  SlotDataList m_slot_data;
172 };
173 } // namespace rdm
174 } // namespace ola
175 #endif // INCLUDE_OLA_RDM_RESPONDERSLOTDATA_H_