0673eb66f1ac92a8cad2dd9c2002ea1a4e6fc721
[pierogi] / pirkeysetmetadata.h
1 #ifndef PIRKEYSETMETADATA_H
2 #define PIRKEYSETMETADATA_H
3
4 #include <map>
5 #include <list>
6 //#include <string>
7
8 #include "pirkeynames.h"
9 #include "pirmakenames.h"
10 #include "pirdevicetypenames.h"
11 #include "pirkeysetwidgetitem.h"
12 #include "protocols/pirprotocol.h"
13
14 typedef std::map<PIRKeyName, const char *> KeyCollection;
15
16 class DeviceInfo
17 {
18 public:
19   DeviceInfo(
20     PIRMakeName ma,
21     const char *mo,
22     PIRDeviceTypeName t)
23   : make(ma),
24     model(mo),
25     type(t)
26   {}
27
28   PIRMakeName make;
29   const char *model;
30   PIRDeviceTypeName type;
31 };
32
33 typedef std::list<DeviceInfo> DeviceCollection;
34
35 class PIRKeysetMetaData
36 {
37 public:
38   PIRKeysetMetaData(
39     const char *keysetName,
40     PIRMakeName make,
41     unsigned int index);
42
43   bool hasKey(
44     PIRKeyName name) const;
45
46   unsigned int getID() const;
47
48   PIRMakeName getMake() const;
49
50   const char *getKeysetName() const;
51
52   void moveProtocolToThread(
53     QThread &thread);
54
55   void populateDeviceTypes(
56     PIRKeysetWidgetItem *kwi) const;
57
58 protected:
59   void addControlledDevice(
60     PIRMakeName make,
61     const char *model,
62     PIRDeviceTypeName type);
63
64   void addDeviceType(
65     PIRDeviceTypeName n);
66
67   void addKey(
68     const char *name,
69     PIRKeyName key,
70     unsigned long data,
71     unsigned int size);
72
73   // Special helper methods for SIRC keys:
74   void addSIRC12Key(
75     const char *name,
76     PIRKeyName key,
77     unsigned int addressData,
78     unsigned int commandData);
79
80   void addSIRC15Key(
81     const char *name,
82     PIRKeyName key,
83     unsigned int addressData,
84     unsigned int commandData);
85
86   void addSIRC20Key(
87     const char *name,
88     PIRKeyName key,
89     unsigned int secondaryAddressData,
90     unsigned int primaryAddressData,
91     unsigned int commandData);
92
93   // Helper method for Sharp keys:
94   void addSharpKey(
95     const char *name,
96     PIRKeyName key,
97     unsigned int addressData,
98     unsigned int commandData);
99
100   void addNECKey(
101     const char *name,
102     PIRKeyName key,
103     unsigned int addressData,
104     unsigned int commandData);
105
106   void addPioneerKey(
107     const char *name,
108     PIRKeyName key,
109     unsigned int addressOne,
110     unsigned int commandOne,
111     unsigned int addressTwo,
112     unsigned int commandTwo);
113
114   void setPreData(
115     unsigned long data,
116     unsigned int bits);
117
118   void setPostData(
119     unsigned long data,
120     unsigned int bits);
121
122   KeyCollection keys;
123
124   DeviceCollection controlledDevices;
125
126   PIRProtocol *threadableProtocol;
127
128   void setKeysetName(
129     const char *name);
130
131 private:
132   const char *keysetName;
133   PIRMakeName make;
134   PIRDeviceTypeCollection deviceTypes;
135
136   unsigned int id;
137 };
138
139
140 #endif // PIRKEYSETMETADATA_H