1 #include "LifxLightBulb.cpp"
2 #include "LightBulb_Skeleton.cpp"
3 #include "LightBulbTest_Stub.cpp"
7 //typedef void* create_t(string className, void** params);
8 //typedef void destroy_t(void*);
11 // Transferring members of IoTSet<void*> into IoTSet<IoTDeviceAddress*>
12 IoTSet<IoTDeviceAddress*>* createDeviceAddressSet(unordered_set<void*>* iotSet) {
14 unordered_set<IoTDeviceAddress*>* devSet = new unordered_set<IoTDeviceAddress*>();
15 //for (auto itr = iotSet->begin(); itr != iotSet->end(); ++itr) {
16 for (unordered_set<void*>::const_iterator itr = iotSet->begin(); itr != iotSet->end(); ++itr) {
17 IoTDeviceAddress* deviceAddress = (IoTDeviceAddress*) *itr;
18 devSet->insert(deviceAddress);
20 IoTSet<IoTDeviceAddress*>* iotDevSet = new IoTSet<IoTDeviceAddress*>(devSet);
28 // External creator/destroyer
29 extern "C" void* create(string className, void** params) {
31 if (className.compare("LifxLightBulb") == 0) {
32 // Arguments: IoTSet<IoTDeviceAddress*>* _devAddress, string macAddress
33 // We pass in a pointer to string and then we pass in just the value for the class
34 return new LifxLightBulb((IoTSet<IoTDeviceAddress*>*) params[0], *((string*) params[1]));
35 } else if (className.compare("LightBulb_Skeleton") == 0) {
36 // Arguments: LightBulb *_mainObj, string _callbackAddress, int _port
37 // We pass in pointers to string and integer, and read the values again
38 return new LightBulb_Skeleton((LightBulb*) params[0], *((string*) params[1]), *((int*) params[2]));
39 } else if (className.compare("LightBulbTest_Stub") == 0) {
40 // int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports
41 // We pass in pointers to string and integer, and read the values again
42 return new LightBulbTest_Stub(*((int*) params[0]), (const char*) params[1], *((string*) params[2]), *((int*) params[3]),
43 (bool*) params[4], *((vector<int>*) params[5]));
44 } else { // Class is not recognized
45 cerr << "ObjectFactory: Class is not recognized: " << className << endl;
50 extern "C" void destroy(string className, void* ob) {
52 if (ob != NULL) { // Check that this pointer is not NULL
54 if (className.compare("LifxLightBulb") == 0) {
55 LifxLightBulb* obj = (LifxLightBulb*) ob;
57 } else if (className.compare("LightBulb_Skeleton") == 0) {
58 LightBulb_Skeleton* obj = (LightBulb_Skeleton*) ob;
60 } else if (className.compare("LightBulbTest_Stub") == 0) {
61 LightBulbTest_Stub* obj = (LightBulbTest_Stub*) ob;
63 } else { // Class is not recognized
64 cerr << "ObjectFactory: Class is not recognized: " << className << endl;