3 #include "TestClassInterface_Skeleton.hpp"
4 #include "TestClass.hpp"
6 #include "CallBackInterfaceWithCallBack_Stub.cpp"
10 TestClassInterface_Skeleton::TestClassInterface_Skeleton(TestClassInterface *_mainObj, string _callbackAddress, int _port) {
11 bool _bResult = false;
13 callbackAddress = _callbackAddress;
14 rmiObj = new IoTRMIObject(_port, &_bResult);
15 set0Allowed.insert(-9999);
16 ___waitRequestInvokeMethod();
19 TestClassInterface_Skeleton::TestClassInterface_Skeleton(TestClassInterface *_mainObj, int _objIdCnt, string _callbackAddress) {
20 bool _bResult = false;
23 callbackAddress = _callbackAddress;
24 set0Allowed.insert(-9999);
25 ___waitRequestInvokeMethod();
28 TestClassInterface_Skeleton::~TestClassInterface_Skeleton() {
33 if (rmiCall != NULL) {
37 for(CallBackInterfaceWithCallBack* cb : vecCallbackObj) {
43 short TestClassInterface_Skeleton::getShort(short in) {
44 return mainObj->getShort(in);
47 void TestClassInterface_Skeleton::registerCallback(CallBackInterfaceWithCallBack* _cb) {
48 mainObj->registerCallback(_cb);
51 void TestClassInterface_Skeleton::___regCB() {
56 string paramCls[] = { "int*", "String", "int" };
57 void* paramObj[] = { ¶m1, ¶m2, ¶m3 };
58 rmiObj->getMethodParams(paramCls, numParam, paramObj);
60 rmiCall = new IoTRMICall(param1[1], param2.c_str(), param3, &bResult);
63 int TestClassInterface_Skeleton::callBack() {
64 return mainObj->callBack();
67 void TestClassInterface_Skeleton::___getShort() {
68 string paramCls[] = { "short" };
71 void* paramObj[] = { &in };
72 rmiObj->getMethodParams(paramCls, numParam, paramObj);
73 short retVal = getShort(in);
74 void* retObj = &retVal;
75 rmiObj->sendReturnObj(retObj, "short");
78 void TestClassInterface_Skeleton::___registerCallback() {
79 string paramCls[] = { "int" };
82 void* paramObj[] = { &numStubs0 };
83 rmiObj->getMethodParams(paramCls, numParam, paramObj);
84 //CallBackInterfaceWithCallBack* stub0 = new CallBackInterfaceWithCallBack_CallbackStub(rmiCall, callbackAddress, objIdCnt, ports);
85 CallBackInterfaceWithCallBack* stub0 = new CallBackInterfaceWithCallBack_Stub(rmiCall, callbackAddress, objIdCnt, ports);
86 vecCallbackObj.push_back(stub0);
88 registerCallback(stub0);
91 void TestClassInterface_Skeleton::___callBack() {
92 string paramCls[] = { };
94 void* paramObj[] = { };
95 rmiObj->getMethodParams(paramCls, numParam, paramObj);
96 int retVal = callBack();
97 void* retObj = &retVal;
98 rmiObj->sendReturnObj(retObj, "int");
101 void TestClassInterface_Skeleton::___waitRequestInvokeMethod() {
103 rmiObj->getMethodBytes();
104 int _objectId = rmiObj->getObjectId();
105 int methodId = rmiObj->getMethodId();
106 if (_objectId == object0Id) {
107 if (set0Allowed.find(methodId) == set0Allowed.end()) {
108 cerr << "Object with object Id: " << _objectId << " is not allowed to access method: " << methodId << endl;
113 cerr << "Object Id: " << _objectId << " not recognized!" << endl;
117 case 0: ___getShort(); break;
118 case 1: ___registerCallback(); break;
119 case 2: ___callBack(); break;
120 case -9999: ___regCB(); break;
122 cerr << "Method Id " << methodId << " not recognized!" << endl;
129 int main(int argc, char *argv[])
131 // First argument is port number
132 /*int port = atoi(argv[1]);
133 int argv2 = atoi(argv[2]);
134 float argv3 = atof(argv[3]);
135 string argv4 = string(argv[4]);
137 cout << port << endl;
138 cout << argv2 << endl;
139 cout << argv3 << endl;
140 cout << argv4 << endl;*/
143 //TestClassInterface *tc = new TestClass(argv2, argv3, argv4);
144 TestClassInterface *tc = new TestClass(123, 2.345, "test");
145 TestClassInterface_Skeleton *tcSkel = new TestClassInterface_Skeleton(tc, "localhost", port);