Open Lighting Architecture
 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 program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program 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
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; 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 <stdint.h>
33 #include <string>
34 #include <vector>
35 
36 #include "ola/rdm/RDMEnums.h"
37 
38 namespace ola {
39 namespace rdm {
40 
41 using std::string;
42 
46 class SlotData {
47  public:
53  rdm_slot_type SlotType() const { return m_slot_type; }
54 
62  uint16_t SlotIDDefinition() const { return m_slot_id; }
63 
69  uint8_t DefaultSlotValue() const { return m_default_slot_value; }
70 
75  bool HasDescription() const { return m_has_description; }
76 
82  string Description() const { return m_description; }
83 
90  static SlotData PrimarySlot(
91  rdm_slot_definition slot_definition,
92  uint8_t default_slot_value);
93 
101  static SlotData PrimarySlot(
102  rdm_slot_definition slot_definition,
103  uint8_t default_slot_value,
104  const string &description);
105 
114  static SlotData SecondarySlot(
115  rdm_slot_type slot_type,
116  uint16_t primary_slot,
117  uint8_t default_slot_value);
118 
127  static SlotData SecondarySlot(
128  rdm_slot_type slot_type,
129  uint16_t primary_slot,
130  uint8_t default_slot_value,
131  const string &description);
132 
133  private:
134  SlotData(rdm_slot_type slot_type,
135  uint16_t slot_id,
136  uint8_t default_slot_value);
137 
138  SlotData(rdm_slot_type slot_type,
139  uint16_t slot_id,
140  uint8_t default_slot_value,
141  const string &description);
142 
143  rdm_slot_type m_slot_type;
144  uint16_t m_slot_id;
145  uint8_t m_default_slot_value;
146  bool m_has_description;
147  string m_description;
148 };
149 
150 
155  public:
156  typedef std::vector<SlotData> SlotDataList;
157 
158  explicit SlotDataCollection(const SlotDataList &slot_data);
159  SlotDataCollection() {}
160 
165  uint16_t SlotCount() const;
166 
171  const SlotData *Lookup(uint16_t slot) const;
172 
173  private:
174  SlotDataList m_slot_data;
175 };
176 } // namespace rdm
177 } // namespace ola
178 #endif // INCLUDE_OLA_RDM_RESPONDERSLOTDATA_H_