Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResponderPersonality.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  * 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 <ola/Logging.h>
25 #include <ola/base/Macro.h>
27 
28 #include <stdint.h>
29 #include <string>
30 #include <vector>
31 
32 namespace ola {
33 namespace rdm {
34 
38 class Personality {
39  public:
40  Personality(uint16_t footprint, const std::string &description);
41  Personality(uint16_t footprint, const std::string &description,
42  const SlotDataCollection &slot_data);
43 
44  uint16_t Footprint() const { return m_footprint; }
45  std::string Description() const { return m_description; }
46 
47  const SlotDataCollection* GetSlotData() const { return &m_slot_data; }
48 
49  const SlotData *GetSlotData(uint16_t slot_number) const {
50  return m_slot_data.Lookup(slot_number);
51  }
52 
53  private:
54  uint16_t m_footprint;
55  std::string m_description;
56  SlotDataCollection m_slot_data;
57 };
58 
59 
66  public:
67  typedef std::vector<Personality> PersonalityList;
68 
69  explicit PersonalityCollection(const PersonalityList &personalities);
70  virtual ~PersonalityCollection();
71 
72  uint8_t PersonalityCount() const;
73 
74  const Personality *Lookup(uint8_t personality) const;
75 
76  protected:
78 
79  private:
80  const PersonalityList m_personalities;
81 
82  DISALLOW_COPY_AND_ASSIGN(PersonalityCollection);
83 };
84 
85 
90  public:
91  PersonalityManager() : m_active_personality(0) {}
92  explicit PersonalityManager(const PersonalityCollection *personalities);
93 
94  uint8_t PersonalityCount() const;
95  bool SetActivePersonality(uint8_t personality);
96  uint8_t ActivePersonalityNumber() const { return m_active_personality; }
97  const Personality *ActivePersonality() const;
98  uint16_t ActivePersonalityFootprint() const;
99  std::string ActivePersonalityDescription() const;
100  const Personality *Lookup(uint8_t personality) const;
101 
102  private:
103  const PersonalityCollection *m_personalities;
104  uint8_t m_active_personality;
105 
106  DISALLOW_COPY_AND_ASSIGN(PersonalityManager);
107 };
108 } // namespace rdm
109 } // namespace ola
110 #endif // INCLUDE_OLA_RDM_RESPONDERPERSONALITY_H_