Fixing bugs on char translation; testing for arrays
[iot2.git] / iotjava / iotrmi / C++ / basics / TestClass.hpp
1 #ifndef _TESTCLASS_HPP__
2 #define _TESTCLASS_HPP__
3
4 #include <iostream>
5 #include <thread>
6 #include <chrono>
7 #include "TestClassInterface.hpp"
8
9 using namespace std;
10
11 class TestClass : public TestClassInterface {
12         public:
13                 TestClass();
14                 TestClass(int _int, float _float, string _string);
15
16                 char                            getByte(char in);
17                 short                           getShort(short in);
18                 int64_t                         getLong(int64_t in);
19                 float                           getFloat(float in);
20                 double                          getDouble(double in);
21                 bool                            getBoolean(bool in);
22                 char                            getChar(char in);
23
24                 vector<char>            getByteArray(vector<char> in);
25                 vector<short>           getShortArray(vector<short> in);
26                 vector<int64_t>         getLongArray(vector<int64_t> in);
27                 vector<float>           getFloatArray(vector<float> in);
28                 vector<double>          getDoubleArray(vector<double> in);
29                 vector<bool>            getBooleanArray(vector<bool> in);
30                 vector<char>            getCharArray(vector<char> in);
31
32                 int                                     getA();
33                 void                            setA(int _int);
34                 void                            setB(float _float);
35                 void                            setC(string _string);
36                 string                          sumArray(vector<string> newA);
37                 int                                     setAndGetA(int newA);
38                 int                                     setACAndGetA(string newC, int newA);
39
40         private:                
41                 int                                                     intA;
42                 float                                           floatB;
43                 string                                          stringC;
44 };
45
46
47 TestClass::TestClass() {
48
49         intA = 1;
50         floatB = 2;
51         stringC = "345";
52         // cbvec doesn't need to be initialized again
53 }
54
55
56 TestClass::TestClass(int _int, float _float, string _string) {
57
58         intA = _int;
59         floatB = _float;
60         stringC = _string;
61         // cbvec doesn't need to be initialized again
62 }
63
64
65 // Single variables
66 char TestClass::getByte(char in) {
67
68         return in;
69 }
70
71
72 short TestClass::getShort(short in) {
73
74         return in;
75 }
76
77
78 int64_t TestClass::getLong(int64_t in) {
79
80         return in;
81 }
82
83
84 float TestClass::getFloat(float in) {
85
86         return in;
87 }
88
89
90 double TestClass::getDouble(double in) {
91
92         return in;
93 }
94
95
96 bool TestClass::getBoolean(bool in) {
97
98         return in;
99 }
100
101
102 char TestClass::getChar(char in) {
103
104         return in;
105 }
106
107
108 // Arrays
109 vector<char> TestClass::getByteArray(vector<char> in) {
110
111         return in;
112 }
113
114
115 vector<short> TestClass::getShortArray(vector<short> in) {
116
117         return in;
118 }
119
120
121 vector<int64_t> TestClass::getLongArray(vector<int64_t> in) {
122
123         return in;
124 }
125
126
127 vector<float> TestClass::getFloatArray(vector<float> in) {
128
129         return in;
130 }
131
132
133 vector<double> TestClass::getDoubleArray(vector<double> in) {
134
135         return in;
136 }
137
138
139 vector<bool> TestClass::getBooleanArray(vector<bool> in) {
140
141         return in;
142 }
143
144
145 vector<char> TestClass::getCharArray(vector<char> in) {
146
147         return in;
148 }
149
150
151 int TestClass::getA() {
152
153         return intA;
154 }
155
156
157 void TestClass::setA(int _int) {
158
159         intA = _int;
160 }
161
162
163 void TestClass::setB(float _float) {
164
165         floatB = _float;
166 }
167
168
169 void TestClass::setC(string _string) {
170
171         stringC = _string;
172 }
173
174
175 string TestClass::sumArray(vector<string> newA) {
176
177         string sum = "";
178         int len = newA.size();
179         for(int c = 0; c < len; c++) {
180                 sum = sum + newA[c];
181         }
182         return sum;
183 }
184
185
186 int TestClass::setAndGetA(int newA) {
187
188         intA = newA;
189         return intA;
190 }
191
192
193 int TestClass::setACAndGetA(string newC, int newA) {
194
195         stringC = newC;
196         intA = newA;
197         return intA;
198 }
199
200 #endif
201