#include <iostream>
#include <fstream>
#include <vector>
+#include <thread>
#include <dlfcn.h> // For dlopen, dlsym, etc.
-#include "ObjectFactory.hpp"
-#include "ISet.hpp"
+//#include "ObjectFactory.hpp"
+//#include "ISet.hpp"
#include "IoTSet.hpp"
-#include "IRelation.hpp"
+#include "IoTDeviceAddress.hpp"
+//#include "IRelation.hpp"
#include "IoTRelation.hpp"
#include "Socket.cpp"
};
+
+// Defining generic function pointers for
+// create, destroy, and init functions of each class object
+typedef void* create_t(void**);
+typedef void destroy_t(void*);
+typedef void init_t(void*);
+
+
class IoTSlave {
private:
// Constants
const static int RCVBUFSIZE = 1024; // Size of receive buffer
+ const static int SKELPARAMSIZE = 3; // Number of params for skeleton
+ const static int STUBPARAMSIZE = 6; // Number of params for stub
const static string FILEPATH; // File path
const static string FILEEXT; // File extension
const static string SOEXT; // Shared object (.so) extension
const static string INTCLASS; // Int class
const static string CREATEFUNCTION; // The create function in class
const static string DESTROYFUNCTION; // The destroy function in class
+ const static string INITFUNCTION; // The init function in class
+ const static string LOCALHOST; // String "localhost"
// Class properties
string serverAddress;
int serverPort;
+ string hostAddress;
+ string mainObjectName;
string objectName;
string objectClassName;
string objectInterfaceName;
string objectSkelClass; // Need to send from Java IoTSlave: sMessage.getObjectInterfaceName() + SKEL_CLASS_SUFFIX
+ string objectStubClass; // Need to send from Java IoTSlave: sMessage.getObjectStubInterfaceName() + STUB_CLASS_SUFFIX
int objectRegPort;
int objectStubPort;
-
- void* object; // Handler of object
+ vector<int> ports; // Now used to contain callback ports
+ string objectFieldName; // Field name that is going to be initialized with IoTSet or IoTRelation
+ unordered_set<void*>* isetObject; // Set of object
+ IoTSet<void*>* iotsetObject; // IoTSet of object
+ vector<IoTSet<void*>*> vecIoTSet; // IoTSet of object
TCPSocket* socket;
- ofstream log; // Log the messages
- vector<string> args; // Hold the arguments for constructor (in string format)
- vector<string> argClasses; // Hold the argument classes
+ ofstream log; // Log the messages
+ vector<string> args; // Hold the arguments for constructor (in string format)
+ vector<string> argClasses; // Hold the argument classes
+ bool isDriverObject; // Set to true if this is IoTSlave instance for a driver object
+ void* objMainCls; // Main class handler, i.e. driver or controller object
+ void* objSkelCls; // Skeleton handler
+ void* objStubCls; // Stub handler
+ unordered_map<string, void*> mapObjNameStub; // Mapping between object name and stub
// Object handlers
create_t* create_object;
destroy_t* destroy_object;
+ init_t* init_object;
public:
// Constructors
void createMainObject(); // Create main object
void createNewIoTSet();
void getDeviceIoTSetObject();
+ void reinitializeIoTSetField();
+ void getIoTSetObject();
+ void invokeInitMethod();
private:
// Private helper functions
void openFile(string fileName);
void writeToFile(string logMsg);
void closeFile();
- void instantiateObject(string objectClassName);
+ void getObjectHandler(string objectClassName);
+ void instantiateMainObject();
+ void instantiateDriverObject();
+ void instantiateSkelObject();
+ void instantiateStubObject();
+ void runInitObject(IoTSlave* iotslave);
};
// Constant initialization
const string IoTSlave::INTCLASS = "int";
const string IoTSlave::CREATEFUNCTION = "create";
const string IoTSlave::DESTROYFUNCTION = "destroy";
+const string IoTSlave::INITFUNCTION = "init";
+const string IoTSlave::LOCALHOST = "localhost";
#endif