1 /* Copyright (C) 2013 BMW Group
2 * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
3 * Author: Juergen Gehring (juergen.gehring@bmw.de)
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #include <common-api-dbus/dbus-message.h>
11 #include "TestDBusSerializableStruct.h"
14 #define COMMON_API_TEST_TEST_STRUCT_SIGNATURE "(ud)"
15 #define COMMON_API_TEST_TEST_STRUCT_ARRAY_SIGNATURE "a" COMMON_API_TEST_TEST_STRUCT_SIGNATURE
17 #define COMMON_API_TEST_TEST_STRUCT_EXTENDED_SIGNATURE "(uds)"
18 #define COMMON_API_TEST_TEST_STRUCT_EXTENDED_ARRAY_SIGNATURE "a" COMMON_API_TEST_TEST_STRUCT_EXTENDED_SIGNATURE
26 TestStruct::TestStruct(const uint32_t& fromIntValue, const double& fromDoubleValue):
27 intValue(fromIntValue),
28 doubleValue(fromDoubleValue) {
31 common::api::dbus::DBusInputMessageStream& TestStruct::readFromDBusInputMessageStream(
32 common::api::dbus::DBusInputMessageStream& inputMessageStream) {
33 return inputMessageStream >> intValue
37 common::api::dbus::DBusOutputMessageStream& TestStruct::writeToDBusOutputMessageStream(
38 common::api::dbus::DBusOutputMessageStream& outputMessageStream) const {
39 return outputMessageStream << intValue
44 TestStructExtended::TestStructExtended(const uint32_t& fromIntValue, const double& fromDoubleValue, const std::string& fromStringValue):
45 TestStruct(fromIntValue, fromDoubleValue),
46 stringValue(fromStringValue) {
49 common::api::dbus::DBusInputMessageStream& TestStructExtended::readFromDBusInputMessageStream(
50 common::api::dbus::DBusInputMessageStream& inputMessageStream) {
51 return TestStruct::readFromDBusInputMessageStream(inputMessageStream) >> stringValue;
54 common::api::dbus::DBusOutputMessageStream& TestStructExtended::writeToDBusOutputMessageStream(
55 common::api::dbus::DBusOutputMessageStream& outputMessageStream) const {
56 return TestStruct::writeToDBusOutputMessageStream(outputMessageStream) << stringValue;
65 using namespace common::api::test;
67 TestStructExtended testStructExtended(123, 456.789, "TestStructExtended");
69 common::api::dbus::DBusMessage message = common::api::dbus::DBusMessage::createMethodCall(
70 "com.bmw.test.TestStruct",
71 "/com/bmw/test/TestStruct",
72 "com.bmw.test.TestStruct",
74 COMMON_API_TEST_TEST_STRUCT_EXTENDED_SIGNATURE);
76 common::api::dbus::DBusOutputMessageStream outStream(message);
77 outStream << testStructExtended;