Initial import to Git
[profile/ivi/common-api-dbus-runtime.git] / src / test / DBusSerializableStructTest.h
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
5 #ifndef DEMO_POSITIONING_H_
6 #define DEMO_POSITIONING_H_
7
8
9 #include <common-api-dbus/dbus-serializable-struct.h>
10 #include <vector>
11
12
13 namespace common {
14 namespace api {
15 namespace test {
16
17
18 struct TestStruct: public common::api::dbus::SerializableStruct {
19         TestStruct() = default;
20         TestStruct(const uint32_t& fromIntValue, const double& fromDoubleValue);
21
22         virtual common::api::dbus::DBusInputMessageStream& readFromDBusInputMessageStream(
23                         common::api::dbus::DBusInputMessageStream& inputMessageStream);
24
25         virtual common::api::dbus::DBusOutputMessageStream& writeToDBusOutputMessageStream(
26                         common::api::dbus::DBusOutputMessageStream& outputMessageStream) const;
27
28         uint32_t intValue;
29         double doubleValue;
30 };
31
32
33 struct TestStructExtended: public TestStruct {
34         TestStructExtended() = default;
35
36         TestStructExtended(const uint32_t& fromIntValue, const double& fromDoubleValue, const std::string& fromStringValue);
37
38         virtual common::api::dbus::DBusInputMessageStream& readFromDBusInputMessageStream(
39                         common::api::dbus::DBusInputMessageStream& inputMessageStream);
40
41         virtual common::api::dbus::DBusOutputMessageStream& writeToDBusOutputMessageStream(
42                         common::api::dbus::DBusOutputMessageStream& outputMessageStream) const;
43
44         std::string stringValue;
45 };
46
47
48 typedef std::vector<TestStruct> TestStructArray;
49 typedef std::vector<TestStructExtended> TestStructExtendedArray;
50
51
52 } //namespace test
53
54 namespace dbus {
55
56 template<>
57 struct Alignment<common::api::test::TestStruct>: SizeConstant<8> { };
58
59 template<>
60 struct Alignment<common::api::test::TestStructExtended>: SizeConstant<8> { };
61
62 } //namespace dbus
63 } //namespace api
64 } //namespace common
65
66 #endif /* DEMO_POSITIONING_H_ */