#include <cstdlib>
#include <memory>
#include <typeinfo>
+#include <map>
#include <iostream>
#include <string>
using namespace std;
-class IoTRMIUtil {
+class IoTRMIUtil final {
public:
IoTRMIUtil();
// Constants
const static int OBJECT_ID_LEN = 4; // 4 bytes = 32 bits
const static int METHOD_ID_LEN = 4; // 4 bytes = 32 bits
+ const static int PACKET_TYPE_LEN = 4;// 4 bytes = 32 bits
const static int PARAM_LEN = 4; // 4 bytes = 32 bits (4-byte field that stores the length of the param)
const static int RETURN_LEN = 4; // 4 bytes = 32 bits (4-byte field that stores the length of the return object)
const static int CHAR_LEN = 2; // 2 bytes (we follow Java convention)
const static int BYTE_LEN = 1; // 1 byte
const static int BOOL_LEN = 1; // 1 byte
+ const static int METHOD_TYPE = 1; // Packet type of method
+ const static int RET_VAL_TYPE = -1; // Packet type of return value
+
+ // Static containers
+ static map<int,void*>* mapStub; // Map object to its stub ID
+ static map<void*,void*>* mapSkel; // Map object to its skeleton
+ static map<void*,int>* mapSkelId; // Map object to its skeleton ID
private:
map<string,string> mapPrimitives;
map<string,string> mapNonPrimitives;
};
+map<int,void*>* IoTRMIUtil::mapStub = new map<int,void*>();
+map<void*,void*>* IoTRMIUtil::mapSkel = new map<void*,void*>();
+map<void*,int>* IoTRMIUtil::mapSkelId = new map<void*,int>();
+
// Constructor
IoTRMIUtil::IoTRMIUtil() {
} else if ( string(type).find("*") != string::npos) {
// This is an array type, i.e. vector
retObj = getArrayParamObject(retObj, type, paramBytes, len);
+ } else if ( (string(type).find("<") != string::npos) &&
+ (string(type).find(">") != string::npos)) {
+ // This is a vector/list type
+ retObj = getArrayParamObject(retObj, type, paramBytes, len);
} else {
cerr << "IoTRMIUtil: Unrecognizable type: " << type << endl;
exit(-1);
} else if ( string(type).find("*") != string::npos) {
// This is an array type, i.e. vector
retObjBytes = getArrayObjectBytes(retObjBytes, obj, type);
+ } else if ( (string(type).find("<") != string::npos) &&
+ (string(type).find(">") != string::npos)) {
+ // This is a vector/list type
+ retObjBytes = getArrayObjectBytes(retObjBytes, obj, type);
} else {
cerr << "IoTRMIUtil: Unrecognizable type: " << type << endl;
exit(-1);