2 #include "../IoTRMICall.hpp"
3 #include "../IoTRMIObject.hpp"
4 #include "TestClassInterface.hpp"
8 class TestClass_Stub : public TestClassInterface {
11 TestClass_Stub(int _port, const char* _address, int _rev, bool* _bResult, vector<int> _ports);
15 void setB(float _float);
16 void setC(string _string);
17 string sumArray(vector<string> newA);
18 //int64_t sumArray(vector<int> newA);
19 int setAndGetA(int newA);
20 int setACAndGetA(string newC, int newA);
21 void registerCallback(CallBackInterface* _cb);
22 void registerCallback(vector<CallBackInterface*>_cb);
26 const static int size = 9;
27 const static string methodSignatures[size];
33 //CallBackInterface cb;
38 map<int,CallBackInterface*> mapCBObj;
40 int objectId = 0; // Default value is 0
44 const string TestClass_Stub::methodSignatures[TestClass_Stub::size] = {
51 "intsetACAndGetA(string,int)",
53 "voidregisterCallBack(CallBackInterface)",
54 "voidregisterCallBack(CallBackInterface[])"
58 TestClass_Stub::TestClass_Stub() {
65 TestClass_Stub::TestClass_Stub(int _port, const char* _address, int _rev, bool* _bResult, vector<int> _ports) {
68 rmiCall = new IoTRMICall(_port, _address, _rev, _bResult, methodSignatures, size);
73 TestClass_Stub::~TestClass_Stub() {
75 if (rmiCall != NULL) {
82 // Callback handler thread
83 void TestClass_Stub::init_CallBack() {
86 rmiObj = new IoTRMIObject(ports[0], &bResult, CallBack_CBSkeleton::methodSignatures, CallBack_CBSkeleton::size);
88 char* method = rmiObj->getMethodBytes();
94 void TestClass_Stub::setA(int _int) {
97 string sign = "voidsetA(int)";
98 string retType = "void";
99 string paramCls[] = { "int" };
100 void* paramObj[] = { &_int };
102 rmiCall->remoteCall(objectId, sign, retType, paramCls, paramObj, numParam, retObj);
106 void TestClass_Stub::setB(float _float) {
109 string sign = "voidsetB(float)";
110 string retType = "void";
111 string paramCls[] = { "float" };
112 void* paramObj[] = { &_float };
114 rmiCall->remoteCall(objectId, sign, retType, paramCls, paramObj, numParam, retObj);
118 void TestClass_Stub::setC(string _string) {
121 string sign = "voidsetC(string)";
122 string retType = "void";
123 string paramCls[] = { "string" };
124 void* paramObj[] = { &_string };
126 rmiCall->remoteCall(objectId, sign, retType, paramCls, paramObj, numParam, retObj);
130 string TestClass_Stub::sumArray(vector<string> newA) {
133 string sign = "sumArray(string[])";
134 string retType = "string";
135 string paramCls[] = { "string[]" };
136 void* paramObj[] = { &newA };
138 void* retObj = &retVal;
139 rmiCall->remoteCall(objectId, sign, retType, paramCls, paramObj, numParam, retObj);
144 /*int64_t TestClass_Stub::sumArray(vector<int> newA) {
147 string sign = "sumArray(int[])";
148 string retType = "long";
149 string paramCls[] = { "int[]" };
150 void* paramObj[] = { &newA };
152 void* retObj = &retVal;
153 rmiCall->remoteCall(objectId, sign, retType, paramCls, paramObj, numParam, retObj);
159 int TestClass_Stub::setAndGetA(int newA) {
162 string sign = "intsetAndGetA(int)";
163 string retType = "int";
164 string paramCls[] = { "int" };
165 void* paramObj[] = { &newA };
167 void* retObj = &retVal;
168 rmiCall->remoteCall(objectId, sign, retType, paramCls, paramObj, numParam, retObj);
173 int TestClass_Stub::setACAndGetA(string newC, int newA) {
176 string sign = "intsetACAndGetA(string,int)";
177 string retType = "int";
178 string paramCls[] = { "string", "int" };
179 void* paramObj[] = { &newC, &newA };
181 void* retObj = &retVal;
182 rmiCall->remoteCall(objectId, sign, retType, paramCls, paramObj, numParam, retObj);
187 void TestClass_Stub::registerCallback(CallBackInterface* _cb) {
189 //Should implement the callback here
193 void TestClass_Stub::registerCallback(vector<CallBackInterface*> _cb) {
195 //Should implement the callback here for multiple callback objects
199 int TestClass_Stub::callBack() {
202 string sign = "intcallBack()";
203 string retType = "int";
204 string paramCls[] = { };
205 void* paramObj[] = { };
207 void* retObj = &retVal;
208 rmiCall->remoteCall(objectId, sign, retType, paramCls, paramObj, numParam, retObj);