2 #include "LightBulb_Skeleton.hpp"
6 LightBulb_Skeleton::LightBulb_Skeleton(LightBulb *_mainObj, int _portSend, int _portRecv) {
10 rmiComm = new IoTRMICommServer(_portSend, _portRecv, &_bResult);
11 IoTRMIUtil::mapSkel->insert(make_pair(_mainObj, this));
12 IoTRMIUtil::mapSkelId->insert(make_pair(_mainObj, objectId));
13 rmiComm->registerSkeleton(objectId, &methodReceived);
14 thread th1 (&LightBulb_Skeleton::___waitRequestInvokeMethod, this, this);
18 LightBulb_Skeleton::LightBulb_Skeleton(LightBulb *_mainObj, IoTRMIComm *_rmiComm, int _objectId) {
19 bool _bResult = false;
23 rmiComm->registerSkeleton(objectId, &methodReceived);
26 LightBulb_Skeleton::~LightBulb_Skeleton() {
27 if (rmiComm != NULL) {
33 bool LightBulb_Skeleton::didInitWaitInvoke() {
34 return didAlreadyInitWaitInvoke;
37 void LightBulb_Skeleton::init() {
41 void LightBulb_Skeleton::turnOff() {
45 void LightBulb_Skeleton::turnOn() {
49 bool LightBulb_Skeleton::getState() {
50 return mainObj->getState();
53 void LightBulb_Skeleton::setColor(double _hue, double _saturation, double _brightness) {
54 mainObj->setColor(_hue, _saturation, _brightness);
57 void LightBulb_Skeleton::setTemperature(int _temperature) {
58 mainObj->setTemperature(_temperature);
61 double LightBulb_Skeleton::getBrightness() {
62 return mainObj->getBrightness();
65 double LightBulb_Skeleton::getHue() {
66 return mainObj->getHue();
69 double LightBulb_Skeleton::getSaturation() {
70 return mainObj->getSaturation();
73 int LightBulb_Skeleton::getTemperature() {
74 return mainObj->getTemperature();
77 double LightBulb_Skeleton::getBrightnessRangeLowerBound() {
78 return mainObj->getBrightnessRangeLowerBound();
81 double LightBulb_Skeleton::getBrightnessRangeUpperBound() {
82 return mainObj->getBrightnessRangeUpperBound();
85 double LightBulb_Skeleton::getHueRangeLowerBound() {
86 return mainObj->getHueRangeLowerBound();
89 double LightBulb_Skeleton::getHueRangeUpperBound() {
90 return mainObj->getHueRangeUpperBound();
93 double LightBulb_Skeleton::getSaturationRangeLowerBound() {
94 return mainObj->getSaturationRangeLowerBound();
97 double LightBulb_Skeleton::getSaturationRangeUpperBound() {
98 return mainObj->getSaturationRangeUpperBound();
101 int LightBulb_Skeleton::getTemperatureRangeLowerBound() {
102 return mainObj->getTemperatureRangeLowerBound();
105 int LightBulb_Skeleton::getTemperatureRangeUpperBound() {
106 return mainObj->getTemperatureRangeUpperBound();
109 void LightBulb_Skeleton::___init(LightBulb_Skeleton* skel) {
110 char* localMethodBytes = new char[methodLen];
111 memcpy(localMethodBytes, skel->methodBytes, methodLen);
112 didGetMethodBytes.exchange(true);
113 string paramCls[] = { };
115 void* paramObj[] = { };
116 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
118 delete[] localMethodBytes;
121 void LightBulb_Skeleton::___turnOff(LightBulb_Skeleton* skel) {
122 char* localMethodBytes = new char[methodLen];
123 memcpy(localMethodBytes, skel->methodBytes, methodLen);
124 didGetMethodBytes.exchange(true);
125 string paramCls[] = { };
127 void* paramObj[] = { };
128 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
130 delete[] localMethodBytes;
133 void LightBulb_Skeleton::___turnOn(LightBulb_Skeleton* skel) {
134 char* localMethodBytes = new char[methodLen];
135 memcpy(localMethodBytes, skel->methodBytes, methodLen);
136 didGetMethodBytes.exchange(true);
137 string paramCls[] = { };
139 void* paramObj[] = { };
140 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
142 delete[] localMethodBytes;
145 void LightBulb_Skeleton::___getState(LightBulb_Skeleton* skel) {
146 char* localMethodBytes = new char[methodLen];
147 memcpy(localMethodBytes, skel->methodBytes, methodLen);
148 didGetMethodBytes.exchange(true);
149 string paramCls[] = { };
151 void* paramObj[] = { };
152 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
153 bool retVal = getState();
154 void* retObj = &retVal;
155 rmiComm->sendReturnObj(retObj, "boolean", localMethodBytes);
156 delete[] localMethodBytes;
159 void LightBulb_Skeleton::___setColor(LightBulb_Skeleton* skel) {
160 char* localMethodBytes = new char[methodLen];
161 memcpy(localMethodBytes, skel->methodBytes, methodLen);
162 didGetMethodBytes.exchange(true);
163 string paramCls[] = { "double", "double", "double" };
168 void* paramObj[] = { &_hue, &_saturation, &_brightness };
169 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
170 setColor(_hue, _saturation, _brightness);
171 delete[] localMethodBytes;
174 void LightBulb_Skeleton::___setTemperature(LightBulb_Skeleton* skel) {
175 char* localMethodBytes = new char[methodLen];
176 memcpy(localMethodBytes, skel->methodBytes, methodLen);
177 didGetMethodBytes.exchange(true);
178 string paramCls[] = { "int" };
181 void* paramObj[] = { &_temperature };
182 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
183 setTemperature(_temperature);
184 delete[] localMethodBytes;
187 void LightBulb_Skeleton::___getBrightness(LightBulb_Skeleton* skel) {
188 char* localMethodBytes = new char[methodLen];
189 memcpy(localMethodBytes, skel->methodBytes, methodLen);
190 didGetMethodBytes.exchange(true);
191 string paramCls[] = { };
193 void* paramObj[] = { };
194 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
195 double retVal = getBrightness();
196 void* retObj = &retVal;
197 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
198 delete[] localMethodBytes;
201 void LightBulb_Skeleton::___getHue(LightBulb_Skeleton* skel) {
202 char* localMethodBytes = new char[methodLen];
203 memcpy(localMethodBytes, skel->methodBytes, methodLen);
204 didGetMethodBytes.exchange(true);
205 string paramCls[] = { };
207 void* paramObj[] = { };
208 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
209 double retVal = getHue();
210 void* retObj = &retVal;
211 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
212 delete[] localMethodBytes;
215 void LightBulb_Skeleton::___getSaturation(LightBulb_Skeleton* skel) {
216 char* localMethodBytes = new char[methodLen];
217 memcpy(localMethodBytes, skel->methodBytes, methodLen);
218 didGetMethodBytes.exchange(true);
219 string paramCls[] = { };
221 void* paramObj[] = { };
222 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
223 double retVal = getSaturation();
224 void* retObj = &retVal;
225 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
226 delete[] localMethodBytes;
229 void LightBulb_Skeleton::___getTemperature(LightBulb_Skeleton* skel) {
230 char* localMethodBytes = new char[methodLen];
231 memcpy(localMethodBytes, skel->methodBytes, methodLen);
232 didGetMethodBytes.exchange(true);
233 string paramCls[] = { };
235 void* paramObj[] = { };
236 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
237 int retVal = getTemperature();
238 void* retObj = &retVal;
239 rmiComm->sendReturnObj(retObj, "int", localMethodBytes);
240 delete[] localMethodBytes;
243 void LightBulb_Skeleton::___getBrightnessRangeLowerBound(LightBulb_Skeleton* skel) {
244 char* localMethodBytes = new char[methodLen];
245 memcpy(localMethodBytes, skel->methodBytes, methodLen);
246 didGetMethodBytes.exchange(true);
247 string paramCls[] = { };
249 void* paramObj[] = { };
250 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
251 double retVal = getBrightnessRangeLowerBound();
252 void* retObj = &retVal;
253 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
254 delete[] localMethodBytes;
257 void LightBulb_Skeleton::___getBrightnessRangeUpperBound(LightBulb_Skeleton* skel) {
258 char* localMethodBytes = new char[methodLen];
259 memcpy(localMethodBytes, skel->methodBytes, methodLen);
260 didGetMethodBytes.exchange(true);
261 string paramCls[] = { };
263 void* paramObj[] = { };
264 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
265 double retVal = getBrightnessRangeUpperBound();
266 void* retObj = &retVal;
267 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
268 delete[] localMethodBytes;
271 void LightBulb_Skeleton::___getHueRangeLowerBound(LightBulb_Skeleton* skel) {
272 char* localMethodBytes = new char[methodLen];
273 memcpy(localMethodBytes, skel->methodBytes, methodLen);
274 didGetMethodBytes.exchange(true);
275 string paramCls[] = { };
277 void* paramObj[] = { };
278 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
279 double retVal = getHueRangeLowerBound();
280 void* retObj = &retVal;
281 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
282 delete[] localMethodBytes;
285 void LightBulb_Skeleton::___getHueRangeUpperBound(LightBulb_Skeleton* skel) {
286 char* localMethodBytes = new char[methodLen];
287 memcpy(localMethodBytes, skel->methodBytes, methodLen);
288 didGetMethodBytes.exchange(true);
289 string paramCls[] = { };
291 void* paramObj[] = { };
292 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
293 double retVal = getHueRangeUpperBound();
294 void* retObj = &retVal;
295 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
296 delete[] localMethodBytes;
299 void LightBulb_Skeleton::___getSaturationRangeLowerBound(LightBulb_Skeleton* skel) {
300 char* localMethodBytes = new char[methodLen];
301 memcpy(localMethodBytes, skel->methodBytes, methodLen);
302 didGetMethodBytes.exchange(true);
303 string paramCls[] = { };
305 void* paramObj[] = { };
306 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
307 double retVal = getSaturationRangeLowerBound();
308 void* retObj = &retVal;
309 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
310 delete[] localMethodBytes;
313 void LightBulb_Skeleton::___getSaturationRangeUpperBound(LightBulb_Skeleton* skel) {
314 char* localMethodBytes = new char[methodLen];
315 memcpy(localMethodBytes, skel->methodBytes, methodLen);
316 didGetMethodBytes.exchange(true);
317 string paramCls[] = { };
319 void* paramObj[] = { };
320 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
321 double retVal = getSaturationRangeUpperBound();
322 void* retObj = &retVal;
323 rmiComm->sendReturnObj(retObj, "double", localMethodBytes);
324 delete[] localMethodBytes;
327 void LightBulb_Skeleton::___getTemperatureRangeLowerBound(LightBulb_Skeleton* skel) {
328 char* localMethodBytes = new char[methodLen];
329 memcpy(localMethodBytes, skel->methodBytes, methodLen);
330 didGetMethodBytes.exchange(true);
331 string paramCls[] = { };
333 void* paramObj[] = { };
334 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
335 int retVal = getTemperatureRangeLowerBound();
336 void* retObj = &retVal;
337 rmiComm->sendReturnObj(retObj, "int", localMethodBytes);
338 delete[] localMethodBytes;
341 void LightBulb_Skeleton::___getTemperatureRangeUpperBound(LightBulb_Skeleton* skel) {
342 char* localMethodBytes = new char[methodLen];
343 memcpy(localMethodBytes, skel->methodBytes, methodLen);
344 didGetMethodBytes.exchange(true);
345 string paramCls[] = { };
347 void* paramObj[] = { };
348 rmiComm->getMethodParams(paramCls, numParam, paramObj, localMethodBytes);
349 int retVal = getTemperatureRangeUpperBound();
350 void* retObj = &retVal;
351 rmiComm->sendReturnObj(retObj, "int", localMethodBytes);
352 delete[] localMethodBytes;
355 void LightBulb_Skeleton::___waitRequestInvokeMethod(LightBulb_Skeleton* skel) {
356 skel->didAlreadyInitWaitInvoke = true;
358 if (!methodReceived) {
361 skel->methodBytes = skel->rmiComm->getMethodBytes();
362 skel->methodLen = skel->rmiComm->getMethodLength();
363 methodReceived = false;
364 int _objectId = skel->rmiComm->getObjectId(skel->methodBytes);
365 int methodId = skel->rmiComm->getMethodId(skel->methodBytes);
366 if (_objectId == objectId) {
367 if (set0Allowed.find(methodId) == set0Allowed.end()) {
368 cerr << "Object with object Id: " << _objectId << " is not allowed to access method: " << methodId << endl;
377 thread th0 (&LightBulb_Skeleton::___init, skel, skel);
381 thread th1 (&LightBulb_Skeleton::___turnOff, skel, skel);
385 thread th2 (&LightBulb_Skeleton::___turnOn, skel, skel);
389 thread th3 (&LightBulb_Skeleton::___getState, skel, skel);
393 thread th4 (&LightBulb_Skeleton::___setColor, skel, skel);
397 thread th5 (&LightBulb_Skeleton::___setTemperature, skel, skel);
401 thread th6 (&LightBulb_Skeleton::___getBrightness, skel, skel);
405 thread th7 (&LightBulb_Skeleton::___getHue, skel, skel);
409 thread th8 (&LightBulb_Skeleton::___getSaturation, skel, skel);
413 thread th9 (&LightBulb_Skeleton::___getTemperature, skel, skel);
417 thread th10 (&LightBulb_Skeleton::___getBrightnessRangeLowerBound, skel, skel);
418 th10.detach(); break;
421 thread th11 (&LightBulb_Skeleton::___getBrightnessRangeUpperBound, skel, skel);
422 th11.detach(); break;
425 thread th12 (&LightBulb_Skeleton::___getHueRangeLowerBound, skel, skel);
426 th12.detach(); break;
429 thread th13 (&LightBulb_Skeleton::___getHueRangeUpperBound, skel, skel);
430 th13.detach(); break;
433 thread th14 (&LightBulb_Skeleton::___getSaturationRangeLowerBound, skel, skel);
434 th14.detach(); break;
437 thread th15 (&LightBulb_Skeleton::___getSaturationRangeUpperBound, skel, skel);
438 th15.detach(); break;
441 thread th16 (&LightBulb_Skeleton::___getTemperatureRangeLowerBound, skel, skel);
442 th16.detach(); break;
445 thread th17 (&LightBulb_Skeleton::___getTemperatureRangeUpperBound, skel, skel);
446 th17.detach(); break;
449 cerr << "Method Id " << methodId << " not recognized!" << endl;
455 extern "C" void* createLightBulb_Skeleton(void** params) {
456 // Args: *_mainObj, int _portSend, int _portRecv
457 return new LightBulb_Skeleton((LightBulb*) params[0], *((int*) params[1]), *((int*) params[2]));
460 extern "C" void destroyLightBulb_Skeleton(void* t) {
461 LightBulb_Skeleton* obj = (LightBulb_Skeleton*) t;
465 extern "C" void initLightBulb_Skeleton(void* t) {