1 #include "LifxLightBulb.cpp"
2 #include "LightBulb_Skeleton.cpp"
3 #include "LightBulbTest_Stub.cpp"
6 typedef void* create_t(string className, void** params);
7 typedef void destroy_t(void*);
9 // External creator/destroyer
10 extern "C" void* create(string className, void** params) {
12 if (className.compare("LifxLightBulb") == 0) {
13 // Arguments: IoTSet<IoTDeviceAddress*>* _devAddress, string macAddress
14 // We pass in a pointer to string and then we pass in just the value for the class
15 return new LifxLightBulb((IoTSet<IoTDeviceAddress*>*) params[0], *((string*) params[1]));
16 } else if (className.compare("LightBulb_Skeleton") == 0) {
17 // Arguments: LightBulb *_mainObj, string _callbackAddress, int _port
18 // We pass in pointers to string and integer, and read the values again
19 return new LightBulb_Skeleton((LightBulb*) params[0], *((string*) params[1]), *((int*) params[2]));
20 } else if (className.compare("LightBulbTest_Stub") == 0) {
21 // int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports
22 // We pass in pointers to string and integer, and read the values again
23 return new LightBulbTest_Stub(*((int*) params[0]), (const char*) params[1], *((string*) params[2]), *((int*) params[3]),
24 (bool*) params[4], *((vector<int>*) params[5]));
25 } else { // Class is not recognized
26 cerr << "ObjectFactory: Class is not recognized: " << className << endl;
31 extern "C" void destroy(string className, void* ob) {
33 if (ob != NULL) { // Check that this pointer is not NULL
35 if (className.compare("LifxLightBulb") == 0) {
36 LifxLightBulb* obj = (LifxLightBulb*) ob;
38 } else if (className.compare("LightBulb_Skeleton") == 0) {
39 LightBulb_Skeleton* obj = (LightBulb_Skeleton*) ob;
41 } else if (className.compare("LightBulbTest_Stub") == 0) {
42 LightBulbTest_Stub* obj = (LightBulbTest_Stub*) ob;
44 } else { // Class is not recognized
45 cerr << "ObjectFactory: Class is not recognized: " << className << endl;
51 /*typedef LifxLightBulb* create_t(IoTSet<IoTDeviceAddress*>* _devAddress, string macAddress);
52 typedef void destroy_t(LifxLightBulb*);
54 // External creator/destroyer
55 extern "C" LifxLightBulb* create(IoTSet<IoTDeviceAddress*>* _devAddress, string macAddress) {
56 return new LifxLightBulb(_devAddress, macAddress);
59 extern "C" void destroy(LifxLightBulb* t) {
63 //typedef LightBulb_Skeleton* create_t(LightBulb *_mainObj, string _callbackAddress, int _port);
64 //typedef void destroy_t(LightBulb_Skeleton*);
66 /*extern "C" LightBulb_Skeleton* create(LightBulb *_mainObj, string _callbackAddress, int _port) {
67 return new LightBulb_Skeleton(_mainObj, _callbackAddress, _port);
70 extern "C" void destroy(LightBulb_Skeleton* t) {
74 //typedef LightBulbTest_Stub* create_t(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports);
75 //typedef void destroy_t(LightBulbTest_Stub*);
77 /*extern "C" LightBulbTest_Stub* create(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports) {
78 return new LightBulbTest_Stub(_port, _skeletonAddress, _callbackAddress, _rev, _bResult, _ports);
81 extern "C" void destroy(LightBulbTest_Stub* t) {