Improved to "half-way usable" (version 0.5)
[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 "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);
45
46   unsigned int getID();
47
48   PIRMakeName getMake();
49   const char *getKeysetName();
50
51   void moveProtocolToThread(
52     QThread &thread);
53
54   void populateDeviceTypes(
55     PIRKeysetWidgetItem *kwi);
56
57 protected:
58   void addControlledDevice(
59     PIRMakeName make,
60     const char *model,
61     PIRDeviceTypeName type);
62
63   void addDeviceType(
64     PIRDeviceTypeName n);
65
66   void addKey(
67     const char *name,
68     PIRKeyName key,
69     unsigned long data,
70     unsigned int size);
71
72   // Special helper methods for SIRC keys:
73   void addSIRC12Key(
74     const char *name,
75     PIRKeyName key,
76     unsigned int addressData,
77     unsigned int commandData);
78
79   void addSIRC15Key(
80     const char *name,
81     PIRKeyName key,
82     unsigned int addressData,
83     unsigned int commandData);
84
85   void addSIRC20Key(
86     const char *name,
87     PIRKeyName key,
88     unsigned int secondaryAddressData,
89     unsigned int primaryAddressData,
90     unsigned int commandData);
91
92   // Helper method for Sharp keys:
93   void addSharpKey(
94     const char *name,
95     PIRKeyName key,
96     unsigned int addressData,
97     unsigned int commandData);
98
99   void setPreData(
100     unsigned long data,
101     unsigned int bits);
102
103   void setPostData(
104     unsigned long data,
105     unsigned int bits);
106
107   KeyCollection keys;
108
109   DeviceCollection controlledDevices;
110
111   PIRProtocol *threadableProtocol;
112
113   void setKeysetName(
114     const char *name);
115
116 private:
117   const char *keysetName;
118   PIRMakeName make;
119   PIRDeviceTypeCollection deviceTypes;
120
121   unsigned int id;
122 };
123
124
125 #endif // PIRKEYSETMETADATA_H