#include <fstream>
#include <vector>
#include <thread>
+#include <cstdlib>
#include <dlfcn.h> // For dlopen, dlsym, etc.
-//#include "ObjectFactory.hpp"
-//#include "ISet.hpp"
#include "IoTSet.hpp"
#include "IoTDeviceAddress.hpp"
-//#include "IRelation.hpp"
#include "IoTRelation.hpp"
#include "Socket.cpp"
const static string DESTROYFUNCTION; // The destroy function in class
const static string INITFUNCTION; // The init function in class
const static string LOCALHOST; // String "localhost"
+ const static string SHELL; // String ".sh"
// Class properties
string serverAddress;
int objectRegPort;
int objectStubPort;
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
+ 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
+ void* irelFirstObject; // First object of IoTRelation
+ void* irelSecondObject; // Second object of IoTRelation
+ unordered_multimap<void*,void*>* irelObject; // Relation of object
+ IoTRelation<void*,void*>* iotrelObject; // IoTRelation of objects
+ vector<IoTRelation<void*,void*>*> vecIoTRel; // IoTRelation of object
+
TCPSocket* socket;
ofstream log; // Log the messages
vector<string> args; // Hold the arguments for constructor (in string format)
int recvInteger();
void sendString(string strSend);
string recvString();
+ string recvFile();
+ void unzipFile(string fileName);
// Main loop
void sendAck();
bool recvEndTransfer();
void createObject(); // Create driver object
void createMainObject(); // Create main object
void createNewIoTSet();
+ void createNewIoTRelation();
void getDeviceIoTSetObject();
+ void getIoTRelationFirstObject();
+ void getIoTRelationSecondObject();
void reinitializeIoTSetField();
+ void reinitializeIoTRelationField();
void getIoTSetObject();
void invokeInitMethod();
+ void transferFile();
private:
// Private helper functions
int* byteToInt(int* result, char* bytes);
char* intToByteArray(int i, char* bytes);
char* recvIter(char* recvBuffer, int recvLen);
+ char* recvFileIter(char* recvBuffer, int recvLen);
void* getObjectConverted(void* retObj, string object, string objectClass);
void openFile(string fileName);
void writeToFile(string logMsg);
void instantiateSkelObject();
void instantiateStubObject();
void runInitObject(IoTSlave* iotslave);
+ void getIoTSetRelationObject();
+ void createStub();
};
// Constant initialization
const string IoTSlave::DESTROYFUNCTION = "destroy";
const string IoTSlave::INITFUNCTION = "init";
const string IoTSlave::LOCALHOST = "localhost";
+const string IoTSlave::SHELL = ".sh";
#endif