Adding stub and skeleton for Lifxtest and LifxLightBulb; Creating build flow for...
[iot2.git] / benchmarks / drivers / Cpp / LifxLightBulb / LightBulb_Skeleton.hpp
1 #ifndef _LIGHTBULB_SKELETON_HPP__
2 #define _LIGHTBULB_SKELETON_HPP__
3 #include <iostream>
4 #include "LightBulb.hpp"
5
6 #include <vector>
7 #include <set>
8 #include "IoTRMICall.hpp"
9 #include "IoTRMIObject.hpp"
10
11 using namespace std;
12
13 class LightBulb_Skeleton : public LightBulb
14 {
15         private:
16
17         LightBulb *mainObj;
18         vector<int> ports;
19         string callbackAddress;
20         IoTRMIObject *rmiObj;
21
22         const static int object0Id = 0; //LightBulbSmart
23         static set<int> set0Allowed;
24         
25
26         public:
27
28         LightBulb_Skeleton(LightBulb *_mainObj, string _callbackAddress, int _port) {
29                 bool _bResult = false;
30                 mainObj = _mainObj;
31                 callbackAddress = _callbackAddress;
32                 rmiObj = new IoTRMIObject(_port, &_bResult);
33                 ___waitRequestInvokeMethod();
34         }
35
36         ~LightBulb_Skeleton() {
37                 if (rmiObj != NULL) {
38                         delete rmiObj;
39                         rmiObj = NULL;
40                 }
41         }
42         
43         void init() {
44                 mainObj->init();
45         }
46
47         void turnOff() {
48                 mainObj->turnOff();
49         }
50
51         void turnOn() {
52                 mainObj->turnOn();
53         }
54
55         bool getState() {
56                 return mainObj->getState();
57         }
58
59         void setColor(double _hue, double _saturation, double _brightness) {
60                 mainObj->setColor(_hue, _saturation, _brightness);
61         }
62
63         void setTemperature(int _temperature) {
64                 mainObj->setTemperature(_temperature);
65         }
66
67         double getBrightness() {
68                 return mainObj->getBrightness();
69         }
70
71         double getHue() {
72                 return mainObj->getHue();
73         }
74
75         double getSaturation() {
76                 return mainObj->getSaturation();
77         }
78
79         int getTemperature() {
80                 return mainObj->getTemperature();
81         }
82
83         double getBrightnessRangeLowerBound() {
84                 return mainObj->getBrightnessRangeLowerBound();
85         }
86
87         double getBrightnessRangeUpperBound() {
88                 return mainObj->getBrightnessRangeUpperBound();
89         }
90
91         double getHueRangeLowerBound() {
92                 return mainObj->getHueRangeLowerBound();
93         }
94
95         double getHueRangeUpperBound() {
96                 return mainObj->getHueRangeUpperBound();
97         }
98
99         double getSaturationRangeLowerBound() {
100                 return mainObj->getSaturationRangeLowerBound();
101         }
102
103         double getSaturationRangeUpperBound() {
104                 return mainObj->getSaturationRangeUpperBound();
105         }
106
107         int getTemperatureRangeLowerBound() {
108                 return mainObj->getTemperatureRangeLowerBound();
109         }
110
111         int getTemperatureRangeUpperBound() {
112                 return mainObj->getTemperatureRangeUpperBound();
113         }
114
115         void ___init() {
116                 string paramCls[] = {  };
117                 int numParam = 0;
118                 void* paramObj[] = {  };
119                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
120                 init();
121         }
122
123         void ___turnOff() {
124                 string paramCls[] = {  };
125                 int numParam = 0;
126                 void* paramObj[] = {  };
127                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
128                 turnOff();
129         }
130
131         void ___turnOn() {
132                 string paramCls[] = {  };
133                 int numParam = 0;
134                 void* paramObj[] = {  };
135                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
136                 turnOn();
137         }
138
139         void ___getState() {
140                 string paramCls[] = {  };
141                 int numParam = 0;
142                 void* paramObj[] = {  };
143                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
144                 bool retVal = getState();
145                 void* retObj = &retVal;
146                 rmiObj->sendReturnObj(retObj, "boolean");
147         }
148
149         void ___setColor() {
150                 string paramCls[] = { "double", "double", "double" };
151                 int numParam = 3;
152                 double _hue;
153                 double _saturation;
154                 double _brightness;
155                 void* paramObj[] = { &_hue, &_saturation, &_brightness };
156                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
157                 setColor(_hue, _saturation, _brightness);
158         }
159
160         void ___setTemperature() {
161                 string paramCls[] = { "int" };
162                 int numParam = 1;
163                 int _temperature;
164                 void* paramObj[] = { &_temperature };
165                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
166                 setTemperature(_temperature);
167         }
168
169         void ___getBrightness() {
170                 string paramCls[] = {  };
171                 int numParam = 0;
172                 void* paramObj[] = {  };
173                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
174                 double retVal = getBrightness();
175                 void* retObj = &retVal;
176                 rmiObj->sendReturnObj(retObj, "double");
177         }
178
179         void ___getHue() {
180                 string paramCls[] = {  };
181                 int numParam = 0;
182                 void* paramObj[] = {  };
183                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
184                 double retVal = getHue();
185                 void* retObj = &retVal;
186                 rmiObj->sendReturnObj(retObj, "double");
187         }
188
189         void ___getSaturation() {
190                 string paramCls[] = {  };
191                 int numParam = 0;
192                 void* paramObj[] = {  };
193                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
194                 double retVal = getSaturation();
195                 void* retObj = &retVal;
196                 rmiObj->sendReturnObj(retObj, "double");
197         }
198
199         void ___getTemperature() {
200                 string paramCls[] = {  };
201                 int numParam = 0;
202                 void* paramObj[] = {  };
203                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
204                 int retVal = getTemperature();
205                 void* retObj = &retVal;
206                 rmiObj->sendReturnObj(retObj, "int");
207         }
208
209         void ___getBrightnessRangeLowerBound() {
210                 string paramCls[] = {  };
211                 int numParam = 0;
212                 void* paramObj[] = {  };
213                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
214                 double retVal = getBrightnessRangeLowerBound();
215                 void* retObj = &retVal;
216                 rmiObj->sendReturnObj(retObj, "double");
217         }
218
219         void ___getBrightnessRangeUpperBound() {
220                 string paramCls[] = {  };
221                 int numParam = 0;
222                 void* paramObj[] = {  };
223                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
224                 double retVal = getBrightnessRangeUpperBound();
225                 void* retObj = &retVal;
226                 rmiObj->sendReturnObj(retObj, "double");
227         }
228
229         void ___getHueRangeLowerBound() {
230                 string paramCls[] = {  };
231                 int numParam = 0;
232                 void* paramObj[] = {  };
233                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
234                 double retVal = getHueRangeLowerBound();
235                 void* retObj = &retVal;
236                 rmiObj->sendReturnObj(retObj, "double");
237         }
238
239         void ___getHueRangeUpperBound() {
240                 string paramCls[] = {  };
241                 int numParam = 0;
242                 void* paramObj[] = {  };
243                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
244                 double retVal = getHueRangeUpperBound();
245                 void* retObj = &retVal;
246                 rmiObj->sendReturnObj(retObj, "double");
247         }
248
249         void ___getSaturationRangeLowerBound() {
250                 string paramCls[] = {  };
251                 int numParam = 0;
252                 void* paramObj[] = {  };
253                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
254                 double retVal = getSaturationRangeLowerBound();
255                 void* retObj = &retVal;
256                 rmiObj->sendReturnObj(retObj, "double");
257         }
258
259         void ___getSaturationRangeUpperBound() {
260                 string paramCls[] = {  };
261                 int numParam = 0;
262                 void* paramObj[] = {  };
263                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
264                 double retVal = getSaturationRangeUpperBound();
265                 void* retObj = &retVal;
266                 rmiObj->sendReturnObj(retObj, "double");
267         }
268
269         void ___getTemperatureRangeLowerBound() {
270                 string paramCls[] = {  };
271                 int numParam = 0;
272                 void* paramObj[] = {  };
273                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
274                 int retVal = getTemperatureRangeLowerBound();
275                 void* retObj = &retVal;
276                 rmiObj->sendReturnObj(retObj, "int");
277         }
278
279         void ___getTemperatureRangeUpperBound() {
280                 string paramCls[] = {  };
281                 int numParam = 0;
282                 void* paramObj[] = {  };
283                 rmiObj->getMethodParams(paramCls, numParam, paramObj);
284                 int retVal = getTemperatureRangeUpperBound();
285                 void* retObj = &retVal;
286                 rmiObj->sendReturnObj(retObj, "int");
287         }
288
289         void ___waitRequestInvokeMethod() {
290                 while (true) {
291                         rmiObj->getMethodBytes();
292                         int _objectId = rmiObj->getObjectId();
293                         int methodId = rmiObj->getMethodId();
294                         if (_objectId == object0Id) {
295                                 if (set0Allowed.find(methodId) == set0Allowed.end()) {
296                                         cerr << "Object with object Id: " << _objectId << "  is not allowed to access method: " << methodId << endl;
297                                         return;
298                                 }
299                         }
300                         else {
301                                 cerr << "Object Id: " << _objectId << " not recognized!" << endl;
302                                 return;
303                         }
304                         switch (methodId) {
305                                 case 0: ___init(); break;
306                                 case 1: ___turnOff(); break;
307                                 case 2: ___turnOn(); break;
308                                 case 3: ___getState(); break;
309                                 case 4: ___setColor(); break;
310                                 case 5: ___setTemperature(); break;
311                                 case 6: ___getBrightness(); break;
312                                 case 7: ___getHue(); break;
313                                 case 8: ___getSaturation(); break;
314                                 case 9: ___getTemperature(); break;
315                                 case 10: ___getBrightnessRangeLowerBound(); break;
316                                 case 11: ___getBrightnessRangeUpperBound(); break;
317                                 case 12: ___getHueRangeLowerBound(); break;
318                                 case 13: ___getHueRangeUpperBound(); break;
319                                 case 14: ___getSaturationRangeLowerBound(); break;
320                                 case 15: ___getSaturationRangeUpperBound(); break;
321                                 case 16: ___getTemperatureRangeLowerBound(); break;
322                                 case 17: ___getTemperatureRangeUpperBound(); break;
323                                 default: 
324                                 cerr << "Method Id " << methodId << " not recognized!" << endl;
325                                 throw exception();
326                         }
327                 }
328         }
329
330 };
331 set<int> LightBulb_Skeleton::set0Allowed { 2, 10, 1, 3, 11, 8, 12, 7, 13, 9, 6, 16, 17, 4, 0, 14, 15, 5 };
332
333 //typedef LightBulb_Skeleton* create_t(LightBulb *_mainObj, string _callbackAddress, int _port);
334 //typedef void destroy_t(LightBulb_Skeleton*);
335 #endif