1 #ifndef _TESTCLASS_HPP__
2 #define _TESTCLASS_HPP__
7 #include "TestClassInterface.hpp"
8 #include "CallBackInterfaceWithCallBack.hpp"
14 class TestClass : public TestClassInterface {
17 TestClass(int _int, float _float, string _string);
19 char getByte(char in);
20 short getShort(short in);
21 int64_t getLong(int64_t in);
22 float getFloat(float in);
23 double getDouble(double in);
24 bool getBoolean(bool in);
25 char getChar(char in);
27 vector<char> getByteArray(vector<char> in);
28 vector<short> getShortArray(vector<short> in);
29 vector<int64_t> getLongArray(vector<int64_t> in);
30 vector<float> getFloatArray(vector<float> in);
31 vector<double> getDoubleArray(vector<double> in);
32 vector<bool> getBooleanArray(vector<bool> in);
33 vector<char> getCharArray(vector<char> in);
35 vector<char> getByteList(vector<char> in);
36 vector<short> getShortList(vector<short> in);
37 vector<int64_t> getLongList(vector<int64_t> in);
38 vector<float> getFloatList(vector<float> in);
39 vector<double> getDoubleList(vector<double> in);
40 vector<bool> getBooleanList(vector<bool> in);
41 vector<char> getCharList(vector<char> in);
44 void registerCallback(CallBackInterfaceWithCallBack* _cb);
45 void registerCallbackArray(vector<CallBackInterfaceWithCallBack*> _cb);
46 void registerCallbackList(vector<CallBackInterfaceWithCallBack*> _cb);
47 void registerCallbackComplex(int in, vector<CallBackInterfaceWithCallBack*> _cb, double db);
49 vector<Enum> handleCallbackEnum(vector<Enum> en, char c, vector<CallBackInterfaceWithCallBack*> _cb);
52 Enum handleEnum(Enum en);
53 vector<Enum> handleEnumArray(vector<Enum> vecEn);
54 vector<Enum> handleEnumList(vector<Enum> vecEn);
55 Enum handleEnumComplex(Enum en, int i, char c);
56 vector<Enum> handleEnumComplex2(vector<Enum> en, int i, char c);
57 vector<Enum> handleEnumTwo(vector<Enum> en1, vector<Enum> en2);
58 vector<Enum> handleEnumThree(vector<Enum> en1, vector<Enum> en2, vector<Struct> str1, vector<Struct> str2);
61 Struct handleStruct(Struct str);
62 vector<Struct> handleStructArray(vector<Struct> vecStr);
63 vector<Struct> handleStructList(vector<Struct> vecStr);
64 Struct handleStructComplex(int in, char c, Struct str);
65 vector<Struct> handleStructComplex2(int in, char c, vector<Struct> vecStr);
66 vector<Struct> handleStructTwo(vector<Struct> str1, vector<Struct> str2);
67 vector<Struct> handleStructThree(vector<Struct> str1, vector<Struct> str2, vector<Struct> str3);
69 vector<Enum> handleEnumStruct(vector<Enum> en, vector<Struct> str, char c);
70 vector<Enum> handleAll(vector<Enum> en, vector<Struct> str, char c, vector<CallBackInterfaceWithCallBack*> _cb);
71 vector<Enum> handleAllTwo(vector<Enum> en1, vector<Enum> en2, vector<Struct> str1, vector<Struct> str2, char c,
72 vector<CallBackInterfaceWithCallBack*> _cb1, vector<CallBackInterfaceWithCallBack*> _cb2);
76 void setB(float _float);
77 void setC(string _string);
78 string sumArray(vector<string> newA);
79 int setAndGetA(int newA);
80 int setACAndGetA(string newC, int newA);
86 vector<CallBackInterfaceWithCallBack*> cbvec;
90 TestClass::TestClass() {
95 // cbvec doesn't need to be initialized again
99 TestClass::TestClass(int _int, float _float, string _string) {
104 // cbvec doesn't need to be initialized again
108 void TestClass::registerCallbackArray(vector<CallBackInterfaceWithCallBack*> _cb) {
110 for (CallBackInterfaceWithCallBack* cb : _cb) {
112 cout << "Registering callback object in array!" << endl;
117 void TestClass::registerCallbackList(vector<CallBackInterfaceWithCallBack*> _cb) {
119 for (CallBackInterfaceWithCallBack* cb : _cb) {
121 cout << "Registering callback object in list!" << endl;
126 void TestClass::registerCallbackComplex(int in, vector<CallBackInterfaceWithCallBack*> _cb, double db) {
128 for (CallBackInterfaceWithCallBack* cb : _cb) {
130 cout << "Registering callback object in list!" << endl;
133 cout << "Integer: " << in << endl;
134 cout << "Double: " << db << endl;
138 void TestClass::registerCallback(CallBackInterfaceWithCallBack* _cb) {
140 cbvec.push_back(_cb);
141 cout << "Registering callback object!" << endl;
145 int TestClass::callBack() {
148 for (CallBackInterfaceWithCallBack* cb : cbvec) {
149 //cout << "Sum: " << sum << endl;
150 sum = sum + cb->printInt();
151 cb->needCallback(this);
152 //cb->needCallback(this);
153 TestClass* tc = new TestClass();
154 cb->needCallback(tc);
155 //cout << "Sum after: " << sum << endl;
157 cout << "About to return sum: " << sum << endl;
164 char TestClass::getByte(char in) {
170 short TestClass::getShort(short in) {
176 int64_t TestClass::getLong(int64_t in) {
182 float TestClass::getFloat(float in) {
188 double TestClass::getDouble(double in) {
194 bool TestClass::getBoolean(bool in) {
200 char TestClass::getChar(char in) {
207 vector<char> TestClass::getByteArray(vector<char> in) {
213 vector<short> TestClass::getShortArray(vector<short> in) {
219 vector<int64_t> TestClass::getLongArray(vector<int64_t> in) {
225 vector<float> TestClass::getFloatArray(vector<float> in) {
231 vector<double> TestClass::getDoubleArray(vector<double> in) {
237 vector<bool> TestClass::getBooleanArray(vector<bool> in) {
243 vector<char> TestClass::getCharArray(vector<char> in) {
249 vector<char> TestClass::getByteList(vector<char> in) {
255 vector<short> TestClass::getShortList(vector<short> in) {
261 vector<int64_t> TestClass::getLongList(vector<int64_t> in) {
267 vector<float> TestClass::getFloatList(vector<float> in) {
273 vector<double> TestClass::getDoubleList(vector<double> in) {
279 vector<bool> TestClass::getBooleanList(vector<bool> in) {
285 vector<char> TestClass::getCharList(vector<char> in) {
291 int TestClass::getA() {
297 void TestClass::setA(int _int) {
303 void TestClass::setB(float _float) {
309 void TestClass::setC(string _string) {
316 Enum TestClass::handleEnum(Enum en) {
318 cout << "Enum: " << en << endl;
324 vector<Enum> TestClass::handleEnumArray(vector<Enum> vecEn) {
326 for (Enum en : vecEn) {
327 cout << "Enum: " << en << endl;
334 vector<Enum> TestClass::handleEnumList(vector<Enum> vecEn) {
336 for (Enum en : vecEn) {
337 cout << "Enum: " << en << endl;
344 Enum TestClass::handleEnumComplex(Enum en, int i, char c) {
346 cout << "Enum: " << en << endl;
347 cout << "Integer: " << i << endl;
348 cout << "Char: " << c << endl;
354 vector<Enum> TestClass::handleEnumComplex2(vector<Enum> vecEn, int in, char c) {
356 for (Enum en : vecEn) {
357 cout << "Enum: " << en << endl;
359 cout << "Integer: " << in << endl;
360 cout << "Char: " << c << endl;
366 vector<Enum> TestClass::handleEnumTwo(vector<Enum> en1, vector<Enum> en2) {
368 for (Enum en : en1) {
369 cout << "Enum1: " << en << endl;
371 for (Enum en : en2) {
372 cout << "Enum2: " << en << endl;
379 vector<Enum> TestClass::handleEnumThree(vector<Enum> en1, vector<Enum> en2, vector<Struct> str1, vector<Struct> str2) {
381 for (Enum en : en1) {
382 cout << "Enum1: " << en << endl;
384 for (Enum en : en2) {
385 cout << "Enum2: " << en << endl;
394 Struct TestClass::handleStruct(Struct str) {
396 cout << "Name: " << str.name << endl;
397 cout << "Value: " << str.value << endl;
398 cout << "Year: " << str.year << endl;
401 test.name = "Anonymous";
410 vector<Struct> TestClass::handleStructArray(vector<Struct> vecStr) {
412 for (Struct str : vecStr) {
414 cout << "Name: " << str.name << endl;
415 cout << "Value: " << str.value << endl;
416 cout << "Year: " << str.year << endl;
419 test.name = "Anonymous";
422 vecStr.push_back(test);
428 vector<Struct> TestClass::handleStructList(vector<Struct> vecStr) {
430 for (Struct str : vecStr) {
432 cout << "Name: " << str.name << endl;
433 cout << "Value: " << str.value << endl;
434 cout << "Year: " << str.year << endl;
437 test.name = "Trimananda";
440 vecStr.push_back(test);
446 vector<Struct> TestClass::handleStructTwo(vector<Struct> str1, vector<Struct> str2) {
448 for (Struct str : str1) {
450 cout << "Name: " << str.name << endl;
451 cout << "Value: " << str.value << endl;
452 cout << "Year: " << str.year << endl;
459 vector<Struct> TestClass::handleStructThree(vector<Struct> str1, vector<Struct> str2, vector<Struct> str3) {
461 for (Struct str : str1) {
463 cout << "Name: " << str.name << endl;
464 cout << "Value: " << str.value << endl;
465 cout << "Year: " << str.year << endl;
472 Struct TestClass::handleStructComplex(int in, char c, Struct str) {
474 cout << "Name: " << str.name << endl;
475 cout << "Value: " << str.value << endl;
476 cout << "Year: " << str.year << endl;
478 cout << "Integer: " << in << endl;
479 cout << "Char: " << c << endl;
482 test.name = "Anonymous";
491 vector<Struct> TestClass::handleStructComplex2(int in, char c, vector<Struct> vecStr) {
493 for (Struct str : vecStr) {
494 cout << "Name: " << str.name << endl;
495 cout << "Value: " << str.value << endl;
496 cout << "Year: " << str.year << endl;
499 cout << "Integer: " << in << endl;
500 cout << "Char: " << c << endl;
506 vector<Enum> TestClass::handleEnumStruct(vector<Enum> en, vector<Struct> str, char c) {
508 for (Struct st : str) {
509 cout << "Name: " << st.name << endl;
510 cout << "Value: " << st.value << endl;
511 cout << "Year: " << st.year << endl;
514 cout << "Char: " << c << endl;
520 vector<Enum> TestClass::handleAll(vector<Enum> en, vector<Struct> str, char c, vector<CallBackInterfaceWithCallBack*> _cb) {
522 for (CallBackInterfaceWithCallBack* cb : _cb) {
524 cout << "Registering callback object in array!" << endl;
527 for (Struct st : str) {
528 cout << "Name: " << st.name << endl;
529 cout << "Value: " << st.value << endl;
530 cout << "Year: " << st.year << endl;
533 cout << "Char: " << c << endl;
539 vector<Enum> TestClass::handleAllTwo(vector<Enum> en1, vector<Enum> en2, vector<Struct> str1, vector<Struct> str2, char c,
540 vector<CallBackInterfaceWithCallBack*> _cb1, vector<CallBackInterfaceWithCallBack*> _cb2) {
542 for (CallBackInterfaceWithCallBack* cb : _cb1) {
544 cout << "Registering callback object in array!" << endl;
547 for (Struct st : str1) {
548 cout << "Name: " << st.name << endl;
549 cout << "Value: " << st.value << endl;
550 cout << "Year: " << st.year << endl;
553 cout << "Char: " << c << endl;
559 vector<Enum> TestClass::handleCallbackEnum(vector<Enum> en, char c, vector<CallBackInterfaceWithCallBack*> _cb) {
561 for (CallBackInterfaceWithCallBack* cb : _cb) {
563 cout << "Registering callback object in array!" << endl;
566 cout << "Char: " << c << endl;
572 string TestClass::sumArray(vector<string> newA) {
575 int len = newA.size();
576 for(int c = 0; c < len; c++) {
583 int TestClass::setAndGetA(int newA) {
590 int TestClass::setACAndGetA(string newC, int newA) {