Open Lighting Architecture  Latest Git
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:
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 
84 };
85 
86 
91  public:
92  PersonalityManager() : m_active_personality(0) {}
93  explicit PersonalityManager(const PersonalityCollection *personalities);
94 
95  uint8_t PersonalityCount() const;
96  bool SetActivePersonality(uint8_t personality);
97  uint8_t ActivePersonalityNumber() const { return m_active_personality; }
98  const Personality *ActivePersonality() const;
99  uint16_t ActivePersonalityFootprint() const;
100  std::string ActivePersonalityDescription() const;
101  const Personality *Lookup(uint8_t personality) const;
102 
103  private:
104  const PersonalityCollection *m_personalities;
105  uint8_t m_active_personality;
106 
108 };
109 } // namespace rdm
110 } // namespace ola
111 #endif // INCLUDE_OLA_RDM_RESPONDERPERSONALITY_H_
Definition: ResponderPersonality.h:65
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Creates dummy copy constructor and assignment operator declarations.
Definition: Macro.h:44
Personality(uint16_t footprint, const std::string &description)
Definition: ResponderPersonality.cpp:40
const SlotData * Lookup(uint16_t slot) const
Lookup slot data based on the slot index.
Definition: ResponderSlotData.cpp:99
Holds information about a set of slots.
Definition: ResponderSlotData.h:151
Definition: ResponderPersonality.h:90
Helper macros.
Holds the information about DMX slots.
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Header file for OLA Logging.
Holds information about a single DMX slot.
Definition: ResponderSlotData.h:44
std::vector< Personality > PersonalityList
Definition: ResponderPersonality.h:68
Definition: ResponderPersonality.h:38