Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResponderPersonality.h
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  * ResponderPersonality.h
17  * Manages personalities for a RDM responder.
18  * Copyright (C) 2013 Simon Newton
19  */
20 
21 #ifndef INCLUDE_OLA_RDM_RESPONDERPERSONALITY_H_
22 #define INCLUDE_OLA_RDM_RESPONDERPERSONALITY_H_
23 
24 #include <stdint.h>
25 #include <string>
26 #include <vector>
27 
28 #include "ola/Logging.h"
30 
31 namespace ola {
32 namespace rdm {
33 
34 using std::string;
35 
39 class Personality {
40  public:
41  Personality(uint16_t footprint, const string &description);
42  Personality(uint16_t footprint, const string &description,
43  const SlotDataCollection &slot_data);
44 
45  uint16_t Footprint() const { return m_footprint; }
46  string Description() const { return m_description; }
47 
48  const SlotDataCollection* GetSlotData() const { return &m_slot_data; }
49 
50  const SlotData *GetSlotData(uint16_t slot_number) const {
51  return m_slot_data.Lookup(slot_number);
52  }
53 
54  private:
55  uint16_t m_footprint;
56  string m_description;
57  SlotDataCollection m_slot_data;
58 };
59 
60 
67  public:
68  typedef std::vector<Personality> PersonalityList;
69 
70  explicit PersonalityCollection(const PersonalityList &personalities);
71  virtual ~PersonalityCollection();
72 
73  uint8_t PersonalityCount() const;
74 
75  const Personality *Lookup(uint8_t personality) const;
76 
77  protected:
79 
80  private:
81  const PersonalityList m_personalities;
82 };
83 
84 
89  public:
90  explicit PersonalityManager(const PersonalityCollection *personalities);
91 
92  uint8_t PersonalityCount() const;
93  bool SetActivePersonality(uint8_t personality);
94  uint8_t ActivePersonalityNumber() const { return m_active_personality; }
95  const Personality *ActivePersonality() const;
96  uint16_t ActivePersonalityFootprint() const;
97  const Personality *Lookup(uint8_t personality) const;
98 
99  private:
100  const PersonalityCollection *m_personalities;
101  uint8_t m_active_personality;
102 };
103 } // namespace rdm
104 } // namespace ola
105 #endif // INCLUDE_OLA_RDM_RESPONDERPERSONALITY_H_