d39960b651b3dbda67a52e6a35232ced9c262f2c
[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                 int                                     getA();
24                 void                            setA(int _int);
25                 void                            setB(float _float);
26                 void                            setC(string _string);
27                 string                          sumArray(vector<string> newA);
28                 int                                     setAndGetA(int newA);
29                 int                                     setACAndGetA(string newC, int newA);
30
31         private:                
32                 int                                                     intA;
33                 float                                           floatB;
34                 string                                          stringC;
35 };
36
37
38 TestClass::TestClass() {
39
40         intA = 1;
41         floatB = 2;
42         stringC = "345";
43         // cbvec doesn't need to be initialized again
44 }
45
46
47 TestClass::TestClass(int _int, float _float, string _string) {
48
49         intA = _int;
50         floatB = _float;
51         stringC = _string;
52         // cbvec doesn't need to be initialized again
53 }
54
55
56 char TestClass::getByte(char in) {
57
58         return in;
59 }
60
61
62 short TestClass::getShort(short in) {
63
64         return in;
65 }
66
67
68 int64_t TestClass::getLong(int64_t in) {
69
70         return in;
71 }
72
73
74 float TestClass::getFloat(float in) {
75
76         return in;
77 }
78
79
80 double TestClass::getDouble(double in) {
81
82         return in;
83 }
84
85
86 bool TestClass::getBoolean(bool in) {
87
88         return in;
89 }
90
91
92 char TestClass::getChar(char in) {
93
94         return in;
95 }
96
97
98 int TestClass::getA() {
99
100         return intA;
101 }
102
103
104 void TestClass::setA(int _int) {
105
106         intA = _int;
107 }
108
109
110 void TestClass::setB(float _float) {
111
112         floatB = _float;
113 }
114
115
116 void TestClass::setC(string _string) {
117
118         stringC = _string;
119 }
120
121
122 string TestClass::sumArray(vector<string> newA) {
123
124         string sum = "";
125         int len = newA.size();
126         for(int c = 0; c < len; c++) {
127                 sum = sum + newA[c];
128         }
129         return sum;
130 }
131
132
133 int TestClass::setAndGetA(int newA) {
134
135         intA = newA;
136         return intA;
137 }
138
139
140 int TestClass::setACAndGetA(string newC, int newA) {
141
142         stringC = newC;
143         intA = newA;
144         return intA;
145 }
146
147 #endif
148