Removing printing statements from C++ RMI library - this will cause SO files to get...
[iot2.git] / iotjava / iotrmi / C++ / sample / CallBack_Stub.hpp
1 #ifndef _CALLBACK_STUB_HPP__
2 #define _CALLBACK_STUB_HPP__
3
4 #include <iostream>
5 #include "CallBackInterface.hpp"
6 #include "../IoTRMICall.hpp"
7
8 using namespace std;
9
10 class CallBack_Stub : public CallBackInterface {
11         public:
12                 CallBack_Stub();
13                 CallBack_Stub(int _port, const char* _address, int _rev, bool* _bResult);
14                 ~CallBack_Stub();
15
16                 int                             printInt();
17                 void                    setInt(int _i);
18
19         private:                
20
21                 IoTRMICall      *rmiCall;
22                 string          address;
23                 int             objectId = 0;   // Default value is 0
24 };
25
26
27 // Constructor
28 CallBack_Stub::CallBack_Stub() {
29
30         address = "";
31         rmiCall = NULL;
32 }
33
34
35 CallBack_Stub::CallBack_Stub(int _port, const char* _address, int _rev, bool* _bResult) {
36
37         address = _address;
38         rmiCall = new IoTRMICall(_port, _address, _rev, _bResult);
39 }
40
41
42 CallBack_Stub::~CallBack_Stub() {
43
44         if (rmiCall != NULL) {
45                 delete rmiCall;
46                 rmiCall = NULL;
47         }
48 }
49
50
51 int CallBack_Stub::printInt() {
52
53         int numParam = 0;
54         int methodId = 0;
55         string retType = "int";
56         string paramCls[] = { };
57         void* paramObj[] = { };
58         int retVal = 0;
59         void* retObj = &retVal;
60         rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
61         return retVal;
62 }
63
64
65 void CallBack_Stub::setInt(int _i) {
66
67         int numParam = 1;
68         int methodId = 1;
69         string retType = "void";
70         string paramCls[] = { "int" };
71         void* paramObj[] = { &_i };
72         void* retObj = NULL;
73         rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
74 }
75
76 #endif