1d73cbe2a43d43cd231d2c00f116b067a5ba3b54
[iot2.git] / iotjava / iotrmi / C++ / sample / TestClass_Stub.hpp
1 #include <iostream>
2 #include "../IoTRMICall.hpp"
3 #include "TestClassInterface.hpp"
4
5 using namespace std;
6
7 class TestClass_Stub : public TestClassInterface {
8         public:
9                 TestClass_Stub();
10                 TestClass_Stub(int _port, const char* _address, int _rev, bool* _bResult);
11                 ~TestClass_Stub();
12
13                 void                            setA(int _int);
14                 void                            setB(float _float);
15                 void                            setC(string _string);
16                 //string                                sumArray(vector<string> newA);
17                 int64_t                         sumArray(vector<int> newA);
18                 int                                     setAndGetA(int newA);
19                 int                                     setACAndGetA(string newC, int newA);
20                 //void                          registerCallback(CallBackInterface _cb);
21                 //int                           callBack();
22
23         private:                
24                 int                                     intA;
25                 float                           floatB;
26                 string                          stringC;
27                 //CallBackInterface cb;
28                 IoTRMICall                      *rmiCall;
29                 string                          address;
30                 //vector<int>                   ports;
31 };
32
33
34 TestClass_Stub::TestClass_Stub() {
35
36         address = "";
37         rmiCall = NULL;
38 }
39
40
41 TestClass_Stub::TestClass_Stub(int _port, const char* _address, int _rev, bool* _bResult) {
42
43         address = _address;
44         rmiCall = new IoTRMICall(_port, _address, _rev, _bResult);
45 }
46
47
48 TestClass_Stub::~TestClass_Stub() {
49
50         if (rmiCall != NULL) {
51                 delete rmiCall;
52                 rmiCall = NULL;
53         }
54 }
55
56
57 void TestClass_Stub::setA(int _int) {
58
59         int numParam = 1;
60         string sign = "voidsetA(int)";
61         string retType = "void";
62         string paramCls[] = { "int" };
63         void* paramObj[] = { &_int };
64         void* retObj = NULL;
65         rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
66 }
67
68
69 void TestClass_Stub::setB(float _float) {
70
71         int numParam = 1;
72         string sign = "voidsetB(float)";
73         string retType = "void";
74         string paramCls[] = { "float" };
75         void* paramObj[] = { &_float };
76         void* retObj = NULL;
77         rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
78 }
79
80
81 void TestClass_Stub::setC(string _string) {
82
83         int numParam = 1;
84         string sign = "voidsetC(string)";
85         string retType = "void";
86         string paramCls[] = { "string" };
87         void* paramObj[] = { &_string };
88         void* retObj = NULL;
89         rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
90 }
91
92
93 /*string TestClass_Stub::sumArray(vector<string> newA) {
94
95         int numParam = 1;
96         string sign = "sumArray(string[])";
97         string retType = "string";
98         string paramCls[] = { "string[]" };
99         void* paramObj[] = { &newA };
100         string retVal = "";
101         void* retObj = &retVal;
102         rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
103         return retVal;
104 }*/
105
106
107 int64_t TestClass_Stub::sumArray(vector<int> newA) {
108
109         int numParam = 1;
110         string sign = "sumArray(int[])";
111         string retType = "long";
112         string paramCls[] = { "int[]" };
113         void* paramObj[] = { &newA };
114         int64_t retVal = 0;
115         void* retObj = &retVal;
116         rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
117         return retVal;
118 }
119
120
121
122 int TestClass_Stub::setAndGetA(int newA) {
123
124         int numParam = 1;
125         string sign = "intsetAndGetA(int)";
126         string retType = "int";
127         string paramCls[] = { "int" };
128         void* paramObj[] = { &newA };
129         int retVal = 0;
130         void* retObj = &retVal;
131         rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
132         return retVal;
133 }
134
135
136 int TestClass_Stub::setACAndGetA(string newC, int newA) {
137
138         int numParam = 2;
139         string sign = "intsetACAndGetA(string,int)";
140         string retType = "int";
141         string paramCls[] = { "string", "int" };
142         void* paramObj[] = { &newC, &newA };
143         int retVal = 0;
144         void* retObj = &retVal;
145         rmiCall->remoteCall(sign, retType, paramCls, paramObj, numParam, retObj);
146         return retVal;
147 }
148
149
150 /*void TestClass_Stub::registerCallback(CallBackInterface _cb) {
151
152         cb = _cb;
153 }
154
155
156 int TestClass_Stub::callBack() {
157
158         return cb.printInt();
159 }*/
160