Initial import to Git
[profile/ivi/common-api-dbus-runtime.git] / CommonAPI-DBus / src / test / commonapi / tests / DerivedTypeCollection.cpp
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 #include "DerivedTypeCollection.h"
5
6 namespace commonapi {
7 namespace tests {
8 namespace DerivedTypeCollection {
9
10 TestStruct::TestStruct(const PredefinedTypeCollection::TestString& testStringValue, const uint16_t& uintValueValue):
11         testString(testStringValue),
12         uintValue(uintValueValue)
13 {
14 }
15
16 bool operator==(const TestStruct& lhs, const TestStruct& rhs) {
17     if (&lhs == &rhs)
18         return true;
19
20     return
21         lhs.testString == rhs.testString &&
22         lhs.uintValue == rhs.uintValue
23     ;
24 }
25
26 void TestStruct::readFromInputStream(CommonAPI::InputStream& inputStream) {
27     inputStream >> testString;
28     inputStream >> uintValue;
29 }
30
31 void TestStruct::writeToOutputStream(CommonAPI::OutputStream& outputStream) const {
32     outputStream << testString;
33     outputStream << uintValue;
34 }
35 TestStructExtended::TestStructExtended(const PredefinedTypeCollection::TestString& testStringValue, const uint16_t& uintValueValue, const TestEnumExtended2& testEnumExtended2Value):
36         TestStruct(testStringValue, uintValueValue),
37         testEnumExtended2(testEnumExtended2Value)
38 {
39 }
40
41 bool operator==(const TestStructExtended& lhs, const TestStructExtended& rhs) {
42     if (&lhs == &rhs)
43         return true;
44
45     return
46         static_cast<TestStructExtended::TestStruct>(lhs) == static_cast<TestStructExtended::TestStruct>(rhs) &&
47         lhs.testEnumExtended2 == rhs.testEnumExtended2
48     ;
49 }
50
51 void TestStructExtended::readFromInputStream(CommonAPI::InputStream& inputStream) {
52     TestStruct::readFromInputStream(inputStream);
53     inputStream >> testEnumExtended2;
54 }
55
56 void TestStructExtended::writeToOutputStream(CommonAPI::OutputStream& outputStream) const {
57     TestStruct::writeToOutputStream(outputStream);
58     outputStream << testEnumExtended2;
59 }
60
61 } // namespace DerivedTypeCollection
62 } // namespace tests
63 } // namespace commonapi