summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Laner <laner@itestra.de>2013-10-24 19:57:58 +0200
committerPhilip Rauwolf <rauwolf@itestra.de>2013-10-29 17:37:33 +0100
commitdf112482a09ad91e8a2028c4cf691969a2365ff1 (patch)
treec662bb76aa7fe61a4e215d73b8bf9154072e2515 /src
parentd4107ff2515a8d66e321e8b3d61f289308f0f569 (diff)
downloadgenivi-common-api-dbus-runtime-df112482a09ad91e8a2028c4cf691969a2365ff1.tar.gz
Fixed (de-)serialization of polymorphic structs.
Added unit test for polymorphic structs. Change-Id: I577a94e3d14ff13a6a3ef56802cbf78c4f26b52c
Diffstat (limited to 'src')
-rw-r--r--src/CommonAPI/DBus/DBusInputStream.cpp102
-rw-r--r--src/CommonAPI/DBus/DBusInputStream.h79
-rw-r--r--src/CommonAPI/DBus/DBusOutputStream.cpp121
-rw-r--r--src/CommonAPI/DBus/DBusOutputStream.h117
-rw-r--r--src/test/DBusPolymorphicTest.cpp286
-rw-r--r--src/test/commonapi/tests/DerivedTypeCollection.cpp122
-rw-r--r--src/test/commonapi/tests/DerivedTypeCollection.h83
-rw-r--r--src/test/commonapi/tests/TestInterfaceDBusProxy.cpp76
-rw-r--r--src/test/commonapi/tests/TestInterfaceDBusProxy.h8
-rw-r--r--src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp41
-rw-r--r--src/test/commonapi/tests/TestInterfaceProxy.h116
-rw-r--r--src/test/commonapi/tests/TestInterfaceProxyBase.h14
-rw-r--r--src/test/commonapi/tests/TestInterfaceStub.h10
-rw-r--r--src/test/commonapi/tests/TestInterfaceStubDefault.cpp32
-rw-r--r--src/test/commonapi/tests/TestInterfaceStubDefault.h12
-rw-r--r--src/test/test-derived-types.fidl20
-rw-r--r--src/test/test-interface-proxy.fidl25
17 files changed, 1093 insertions, 171 deletions
diff --git a/src/CommonAPI/DBus/DBusInputStream.cpp b/src/CommonAPI/DBus/DBusInputStream.cpp
index c7627a1..2d3b1df 100644
--- a/src/CommonAPI/DBus/DBusInputStream.cpp
+++ b/src/CommonAPI/DBus/DBusInputStream.cpp
@@ -6,7 +6,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DBusInputStream.h"
-
namespace CommonAPI {
namespace DBus {
@@ -18,8 +17,7 @@ DBusInputStream::DBusInputStream(const CommonAPI::DBus::DBusMessage& message) :
exception_(nullptr) {
}
-DBusInputStream::~DBusInputStream() {
-}
+DBusInputStream::~DBusInputStream() {}
const CommonAPI::DBus::DBusError& DBusInputStream::getError() const {
return *exception_;
@@ -46,12 +44,12 @@ char* DBusInputStream::readRawData(const size_t numBytesToRead) {
return dataPtr;
}
-template <>
+template<>
DBusInputStream& DBusInputStream::readBasicTypeValue<float>(float& val) {
if (sizeof(val) > 1)
alignToBoundary(sizeof(double));
- val = (float)(*(reinterpret_cast<double*>(readRawData(sizeof(double)))));
+ val = (float) (*(reinterpret_cast<double*>(readRawData(sizeof(double)))));
return *this;
}
@@ -62,18 +60,38 @@ InputStream& DBusInputStream::readValue(bool& boolValue) {
return *this;
}
-InputStream& DBusInputStream::readValue(int8_t& int8Value) { return readBasicTypeValue(int8Value); }
-InputStream& DBusInputStream::readValue(int16_t& int16Value) { return readBasicTypeValue(int16Value); }
-InputStream& DBusInputStream::readValue(int32_t& int32Value) { return readBasicTypeValue(int32Value); }
-InputStream& DBusInputStream::readValue(int64_t& int64Value) { return readBasicTypeValue(int64Value); }
+InputStream& DBusInputStream::readValue(int8_t& int8Value) {
+ return readBasicTypeValue(int8Value);
+}
+InputStream& DBusInputStream::readValue(int16_t& int16Value) {
+ return readBasicTypeValue(int16Value);
+}
+InputStream& DBusInputStream::readValue(int32_t& int32Value) {
+ return readBasicTypeValue(int32Value);
+}
+InputStream& DBusInputStream::readValue(int64_t& int64Value) {
+ return readBasicTypeValue(int64Value);
+}
-InputStream& DBusInputStream::readValue(uint8_t& uint8Value) { return readBasicTypeValue(uint8Value); }
-InputStream& DBusInputStream::readValue(uint16_t& uint16Value) { return readBasicTypeValue(uint16Value); }
-InputStream& DBusInputStream::readValue(uint32_t& uint32Value) { return readBasicTypeValue(uint32Value); }
-InputStream& DBusInputStream::readValue(uint64_t& uint64Value) { return readBasicTypeValue(uint64Value); }
+InputStream& DBusInputStream::readValue(uint8_t& uint8Value) {
+ return readBasicTypeValue(uint8Value);
+}
+InputStream& DBusInputStream::readValue(uint16_t& uint16Value) {
+ return readBasicTypeValue(uint16Value);
+}
+InputStream& DBusInputStream::readValue(uint32_t& uint32Value) {
+ return readBasicTypeValue(uint32Value);
+}
+InputStream& DBusInputStream::readValue(uint64_t& uint64Value) {
+ return readBasicTypeValue(uint64Value);
+}
-InputStream& DBusInputStream::readValue(float& floatValue) { return readBasicTypeValue(floatValue); }
-InputStream& DBusInputStream::readValue(double& doubleValue) { return readBasicTypeValue(doubleValue); }
+InputStream& DBusInputStream::readValue(float& floatValue) {
+ return readBasicTypeValue(floatValue);
+}
+InputStream& DBusInputStream::readValue(double& doubleValue) {
+ return readBasicTypeValue(doubleValue);
+}
InputStream& DBusInputStream::readValue(std::string& stringValue) {
uint32_t lengthOfString;
@@ -93,14 +111,30 @@ InputStream& DBusInputStream::readValue(ByteBuffer& byteBufferValue) {
return *this;
}
-InputStream& DBusInputStream::readEnumValue(int8_t& int8BackingTypeValue) { return readValue(int8BackingTypeValue); }
-InputStream& DBusInputStream::readEnumValue(int16_t& int16BackingTypeValue) { return readValue(int16BackingTypeValue); }
-InputStream& DBusInputStream::readEnumValue(int32_t& int32BackingTypeValue) { return readValue(int32BackingTypeValue); }
-InputStream& DBusInputStream::readEnumValue(int64_t& int64BackingTypeValue) { return readValue(int64BackingTypeValue); }
-InputStream& DBusInputStream::readEnumValue(uint8_t& uint8BackingTypeValue) { return readValue(uint8BackingTypeValue); }
-InputStream& DBusInputStream::readEnumValue(uint16_t& uint16BackingTypeValue) { return readValue(uint16BackingTypeValue); }
-InputStream& DBusInputStream::readEnumValue(uint32_t& uint32BackingTypeValue) { return readValue(uint32BackingTypeValue); }
-InputStream& DBusInputStream::readEnumValue(uint64_t& uint64BackingTypeValue) { return readValue(uint64BackingTypeValue); }
+InputStream& DBusInputStream::readEnumValue(int8_t& int8BackingTypeValue) {
+ return readValue(int8BackingTypeValue);
+}
+InputStream& DBusInputStream::readEnumValue(int16_t& int16BackingTypeValue) {
+ return readValue(int16BackingTypeValue);
+}
+InputStream& DBusInputStream::readEnumValue(int32_t& int32BackingTypeValue) {
+ return readValue(int32BackingTypeValue);
+}
+InputStream& DBusInputStream::readEnumValue(int64_t& int64BackingTypeValue) {
+ return readValue(int64BackingTypeValue);
+}
+InputStream& DBusInputStream::readEnumValue(uint8_t& uint8BackingTypeValue) {
+ return readValue(uint8BackingTypeValue);
+}
+InputStream& DBusInputStream::readEnumValue(uint16_t& uint16BackingTypeValue) {
+ return readValue(uint16BackingTypeValue);
+}
+InputStream& DBusInputStream::readEnumValue(uint32_t& uint32BackingTypeValue) {
+ return readValue(uint32BackingTypeValue);
+}
+InputStream& DBusInputStream::readEnumValue(uint64_t& uint64BackingTypeValue) {
+ return readValue(uint64BackingTypeValue);
+}
InputStream& DBusInputStream::readVersionValue(Version& versionValue) {
alignToBoundary(8);
@@ -113,13 +147,14 @@ void DBusInputStream::beginReadSerializableStruct(const SerializableStruct& seri
alignToBoundary(8);
}
-void DBusInputStream::endReadSerializableStruct(const SerializableStruct& serializableStruct) { }
+void DBusInputStream::endReadSerializableStruct(const SerializableStruct& serializableStruct) {
+}
void DBusInputStream::beginReadSerializablePolymorphicStruct(uint32_t& serialId) {
- alignToBoundary(8);
- readValue(serialId);
- skipOverSignature();
- alignToBoundary(8);
+ alignToBoundary(8);
+ readValue(serialId);
+ skipOverSignature();
+ alignToBoundary(8);
}
void DBusInputStream::endReadSerializablePolymorphicStruct(const uint32_t& serialId) {
@@ -134,7 +169,6 @@ void DBusInputStream::readSerializableVariant(SerializableVariant& serializableV
serializableVariant.readFromInputStream(containedTypeIndex, *this);
}
-
void DBusInputStream::beginReadBoolVector() {
beginReadGenericVector();
savedStreamPositions_.push(currentDataPosition_);
@@ -275,6 +309,12 @@ void DBusInputStream::beginReadVectorOfMaps() {
savedStreamPositions_.push(currentDataPosition_);
}
+void DBusInputStream::beginReadVectorOfSerializablePolymorphicStructs() {
+ beginReadGenericVector();
+ alignToBoundary(8);
+ savedStreamPositions_.push(currentDataPosition_);
+}
+
bool DBusInputStream::hasMoreVectorElements() {
return bytesToRead_.top() > currentDataPosition_ - savedStreamPositions_.top();
}
@@ -304,8 +344,8 @@ void DBusInputStream::endReadMap() {
void DBusInputStream::beginReadMapElement() {
alignToBoundary(8);
}
-void DBusInputStream::endReadMapElement() {}
-
+void DBusInputStream::endReadMapElement() {
+}
} // namespace DBus
} // namespace CommonAPI
diff --git a/src/CommonAPI/DBus/DBusInputStream.h b/src/CommonAPI/DBus/DBusInputStream.h
index 3edd874..9ee3238 100644
--- a/src/CommonAPI/DBus/DBusInputStream.h
+++ b/src/CommonAPI/DBus/DBusInputStream.h
@@ -38,45 +38,47 @@ typedef uint32_t position_t;
* (this operator is predefined for all basic data types and for vectors).
*/
class DBusInputStream: public InputStream {
- public:
- virtual bool hasError() const { return isErrorSet(); }
+public:
+ virtual bool hasError() const {
+ return isErrorSet();
+ }
virtual InputStream& readValue(bool& boolValue);
- virtual InputStream& readValue(int8_t& int8Value);
- virtual InputStream& readValue(int16_t& int16Value);
- virtual InputStream& readValue(int32_t& int32Value);
- virtual InputStream& readValue(int64_t& int64Value);
+ virtual InputStream& readValue(int8_t& int8Value);
+ virtual InputStream& readValue(int16_t& int16Value);
+ virtual InputStream& readValue(int32_t& int32Value);
+ virtual InputStream& readValue(int64_t& int64Value);
- virtual InputStream& readValue(uint8_t& uint8Value);
- virtual InputStream& readValue(uint16_t& uint16Value);
- virtual InputStream& readValue(uint32_t& uint32Value);
- virtual InputStream& readValue(uint64_t& uint64Value);
+ virtual InputStream& readValue(uint8_t& uint8Value);
+ virtual InputStream& readValue(uint16_t& uint16Value);
+ virtual InputStream& readValue(uint32_t& uint32Value);
+ virtual InputStream& readValue(uint64_t& uint64Value);
- virtual InputStream& readValue(float& floatValue);
- virtual InputStream& readValue(double& doubleValue);
+ virtual InputStream& readValue(float& floatValue);
+ virtual InputStream& readValue(double& doubleValue);
- virtual InputStream& readValue(std::string& stringValue);
- virtual InputStream& readValue(ByteBuffer& byteBufferValue);
+ virtual InputStream& readValue(std::string& stringValue);
+ virtual InputStream& readValue(ByteBuffer& byteBufferValue);
- virtual InputStream& readEnumValue(int8_t& int8BackingTypeValue);
- virtual InputStream& readEnumValue(int16_t& int16BackingTypeValue);
- virtual InputStream& readEnumValue(int32_t& int32BackingTypeValue);
- virtual InputStream& readEnumValue(int64_t& int64BackingTypeValue);
- virtual InputStream& readEnumValue(uint8_t& uint8BackingTypeValue);
- virtual InputStream& readEnumValue(uint16_t& uint16BackingTypeValue);
- virtual InputStream& readEnumValue(uint32_t& uint32BackingTypeValue);
- virtual InputStream& readEnumValue(uint64_t& uint64BackingTypeValue);
+ virtual InputStream& readEnumValue(int8_t& int8BackingTypeValue);
+ virtual InputStream& readEnumValue(int16_t& int16BackingTypeValue);
+ virtual InputStream& readEnumValue(int32_t& int32BackingTypeValue);
+ virtual InputStream& readEnumValue(int64_t& int64BackingTypeValue);
+ virtual InputStream& readEnumValue(uint8_t& uint8BackingTypeValue);
+ virtual InputStream& readEnumValue(uint16_t& uint16BackingTypeValue);
+ virtual InputStream& readEnumValue(uint32_t& uint32BackingTypeValue);
+ virtual InputStream& readEnumValue(uint64_t& uint64BackingTypeValue);
- virtual InputStream& readVersionValue(Version& versionValue);
+ virtual InputStream& readVersionValue(Version& versionValue);
- virtual void beginReadSerializableStruct(const SerializableStruct& serializableStruct);
- virtual void endReadSerializableStruct(const SerializableStruct& serializableStruct);
+ virtual void beginReadSerializableStruct(const SerializableStruct& serializableStruct);
+ virtual void endReadSerializableStruct(const SerializableStruct& serializableStruct);
- virtual void beginReadSerializablePolymorphicStruct(uint32_t& serialId);
- virtual void endReadSerializablePolymorphicStruct(const uint32_t& serialId);
+ virtual void beginReadSerializablePolymorphicStruct(uint32_t& serialId);
+ virtual void endReadSerializablePolymorphicStruct(const uint32_t& serialId);
- virtual void readSerializableVariant(SerializableVariant& serializableVariant);
+ virtual void readSerializableVariant(SerializableVariant& serializableVariant);
virtual void beginReadBoolVector();
virtual void beginReadInt8Vector();
@@ -107,17 +109,18 @@ class DBusInputStream: public InputStream {
virtual void beginReadVectorOfVectors();
virtual void beginReadVectorOfMaps();
- virtual bool hasMoreVectorElements();
- virtual void endReadVector();
+ virtual void beginReadVectorOfSerializablePolymorphicStructs();
+
+ virtual bool hasMoreVectorElements();
+ virtual void endReadVector();
- virtual void beginReadMap();
- virtual bool hasMoreMapElements();
- virtual void endReadMap();
+ virtual void beginReadMap();
+ virtual bool hasMoreMapElements();
+ virtual void endReadMap();
virtual void beginReadMapElement();
virtual void endReadMapElement();
-
- /**
+ /**
* Creates a #DBusInputMessageStream which can be used to deserialize and read data from the given #DBusMessage.
* As no message-signature is checked, the user is responsible to ensure that the correct data types are read in the correct order.
*
@@ -192,7 +195,7 @@ class DBusInputStream: public InputStream {
* @param inputMessageStream The stream which the value is to be read from
* @return The given inputMessageStream to allow for successive reading
*/
- template <typename _BasicType>
+ template<typename _BasicType>
DBusInputStream& readBasicTypeValue(_BasicType& val) {
if (sizeof(val) > 1)
alignToBoundary(sizeof(_BasicType));
@@ -201,7 +204,7 @@ class DBusInputStream: public InputStream {
return *this;
}
- private:
+private:
inline void beginReadGenericVector() {
uint32_t vectorByteSize;
readBasicTypeValue(vectorByteSize);
@@ -224,12 +227,10 @@ class DBusInputStream: public InputStream {
std::stack<position_t> savedStreamPositions_;
};
-
inline void DBusInputStream::setError() {
exception_ = new CommonAPI::DBus::DBusError();
}
-
} // namespace DBus
} // namespace CommonAPI
diff --git a/src/CommonAPI/DBus/DBusOutputStream.cpp b/src/CommonAPI/DBus/DBusOutputStream.cpp
index 46cf191..b94c4d5 100644
--- a/src/CommonAPI/DBus/DBusOutputStream.cpp
+++ b/src/CommonAPI/DBus/DBusOutputStream.cpp
@@ -13,43 +13,80 @@ DBusOutputStream::DBusOutputStream(DBusMessage dbusMessage) :
dbusMessage_(dbusMessage) {
}
-DBusOutputStream::~DBusOutputStream() {
-}
+DBusOutputStream::~DBusOutputStream() {}
OutputStream& DBusOutputStream::writeValue(const bool& boolValue) {
- alignToBoundary(4);
- writeBasicTypeValue(boolValue);
- alignToBoundary(4);
- return *this;
+ alignToBoundary(4);
+ writeBasicTypeValue(boolValue);
+ alignToBoundary(4);
+ return *this;
}
-OutputStream& DBusOutputStream::writeValue(const int8_t& int8Value) { return writeBasicTypeValue(int8Value); }
-OutputStream& DBusOutputStream::writeValue(const int16_t& int16Value) { return writeBasicTypeValue(int16Value); }
-OutputStream& DBusOutputStream::writeValue(const int32_t& int32Value) { return writeBasicTypeValue(int32Value); }
-OutputStream& DBusOutputStream::writeValue(const int64_t& int64Value) { return writeBasicTypeValue(int64Value); }
+OutputStream& DBusOutputStream::writeValue(const int8_t& int8Value) {
+ return writeBasicTypeValue(int8Value);
+}
+OutputStream& DBusOutputStream::writeValue(const int16_t& int16Value) {
+ return writeBasicTypeValue(int16Value);
+}
+OutputStream& DBusOutputStream::writeValue(const int32_t& int32Value) {
+ return writeBasicTypeValue(int32Value);
+}
+OutputStream& DBusOutputStream::writeValue(const int64_t& int64Value) {
+ return writeBasicTypeValue(int64Value);
+}
-OutputStream& DBusOutputStream::writeValue(const uint8_t& uint8Value) { return writeBasicTypeValue(uint8Value); }
-OutputStream& DBusOutputStream::writeValue(const uint16_t& uint16Value) { return writeBasicTypeValue(uint16Value); }
-OutputStream& DBusOutputStream::writeValue(const uint32_t& uint32Value) { return writeBasicTypeValue(uint32Value); }
-OutputStream& DBusOutputStream::writeValue(const uint64_t& uint64Value) { return writeBasicTypeValue(uint64Value); }
+OutputStream& DBusOutputStream::writeValue(const uint8_t& uint8Value) {
+ return writeBasicTypeValue(uint8Value);
+}
+OutputStream& DBusOutputStream::writeValue(const uint16_t& uint16Value) {
+ return writeBasicTypeValue(uint16Value);
+}
+OutputStream& DBusOutputStream::writeValue(const uint32_t& uint32Value) {
+ return writeBasicTypeValue(uint32Value);
+}
+OutputStream& DBusOutputStream::writeValue(const uint64_t& uint64Value) {
+ return writeBasicTypeValue(uint64Value);
+}
-OutputStream& DBusOutputStream::writeValue(const float& floatValue) { return writeBasicTypeValue((double) floatValue); }
-OutputStream& DBusOutputStream::writeValue(const double& doubleValue) { return writeBasicTypeValue(doubleValue); }
+OutputStream& DBusOutputStream::writeValue(const float& floatValue) {
+ return writeBasicTypeValue((double) floatValue);
+}
+OutputStream& DBusOutputStream::writeValue(const double& doubleValue) {
+ return writeBasicTypeValue(doubleValue);
+}
-OutputStream& DBusOutputStream::writeValue(const std::string& stringValue) { return writeString(stringValue.c_str(), stringValue.length()); }
+OutputStream& DBusOutputStream::writeValue(const std::string& stringValue) {
+ return writeString(stringValue.c_str(), stringValue.length());
+}
OutputStream& DBusOutputStream::writeValue(const ByteBuffer& byteBufferValue) {
return *this;
}
-OutputStream& DBusOutputStream::writeEnumValue(const int8_t& int8BackingTypeValue) { return writeValue(int8BackingTypeValue); }
-OutputStream& DBusOutputStream::writeEnumValue(const int16_t& int16BackingTypeValue) { return writeValue(int16BackingTypeValue); }
-OutputStream& DBusOutputStream::writeEnumValue(const int32_t& int32BackingTypeValue) { return writeValue(int32BackingTypeValue); }
-OutputStream& DBusOutputStream::writeEnumValue(const int64_t& int64BackingTypeValue) { return writeValue(int64BackingTypeValue); }
-OutputStream& DBusOutputStream::writeEnumValue(const uint8_t& uint8BackingTypeValue) { return writeValue(uint8BackingTypeValue); }
-OutputStream& DBusOutputStream::writeEnumValue(const uint16_t& uint16BackingTypeValue) { return writeValue(uint16BackingTypeValue); }
-OutputStream& DBusOutputStream::writeEnumValue(const uint32_t& uint32BackingTypeValue) { return writeValue(uint32BackingTypeValue); }
-OutputStream& DBusOutputStream::writeEnumValue(const uint64_t& uint64BackingTypeValue) { return writeValue(uint64BackingTypeValue); }
+OutputStream& DBusOutputStream::writeEnumValue(const int8_t& int8BackingTypeValue) {
+ return writeValue(int8BackingTypeValue);
+}
+OutputStream& DBusOutputStream::writeEnumValue(const int16_t& int16BackingTypeValue) {
+ return writeValue(int16BackingTypeValue);
+}
+OutputStream& DBusOutputStream::writeEnumValue(const int32_t& int32BackingTypeValue) {
+ return writeValue(int32BackingTypeValue);
+}
+OutputStream& DBusOutputStream::writeEnumValue(const int64_t& int64BackingTypeValue) {
+ return writeValue(int64BackingTypeValue);
+}
+OutputStream& DBusOutputStream::writeEnumValue(const uint8_t& uint8BackingTypeValue) {
+ return writeValue(uint8BackingTypeValue);
+}
+OutputStream& DBusOutputStream::writeEnumValue(const uint16_t& uint16BackingTypeValue) {
+ return writeValue(uint16BackingTypeValue);
+}
+OutputStream& DBusOutputStream::writeEnumValue(const uint32_t& uint32BackingTypeValue) {
+ return writeValue(uint32BackingTypeValue);
+}
+OutputStream& DBusOutputStream::writeEnumValue(const uint64_t& uint64BackingTypeValue) {
+ return writeValue(uint64BackingTypeValue);
+}
void DBusOutputStream::beginWriteBoolVector(uint32_t sizeOfVector) {
beginWriteGenericVector();
@@ -168,6 +205,12 @@ void DBusOutputStream::beginWriteVectorOfMaps(uint32_t sizeOfVector) {
rememberCurrentStreamPosition();
}
+void DBusOutputStream::beginWriteVectorOfSerializablePolymorphicStructs(uint32_t sizeOfVector) {
+ beginWriteGenericVector();
+ alignToBoundary(8);
+ rememberCurrentStreamPosition();
+}
+
void DBusOutputStream::endWriteVector() {
uint32_t numOfWrittenBytes = getCurrentStreamPosition() - popRememberedStreamPosition();
writeBasicTypeValueAtPosition(popRememberedStreamPosition(), numOfWrittenBytes);
@@ -180,14 +223,17 @@ OutputStream& DBusOutputStream::writeVersionValue(const Version& versionValue) {
return *this;
}
-void DBusOutputStream::beginWriteSerializableStruct(const SerializableStruct& serializableStruct) { alignToBoundary(8); }
-void DBusOutputStream::endWriteSerializableStruct(const SerializableStruct& serializableStruct) { }
+void DBusOutputStream::beginWriteSerializableStruct(const SerializableStruct& serializableStruct) {
+ alignToBoundary(8);
+}
+void DBusOutputStream::endWriteSerializableStruct(const SerializableStruct& serializableStruct) {
+}
void DBusOutputStream::beginWriteSerializablePolymorphicStruct(const std::shared_ptr<SerializablePolymorphicStruct>& serializableStruct) {
- alignToBoundary(8);
- writeValue(serializableStruct->getSerialId());
+ alignToBoundary(8);
+ writeValue(serializableStruct->getSerialId());
- DBusTypeOutputStream typeOutputStream;
+ DBusTypeOutputStream typeOutputStream;
typeOutputStream.beginWriteStructType();
serializableStruct->createTypeSignature(typeOutputStream);
typeOutputStream.endWriteStructType();
@@ -198,7 +244,7 @@ void DBusOutputStream::beginWriteSerializablePolymorphicStruct(const std::shared
}
void DBusOutputStream::endWriteSerializablePolymorphicStruct(const std::shared_ptr<SerializablePolymorphicStruct>& serializableStruct) {
- endWriteSerializableStruct(*serializableStruct);
+ endWriteSerializableStruct(*serializableStruct);
}
void DBusOutputStream::beginWriteMap(size_t elementCount) {
@@ -217,7 +263,8 @@ void DBusOutputStream::endWriteMap() {
void DBusOutputStream::beginWriteMapElement() {
alignToBoundary(8);
}
-void DBusOutputStream::endWriteMapElement() {}
+void DBusOutputStream::endWriteMapElement() {
+}
void DBusOutputStream::beginWriteSerializableVariant(const SerializableVariant& serializableVariant) {
alignToBoundary(8);
@@ -228,7 +275,8 @@ void DBusOutputStream::beginWriteSerializableVariant(const SerializableVariant&
writeSignature(std::move(typeOutputStream.retrieveSignature()));
}
-void DBusOutputStream::endWriteSerializableVariant(const SerializableVariant& serializableVariant) {}
+void DBusOutputStream::endWriteSerializableVariant(const SerializableVariant& serializableVariant) {
+}
bool DBusOutputStream::hasError() const {
return dbusError_;
@@ -272,7 +320,6 @@ DBusOutputStream& DBusOutputStream::writeString(const char* cString, const uint3
return *this;
}
-
//Additional 0-termination, so this is 8 byte of \0
static const char eightByteZeroString[] = "\0\0\0\0\0\0\0";
@@ -308,10 +355,10 @@ void DBusOutputStream::beginWriteGenericVector() {
}
void DBusOutputStream::writeSignature(const std::string& signature) {
- const auto& signatureLength = signature.length();
- assert(signatureLength > 0 && signatureLength < 256);
+ const auto& signatureLength = signature.length();
+ assert(signatureLength > 0 && signatureLength < 256);
- const uint8_t wireLength = (uint8_t) signatureLength;
+ const uint8_t wireLength = (uint8_t) signatureLength;
*this << wireLength;
writeRawData(signature.c_str(), wireLength + 1);
}
diff --git a/src/CommonAPI/DBus/DBusOutputStream.h b/src/CommonAPI/DBus/DBusOutputStream.h
index 9c7105f..49b7ccd 100644
--- a/src/CommonAPI/DBus/DBusOutputStream.h
+++ b/src/CommonAPI/DBus/DBusOutputStream.h
@@ -27,112 +27,109 @@
namespace CommonAPI {
namespace DBus {
-
class DBusTypeOutputStream: public TypeOutputStream {
- public:
- DBusTypeOutputStream(): signature_("") {
+public:
+ DBusTypeOutputStream() :
+ signature_("") {
}
virtual ~DBusTypeOutputStream() {}
-
virtual void writeBoolType() {
signature_.append("b");
}
- virtual void writeInt8Type() {
+ virtual void writeInt8Type() {
signature_.append("y");
}
- virtual void writeInt16Type() {
+ virtual void writeInt16Type() {
signature_.append("n");
}
- virtual void writeInt32Type() {
+ virtual void writeInt32Type() {
signature_.append("i");
}
- virtual void writeInt64Type() {
+ virtual void writeInt64Type() {
signature_.append("x");
}
- virtual void writeUInt8Type() {
+ virtual void writeUInt8Type() {
signature_.append("y");
}
- virtual void writeUInt16Type() {
+ virtual void writeUInt16Type() {
signature_.append("q");
}
- virtual void writeUInt32Type() {
+ virtual void writeUInt32Type() {
signature_.append("u");
}
- virtual void writeUInt64Type() {
+ virtual void writeUInt64Type() {
signature_.append("t");
}
-
- virtual void writeInt8EnumType() {
+ virtual void writeInt8EnumType() {
signature_.append("y");
}
- virtual void writeInt16EnumType() {
+ virtual void writeInt16EnumType() {
signature_.append("n");
}
- virtual void writeInt32EnumType() {
+ virtual void writeInt32EnumType() {
signature_.append("i");
}
- virtual void writeInt64EnumType() {
+ virtual void writeInt64EnumType() {
signature_.append("x");
}
- virtual void writeUInt8EnumType() {
+ virtual void writeUInt8EnumType() {
signature_.append("y");
}
- virtual void writeUInt16EnumType() {
+ virtual void writeUInt16EnumType() {
signature_.append("n");
}
- virtual void writeUInt32EnumType() {
+ virtual void writeUInt32EnumType() {
signature_.append("u");
}
- virtual void writeUInt64EnumType() {
+ virtual void writeUInt64EnumType() {
signature_.append("t");
}
-
- virtual void writeFloatType() {
+ virtual void writeFloatType() {
signature_.append("d");
}
- virtual void writeDoubleType() {
+ virtual void writeDoubleType() {
signature_.append("d");
}
- virtual void writeStringType() {
+ virtual void writeStringType() {
signature_.append("s");
}
- virtual void writeByteBufferType() {
+ virtual void writeByteBufferType() {
signature_.append("ay");
}
- virtual void writeVersionType() {
+ virtual void writeVersionType() {
signature_.append("(uu)");
}
- virtual void beginWriteStructType() {
+ virtual void beginWriteStructType() {
signature_.append("(");
}
virtual void endWriteStructType() {
signature_.append(")");
}
- virtual void beginWriteMapType() {
+ virtual void beginWriteMapType() {
signature_.append("a{");
}
virtual void endWriteMapType() {
signature_.append("}");
}
- virtual void beginWriteVectorType() {
+ virtual void beginWriteVectorType() {
signature_.append("a");
}
- virtual void endWriteVectorType() {
+ virtual void endWriteVectorType() {
}
- virtual void writeVariantType() {
+ virtual void writeVariantType() {
signature_.append("(yv)");
}
@@ -140,18 +137,15 @@ class DBusTypeOutputStream: public TypeOutputStream {
return std::move(signature_);
}
-
- private:
+private:
std::string signature_;
};
-
/**
* Used to mark the position of a pointer within an array of bytes.
*/
typedef uint32_t position_t;
-
/**
* @class DBusOutputMessageStream
*
@@ -160,7 +154,7 @@ typedef uint32_t position_t;
* to match the actual data that is inserted via the #DBusOutputMessageStream.
*/
class DBusOutputStream: public OutputStream {
- public:
+public:
/**
* Creates a #DBusOutputMessageStream which can be used to serialize and write data into the given #DBusMessage. Any data written is buffered within the stream.
@@ -181,31 +175,31 @@ class DBusOutputStream: public OutputStream {
virtual OutputStream& writeValue(const int8_t& int8Value);
virtual OutputStream& writeValue(const int16_t& int16Value);
- virtual OutputStream& writeValue(const int32_t& int32Value);
- virtual OutputStream& writeValue(const int64_t& int64Value);
+ virtual OutputStream& writeValue(const int32_t& int32Value);
+ virtual OutputStream& writeValue(const int64_t& int64Value);
- virtual OutputStream& writeValue(const uint8_t& uint8Value);
- virtual OutputStream& writeValue(const uint16_t& uint16Value);
- virtual OutputStream& writeValue(const uint32_t& uint32Value);
- virtual OutputStream& writeValue(const uint64_t& uint64Value);
+ virtual OutputStream& writeValue(const uint8_t& uint8Value);
+ virtual OutputStream& writeValue(const uint16_t& uint16Value);
+ virtual OutputStream& writeValue(const uint32_t& uint32Value);
+ virtual OutputStream& writeValue(const uint64_t& uint64Value);
- virtual OutputStream& writeValue(const float& floatValue);
- virtual OutputStream& writeValue(const double& doubleValue);
+ virtual OutputStream& writeValue(const float& floatValue);
+ virtual OutputStream& writeValue(const double& doubleValue);
- virtual OutputStream& writeValue(const std::string& stringValue);
+ virtual OutputStream& writeValue(const std::string& stringValue);
- virtual OutputStream& writeValue(const ByteBuffer& byteBufferValue);
+ virtual OutputStream& writeValue(const ByteBuffer& byteBufferValue);
- virtual OutputStream& writeEnumValue(const int8_t& int8BackingTypeValue);
- virtual OutputStream& writeEnumValue(const int16_t& int16BackingTypeValue);
- virtual OutputStream& writeEnumValue(const int32_t& int32BackingTypeValue);
- virtual OutputStream& writeEnumValue(const int64_t& int64BackingTypeValue);
- virtual OutputStream& writeEnumValue(const uint8_t& uint8BackingTypeValue);
- virtual OutputStream& writeEnumValue(const uint16_t& uint16BackingTypeValue);
- virtual OutputStream& writeEnumValue(const uint32_t& uint32BackingTypeValue);
- virtual OutputStream& writeEnumValue(const uint64_t& uint64BackingTypeValue);
+ virtual OutputStream& writeEnumValue(const int8_t& int8BackingTypeValue);
+ virtual OutputStream& writeEnumValue(const int16_t& int16BackingTypeValue);
+ virtual OutputStream& writeEnumValue(const int32_t& int32BackingTypeValue);
+ virtual OutputStream& writeEnumValue(const int64_t& int64BackingTypeValue);
+ virtual OutputStream& writeEnumValue(const uint8_t& uint8BackingTypeValue);
+ virtual OutputStream& writeEnumValue(const uint16_t& uint16BackingTypeValue);
+ virtual OutputStream& writeEnumValue(const uint32_t& uint32BackingTypeValue);
+ virtual OutputStream& writeEnumValue(const uint64_t& uint64BackingTypeValue);
- virtual void beginWriteBoolVector(uint32_t sizeOfVector);
+ virtual void beginWriteBoolVector(uint32_t sizeOfVector);
virtual void beginWriteInt8Vector(uint32_t sizeOfVector);
virtual void beginWriteInt16Vector(uint32_t sizeOfVector);
virtual void beginWriteInt32Vector(uint32_t sizeOfVector);
@@ -234,6 +228,8 @@ class DBusOutputStream: public OutputStream {
virtual void beginWriteVectorOfVectors(uint32_t sizeOfVector);
virtual void beginWriteVectorOfMaps(uint32_t sizeOfVector);
+ virtual void beginWriteVectorOfSerializablePolymorphicStructs(uint32_t sizeOfVector);
+
virtual void endWriteVector();
virtual OutputStream& writeVersionValue(const Version& versionValue);
@@ -241,8 +237,8 @@ class DBusOutputStream: public OutputStream {
virtual void beginWriteSerializableStruct(const SerializableStruct& serializableStruct);
virtual void endWriteSerializableStruct(const SerializableStruct& serializableStruct);
- virtual void beginWriteSerializablePolymorphicStruct(const std::shared_ptr<SerializablePolymorphicStruct>& serializableStruct);
- virtual void endWriteSerializablePolymorphicStruct(const std::shared_ptr<SerializablePolymorphicStruct>& serializableStruct);
+ virtual void beginWriteSerializablePolymorphicStruct(const std::shared_ptr<SerializablePolymorphicStruct>& serializableStruct);
+ virtual void endWriteSerializablePolymorphicStruct(const std::shared_ptr<SerializablePolymorphicStruct>& serializableStruct);
virtual void beginWriteMap(size_t elementCount);
virtual void endWriteMap();
@@ -325,10 +321,10 @@ class DBusOutputStream: public OutputStream {
bool writeRawDataAtPosition(size_t position, const char* rawDataPtr, const size_t sizeInByte);
- protected:
+protected:
std::string payload_;
- private:
+private:
void beginWriteGenericVector();
void writeSignature(const std::string& signature);
@@ -345,7 +341,6 @@ class DBusOutputStream: public OutputStream {
std::stack<position_t> savedStreamPositions_;
};
-
} // namespace DBus
} // namespace CommonAPI
diff --git a/src/test/DBusPolymorphicTest.cpp b/src/test/DBusPolymorphicTest.cpp
new file mode 100644
index 0000000..4e5ab0b
--- /dev/null
+++ b/src/test/DBusPolymorphicTest.cpp
@@ -0,0 +1,286 @@
+/* Copyright (C) 2013 BMW Group
+ * Author: Manfred Bathelt (manfred.bathelt@bmw.de)
+ * Author: Juergen Gehring (juergen.gehring@bmw.de)
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#include <gtest/gtest.h>
+#include <commonapi/tests/DerivedTypeCollection.h>
+#include <commonapi/tests/TestInterfaceDBusProxy.h>
+#include <commonapi/tests/TestInterfaceDBusStubAdapter.h>
+#include <commonapi/tests/TestInterfaceStubDefault.h>
+
+#ifndef COMMONAPI_INTERNAL_COMPILATION
+#define COMMONAPI_INTERNAL_COMPILATION
+#endif
+#include <CommonAPI/DBus/DBusRuntime.h>
+
+#ifndef COMMONAPI_INTERNAL_COMPILATION
+#define COMMONAPI_INTERNAL_COMPILATION
+#endif
+
+static const std::string commonApiAddress =
+ "local:CommonAPI.DBus.tests.DBusProxyTestInterface:CommonAPI.DBus.tests.DBusProxyTestService";
+static const std::string interfaceName = "CommonAPI.DBus.tests.DBusProxyTestInterface";
+static const std::string busName = "CommonAPI.DBus.tests.DBusProxyTestService";
+static const std::string objectPath = "/CommonAPI/DBus/tests/DBusProxyTestService";
+
+class PolymorphicTestStub: public commonapi::tests::TestInterfaceStubDefault {
+public:
+ void TestArrayOfPolymorphicStructMethod(
+ const std::shared_ptr<CommonAPI::ClientId> clientId,
+ std::vector<std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestPolymorphicStruct>> inArray) {
+ numberOfContainedElements_ = inArray.size();
+
+ if (numberOfContainedElements_ > 0) {
+ std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct> extended =
+ std::dynamic_pointer_cast<
+ commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct>(
+ inArray[0]);
+ firstElementIsExtended_ = (extended != NULL);
+ }
+
+ if (numberOfContainedElements_ > 1) {
+ std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct> extended =
+ std::dynamic_pointer_cast<
+ commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct>(
+ inArray[1]);
+ secondElementIsExtended_ = (extended != NULL);
+ }
+ }
+
+ void TestMapOfPolymorphicStructMethod(
+ const std::shared_ptr<CommonAPI::ClientId> clientId,
+ std::unordered_map<uint8_t, std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestPolymorphicStruct>> inMap) {
+ numberOfContainedElements_ = inMap.size();
+
+ auto iteratorFirst = inMap.find(5);
+ auto iteratorSecond = inMap.find(10);
+
+ if (iteratorFirst != inMap.end()) {
+ std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct> extended =
+ std::dynamic_pointer_cast<
+ commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct>(
+ iteratorFirst->second);
+ firstElementIsExtended_ = (extended != NULL);
+ }
+
+ if (iteratorSecond != inMap.end()) {
+ std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct> extended =
+ std::dynamic_pointer_cast<
+ commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct>(
+ iteratorSecond->second);
+ secondElementIsExtended_ = (extended != NULL);
+ }
+ }
+
+ void TestMapWithPolymorphicStructKeyMethod(const std::shared_ptr<CommonAPI::ClientId> clientId,
+ commonapi::tests::DerivedTypeCollection::MapPolymorphicToInt inMap) {
+ numberOfContainedElements_ = inMap.size();
+
+ auto mapIterator = inMap.begin();
+
+ if (mapIterator != inMap.end()) {
+ std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct> extended =
+ std::dynamic_pointer_cast<
+ commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct>(
+ mapIterator->first);
+ firstElementIsExtended_ = (extended != NULL);
+ mapIterator++;
+ }
+
+ if (mapIterator != inMap.end()) {
+ std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct> extended =
+ std::dynamic_pointer_cast<
+ commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct>(
+ mapIterator->first);
+ firstElementIsExtended_ = (extended != NULL);
+ }
+
+ }
+
+ void TestStructWithPolymorphicMemberMethod(const std::shared_ptr<CommonAPI::ClientId> clientId,
+ commonapi::tests::DerivedTypeCollection::StructWithPolymorphicMember inStruct) {
+ if (inStruct.polymorphicMember != NULL) {
+ numberOfContainedElements_ = 1;
+
+ std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct> extended =
+ std::dynamic_pointer_cast<
+ commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct>(
+ inStruct.polymorphicMember);
+ firstElementIsExtended_ = (extended != NULL);
+ }
+ }
+
+ int numberOfContainedElements_;
+ bool firstElementIsExtended_;
+ bool secondElementIsExtended_;
+};
+
+class PolymorphicTest: public ::testing::Test {
+protected:
+ void SetUp() {
+ auto runtime = std::dynamic_pointer_cast<CommonAPI::DBus::DBusRuntime>(CommonAPI::Runtime::load());
+
+ serviceFactory = std::dynamic_pointer_cast<CommonAPI::DBus::DBusFactory>(runtime->createFactory());
+
+ proxyDBusConnection_ = CommonAPI::DBus::DBusConnection::getSessionBus();
+ ASSERT_TRUE(proxyDBusConnection_->connect());
+
+ proxy_ = std::make_shared<commonapi::tests::TestInterfaceDBusProxy>(
+ serviceFactory,
+ commonApiAddress,
+ interfaceName,
+ busName,
+ objectPath,
+ proxyDBusConnection_);
+ proxy_->init();
+
+ registerTestStub();
+
+ for (unsigned int i = 0; !proxy_->isAvailable() && i < 100; ++i) {
+ usleep(10000);
+ }
+ ASSERT_TRUE(proxy_->isAvailable());
+
+ baseInstance1_ = std::make_shared<commonapi::tests::DerivedTypeCollection::TestPolymorphicStruct>();
+ baseInstance1_->testString = "abc";
+
+ extendedInstance1_ = std::make_shared<commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct>();
+ extendedInstance1_->additionalValue = 7;
+ }
+
+ std::shared_ptr<CommonAPI::DBus::DBusFactory> serviceFactory;
+
+ virtual void TearDown() {
+ deregisterTestStub();
+ usleep(30000);
+ }
+
+ void registerTestStub() {
+ stubDBusConnection_ = CommonAPI::DBus::DBusConnection::getSessionBus();
+ ASSERT_TRUE(stubDBusConnection_->connect());
+
+ testStub = std::make_shared<PolymorphicTestStub>();
+ stubAdapter_ = std::make_shared<commonapi::tests::TestInterfaceDBusStubAdapter>(
+ serviceFactory,
+ commonApiAddress,
+ interfaceName,
+ busName,
+ objectPath,
+ stubDBusConnection_,
+ testStub);
+ stubAdapter_->init();
+
+ const bool isStubAdapterRegistered = CommonAPI::DBus::DBusServicePublisher::getInstance()->registerService(
+ stubAdapter_);
+ ASSERT_TRUE(isStubAdapterRegistered);
+ }
+
+ void deregisterTestStub() {
+ const bool isStubAdapterUnregistered = CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterService(
+ stubAdapter_->getAddress());
+ ASSERT_TRUE(isStubAdapterUnregistered);
+ stubAdapter_.reset();
+
+ if (stubDBusConnection_->isConnected()) {
+ stubDBusConnection_->disconnect();
+ }
+ stubDBusConnection_.reset();
+ }
+
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> proxyDBusConnection_;
+ std::shared_ptr<commonapi::tests::TestInterfaceDBusProxy> proxy_;
+
+ std::shared_ptr<CommonAPI::DBus::DBusConnection> stubDBusConnection_;
+ std::shared_ptr<commonapi::tests::TestInterfaceDBusStubAdapter> stubAdapter_;
+
+ std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestPolymorphicStruct> baseInstance1_;
+ std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestExtendedPolymorphicStruct> extendedInstance1_;
+
+ std::shared_ptr<PolymorphicTestStub> testStub;
+};
+
+TEST_F(PolymorphicTest, SendVectorOfBaseType) {
+ CommonAPI::CallStatus stat;
+ std::vector<std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestPolymorphicStruct> > inputArray;
+ inputArray.push_back(baseInstance1_);
+
+ proxy_->TestArrayOfPolymorphicStructMethod(inputArray, stat);
+
+ ASSERT_EQ(stat, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(testStub->numberOfContainedElements_, 1);
+ ASSERT_FALSE(testStub->firstElementIsExtended_);
+}
+
+TEST_F(PolymorphicTest, SendVectorOfExtendedType) {
+ CommonAPI::CallStatus stat;
+ std::vector<std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestPolymorphicStruct> > inputArray;
+ inputArray.push_back(extendedInstance1_);
+
+ proxy_->TestArrayOfPolymorphicStructMethod(inputArray, stat);
+
+ ASSERT_EQ(stat, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(testStub->numberOfContainedElements_, 1);
+ ASSERT_TRUE(testStub->firstElementIsExtended_);
+}
+
+TEST_F(PolymorphicTest, SendVectorOfBaseAndExtendedType) {
+ CommonAPI::CallStatus stat;
+ std::vector<std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestPolymorphicStruct> > inputArray;
+ inputArray.push_back(baseInstance1_);
+ inputArray.push_back(extendedInstance1_);
+
+ proxy_->TestArrayOfPolymorphicStructMethod(inputArray, stat);
+
+ ASSERT_EQ(stat, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(testStub->numberOfContainedElements_, 2);
+ ASSERT_FALSE(testStub->firstElementIsExtended_);
+ ASSERT_TRUE(testStub->secondElementIsExtended_);
+}
+
+TEST_F(PolymorphicTest, SendMapOfBaseAndExtendedType) {
+ CommonAPI::CallStatus stat;
+ std::unordered_map<uint8_t, std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestPolymorphicStruct> > inputMap;
+ inputMap.insert( {5, baseInstance1_});
+ inputMap.insert( {10, extendedInstance1_});
+
+ proxy_->TestMapOfPolymorphicStructMethod(inputMap, stat);
+
+ ASSERT_EQ(stat, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(testStub->numberOfContainedElements_, 2);
+ ASSERT_FALSE(testStub->firstElementIsExtended_);
+ ASSERT_TRUE(testStub->secondElementIsExtended_);
+}
+
+// disabled as it leads to a crash in libdbus which does not allow container types as map keys in its signature validation
+TEST_F(PolymorphicTest, DISABLED_SendMapOfBaseAndExtendedTypeAsKey) {
+ CommonAPI::CallStatus stat;
+ std::unordered_map<std::shared_ptr<commonapi::tests::DerivedTypeCollection::TestPolymorphicStruct>, uint8_t> inputMap;
+ inputMap.insert( {baseInstance1_, 5});
+ inputMap.insert( {extendedInstance1_, 10});
+
+ proxy_->TestMapWithPolymorphicStructKeyMethod(inputMap, stat);
+
+ ASSERT_EQ(stat, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(testStub->numberOfContainedElements_, 2);
+ ASSERT_FALSE(testStub->firstElementIsExtended_);
+ ASSERT_TRUE(testStub->secondElementIsExtended_);
+}
+
+TEST_F(PolymorphicTest, SendStructWithPolymorphicMember) {
+ CommonAPI::CallStatus stat;
+ commonapi::tests::DerivedTypeCollection::StructWithPolymorphicMember inputStruct;
+ inputStruct.polymorphicMember = extendedInstance1_;
+
+ proxy_->TestStructWithPolymorphicMemberMethod(inputStruct, stat);
+
+ ASSERT_EQ(stat, CommonAPI::CallStatus::SUCCESS);
+ ASSERT_EQ(testStub->numberOfContainedElements_, 1);
+ ASSERT_TRUE(testStub->firstElementIsExtended_);
+}
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/src/test/commonapi/tests/DerivedTypeCollection.cpp b/src/test/commonapi/tests/DerivedTypeCollection.cpp
index 1aa8988..a6e80fb 100644
--- a/src/test/commonapi/tests/DerivedTypeCollection.cpp
+++ b/src/test/commonapi/tests/DerivedTypeCollection.cpp
@@ -77,6 +77,7 @@ void TestStruct::writeToOutputStream(CommonAPI::OutputStream& outputStream) cons
outputStream << uintValue;
}
+<<<<<<< Upstream, based on origin/master
TestStructEnumMap::TestStructEnumMap(const TestEnumMap& testMapValue):
testMap(testMapValue)
{
@@ -98,6 +99,127 @@ void TestStructEnumMap::readFromInputStream(CommonAPI::InputStream& inputStream)
void TestStructEnumMap::writeToOutputStream(CommonAPI::OutputStream& outputStream) const {
outputStream << testMap;
+=======
+TestPolymorphicStruct::TestPolymorphicStruct(const PredefinedTypeCollection::TestString& testStringValue, const uint16_t& uintValueValue):
+ testString(testStringValue),
+ uintValue(uintValueValue)
+{
+}
+
+TestPolymorphicStruct* TestPolymorphicStruct::createInstance(const uint32_t& serialId) {
+ if (serialId == SERIAL_ID)
+ return new TestPolymorphicStruct;
+
+ const std::function<TestPolymorphicStruct*()> createDerivedInstanceFuncs[] = {
+ [&]() { return TestExtendedPolymorphicStruct::createInstance(serialId); }
+ };
+
+ for (auto& createDerivedInstanceFunc : createDerivedInstanceFuncs) {
+ TestPolymorphicStruct* derivedInstance = createDerivedInstanceFunc();
+ if (derivedInstance != NULL)
+ return derivedInstance;
+ }
+
+ return NULL;
+}
+
+uint32_t TestPolymorphicStruct::getSerialId() const {
+ return SERIAL_ID;
+}
+
+void TestPolymorphicStruct::createTypeSignature(CommonAPI::TypeOutputStream& typeOutputStream) const {
+ TestPolymorphicStruct::writeToTypeOutputStream(typeOutputStream);
+}
+
+bool operator==(const TestPolymorphicStruct& lhs, const TestPolymorphicStruct& rhs) {
+ if (&lhs == &rhs)
+ return true;
+
+ return
+ lhs.testString == rhs.testString &&
+ lhs.uintValue == rhs.uintValue
+ ;
+}
+
+void TestPolymorphicStruct::readFromInputStream(CommonAPI::InputStream& inputStream) {
+ inputStream >> testString;
+ inputStream >> uintValue;
+}
+
+void TestPolymorphicStruct::writeToOutputStream(CommonAPI::OutputStream& outputStream) const {
+ outputStream << testString;
+ outputStream << uintValue;
+}
+
+TestExtendedPolymorphicStruct::TestExtendedPolymorphicStruct(const PredefinedTypeCollection::TestString& testStringValue, const uint16_t& uintValueValue, const uint32_t& additionalValueValue):
+ TestPolymorphicStruct(testStringValue, uintValueValue),
+ additionalValue(additionalValueValue)
+{
+}
+
+TestExtendedPolymorphicStruct* TestExtendedPolymorphicStruct::createInstance(const uint32_t& serialId) {
+ if (serialId == SERIAL_ID)
+ return new TestExtendedPolymorphicStruct;
+
+ return NULL;
+}
+
+uint32_t TestExtendedPolymorphicStruct::getSerialId() const {
+ return SERIAL_ID;
+}
+
+void TestExtendedPolymorphicStruct::createTypeSignature(CommonAPI::TypeOutputStream& typeOutputStream) const {
+ TestExtendedPolymorphicStruct::writeToTypeOutputStream(typeOutputStream);
+}
+
+bool operator==(const TestExtendedPolymorphicStruct& lhs, const TestExtendedPolymorphicStruct& rhs) {
+ if (&lhs == &rhs)
+ return true;
+
+ return
+ static_cast<TestExtendedPolymorphicStruct::TestPolymorphicStruct>(lhs) == static_cast<TestExtendedPolymorphicStruct::TestPolymorphicStruct>(rhs) &&
+ lhs.additionalValue == rhs.additionalValue
+ ;
+}
+
+void TestExtendedPolymorphicStruct::readFromInputStream(CommonAPI::InputStream& inputStream) {
+ TestPolymorphicStruct::readFromInputStream(inputStream);
+ inputStream >> additionalValue;
+}
+
+void TestExtendedPolymorphicStruct::writeToOutputStream(CommonAPI::OutputStream& outputStream) const {
+ TestPolymorphicStruct::writeToOutputStream(outputStream);
+ outputStream << additionalValue;
+}
+
+
+
+StructWithPolymorphicMember::StructWithPolymorphicMember(const uint32_t& numberValueValue, const std::shared_ptr<TestPolymorphicStruct>& polymorphicMemberValue):
+ numberValue(numberValueValue),
+ polymorphicMember(polymorphicMemberValue)
+{
+}
+
+
+bool operator==(const StructWithPolymorphicMember& lhs, const StructWithPolymorphicMember& rhs) {
+ if (&lhs == &rhs)
+ return true;
+
+ return
+ lhs.numberValue == rhs.numberValue &&
+ lhs.polymorphicMember == rhs.polymorphicMember
+ ;
+}
+
+void StructWithPolymorphicMember::readFromInputStream(CommonAPI::InputStream& inputStream) {
+ inputStream >> numberValue;
+ inputStream >> polymorphicMember;
+}
+
+void StructWithPolymorphicMember::writeToOutputStream(CommonAPI::OutputStream& outputStream) const {
+ outputStream << numberValue;
+ outputStream << polymorphicMember;
+>>>>>>> 3439751 Fixed (de-)serialization of polymorphic structs. Added unit test for polymorphic structs.
}
} // namespace DerivedTypeCollection
diff --git a/src/test/commonapi/tests/DerivedTypeCollection.h b/src/test/commonapi/tests/DerivedTypeCollection.h
index d2b2468..195b155 100644
--- a/src/test/commonapi/tests/DerivedTypeCollection.h
+++ b/src/test/commonapi/tests/DerivedTypeCollection.h
@@ -138,6 +138,7 @@ namespace DerivedTypeCollection {
// Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1
struct TestEnumMissingValueComparator;
typedef std::vector<uint64_t> TestArrayUInt64;
+<<<<<<< Upstream, based on origin/master
struct TestStructEnumMap: CommonAPI::SerializableStruct {
TestEnumMap testMap;
@@ -153,6 +154,75 @@ namespace DerivedTypeCollection {
typeOutputStream.writeInt32Type();
typeOutputStream.writeStringType();
typeOutputStream.endWriteMapType();
+=======
+ struct TestPolymorphicStruct: CommonAPI::SerializablePolymorphicStruct {
+ /**
+ * the name of the property
+ */
+ PredefinedTypeCollection::TestString testString;
+ /**
+ * the actual value
+ */
+ uint16_t uintValue;
+
+ TestPolymorphicStruct() = default;
+ TestPolymorphicStruct(const PredefinedTypeCollection::TestString& testString, const uint16_t& uintValue);
+
+ enum: uint32_t { SERIAL_ID = 0x34650f46 };
+
+ static TestPolymorphicStruct* createInstance(const uint32_t& serialId);
+
+ virtual uint32_t getSerialId() const;
+ virtual void createTypeSignature(CommonAPI::TypeOutputStream& typeOutputStream) const;
+
+ virtual void readFromInputStream(CommonAPI::InputStream& inputStream);
+ virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const;
+
+ static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
+ typeOutputStream.writeStringType();
+ typeOutputStream.writeUInt16Type();
+ }
+ };
+ struct TestExtendedPolymorphicStruct: TestPolymorphicStruct {
+ uint32_t additionalValue;
+
+ TestExtendedPolymorphicStruct() = default;
+ TestExtendedPolymorphicStruct(const PredefinedTypeCollection::TestString& testString, const uint16_t& uintValue, const uint32_t& additionalValue);
+
+ enum: uint32_t { SERIAL_ID = 0xc967fead };
+
+ static TestExtendedPolymorphicStruct* createInstance(const uint32_t& serialId);
+
+ virtual uint32_t getSerialId() const;
+ virtual void createTypeSignature(CommonAPI::TypeOutputStream& typeOutputStream) const;
+
+ virtual void readFromInputStream(CommonAPI::InputStream& inputStream);
+ virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const;
+
+ static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
+ TestPolymorphicStruct::writeToTypeOutputStream(typeOutputStream);
+ typeOutputStream.writeUInt32Type();
+ }
+ };
+ typedef std::unordered_map<uint8_t, std::shared_ptr<TestPolymorphicStruct>> MapIntToPolymorphic;
+ typedef std::unordered_map<std::shared_ptr<TestPolymorphicStruct>, uint8_t> MapPolymorphicToInt;
+ struct StructWithPolymorphicMember: CommonAPI::SerializableStruct {
+ uint32_t numberValue;
+ std::shared_ptr<TestPolymorphicStruct> polymorphicMember;
+
+ StructWithPolymorphicMember() = default;
+ StructWithPolymorphicMember(const uint32_t& numberValue, const std::shared_ptr<TestPolymorphicStruct>& polymorphicMember);
+
+
+ virtual void readFromInputStream(CommonAPI::InputStream& inputStream);
+ virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const;
+
+ static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
+ typeOutputStream.writeUInt32Type();
+ typeOutputStream.beginWriteStructType();
+ typeOutputStream.writeStringType();typeOutputStream.writeUInt16Type();
+ typeOutputStream.endWriteStructType();
+>>>>>>> 3439751 Fixed (de-)serialization of polymorphic structs. Added unit test for polymorphic structs.
}
};
@@ -259,8 +329,21 @@ bool operator==(const TestStruct& lhs, const TestStruct& rhs);
inline bool operator!=(const TestStruct& lhs, const TestStruct& rhs) {
return !(lhs == rhs);
}
+<<<<<<< Upstream, based on origin/master
bool operator==(const TestStructEnumMap& lhs, const TestStructEnumMap& rhs);
inline bool operator!=(const TestStructEnumMap& lhs, const TestStructEnumMap& rhs) {
+=======
+bool operator==(const TestPolymorphicStruct& lhs, const TestPolymorphicStruct& rhs);
+inline bool operator!=(const TestPolymorphicStruct& lhs, const TestPolymorphicStruct& rhs) {
+ return !(lhs == rhs);
+}
+bool operator==(const TestExtendedPolymorphicStruct& lhs, const TestExtendedPolymorphicStruct& rhs);
+inline bool operator!=(const TestExtendedPolymorphicStruct& lhs, const TestExtendedPolymorphicStruct& rhs) {
+ return !(lhs == rhs);
+}
+bool operator==(const StructWithPolymorphicMember& lhs, const StructWithPolymorphicMember& rhs);
+inline bool operator!=(const StructWithPolymorphicMember& lhs, const StructWithPolymorphicMember& rhs) {
+>>>>>>> 3439751 Fixed (de-)serialization of polymorphic structs. Added unit test for polymorphic structs.
return !(lhs == rhs);
}
diff --git a/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp b/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp
index 93a8574..9b38b8e 100644
--- a/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp
+++ b/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp
@@ -157,6 +157,82 @@ std::future<CommonAPI::CallStatus> TestInterfaceDBusProxy::testDerivedTypeMethod
testEnumExtended2InValue, testMapInValue,
std::move(callback));
}
+void TestInterfaceDBusProxy::TestArrayOfPolymorphicStructMethod(const std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>& inArray, CommonAPI::CallStatus& callStatus) {
+ CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>>,
+ CommonAPI::DBus::DBusSerializableArguments<> >::callMethodWithReply(
+ *this,
+ "TestArrayOfPolymorphicStructMethod",
+ "a(uv)",
+ inArray,
+ callStatus
+ );
+}
+std::future<CommonAPI::CallStatus> TestInterfaceDBusProxy::TestArrayOfPolymorphicStructMethodAsync(const std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>& inArray, TestArrayOfPolymorphicStructMethodAsyncCallback callback) {
+ return CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>>,
+ CommonAPI::DBus::DBusSerializableArguments<> >::callMethodAsync(
+ *this,
+ "TestArrayOfPolymorphicStructMethod",
+ "a(uv)",
+ inArray,
+ std::move(callback));
+}
+void TestInterfaceDBusProxy::TestMapOfPolymorphicStructMethod(const DerivedTypeCollection::MapIntToPolymorphic& inMap, CommonAPI::CallStatus& callStatus) {
+ CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<DerivedTypeCollection::MapIntToPolymorphic>,
+ CommonAPI::DBus::DBusSerializableArguments<> >::callMethodWithReply(
+ *this,
+ "TestMapOfPolymorphicStructMethod",
+ "a{y(uv)}",
+ inMap,
+ callStatus
+ );
+}
+std::future<CommonAPI::CallStatus> TestInterfaceDBusProxy::TestMapOfPolymorphicStructMethodAsync(const DerivedTypeCollection::MapIntToPolymorphic& inMap, TestMapOfPolymorphicStructMethodAsyncCallback callback) {
+ return CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<DerivedTypeCollection::MapIntToPolymorphic>,
+ CommonAPI::DBus::DBusSerializableArguments<> >::callMethodAsync(
+ *this,
+ "TestMapOfPolymorphicStructMethod",
+ "a{y(uv)}",
+ inMap,
+ std::move(callback));
+}
+void TestInterfaceDBusProxy::TestMapWithPolymorphicStructKeyMethod(const DerivedTypeCollection::MapPolymorphicToInt& inMap, CommonAPI::CallStatus& callStatus) {
+ CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<DerivedTypeCollection::MapPolymorphicToInt>,
+ CommonAPI::DBus::DBusSerializableArguments<> >::callMethodWithReply(
+ *this,
+ "TestMapWithPolymorphicStructKeyMethod",
+ "a{(uv)y}",
+ inMap,
+ callStatus
+ );
+}
+std::future<CommonAPI::CallStatus> TestInterfaceDBusProxy::TestMapWithPolymorphicStructKeyMethodAsync(const DerivedTypeCollection::MapPolymorphicToInt& inMap, TestMapWithPolymorphicStructKeyMethodAsyncCallback callback) {
+ return CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<DerivedTypeCollection::MapPolymorphicToInt>,
+ CommonAPI::DBus::DBusSerializableArguments<> >::callMethodAsync(
+ *this,
+ "TestMapWithPolymorphicStructKeyMethod",
+ "a{(uv)y}",
+ inMap,
+ std::move(callback));
+}
+void TestInterfaceDBusProxy::TestStructWithPolymorphicMemberMethod(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, CommonAPI::CallStatus& callStatus) {
+ CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<DerivedTypeCollection::StructWithPolymorphicMember>,
+ CommonAPI::DBus::DBusSerializableArguments<> >::callMethodWithReply(
+ *this,
+ "TestStructWithPolymorphicMemberMethod",
+ "(u(uv))",
+ inStruct,
+ callStatus
+ );
+}
+std::future<CommonAPI::CallStatus> TestInterfaceDBusProxy::TestStructWithPolymorphicMemberMethodAsync(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, TestStructWithPolymorphicMemberMethodAsyncCallback callback) {
+ return CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<DerivedTypeCollection::StructWithPolymorphicMember>,
+ CommonAPI::DBus::DBusSerializableArguments<> >::callMethodAsync(
+ *this,
+ "TestStructWithPolymorphicMemberMethod",
+ "(u(uv))",
+ inStruct,
+ std::move(callback));
+}
diff --git a/src/test/commonapi/tests/TestInterfaceDBusProxy.h b/src/test/commonapi/tests/TestInterfaceDBusProxy.h
index 5ac89be..805030a 100644
--- a/src/test/commonapi/tests/TestInterfaceDBusProxy.h
+++ b/src/test/commonapi/tests/TestInterfaceDBusProxy.h
@@ -60,6 +60,14 @@ class TestInterfaceDBusProxy: virtual public TestInterfaceProxyBase, virtual pub
virtual std::future<CommonAPI::CallStatus> testVoidDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2Value, const DerivedTypeCollection::TestMap& testMapValue, TestVoidDerivedTypeMethodAsyncCallback callback);
virtual void testDerivedTypeMethod(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, CommonAPI::CallStatus& callStatus, DerivedTypeCollection::TestEnumExtended2& testEnumExtended2OutValue, DerivedTypeCollection::TestMap& testMapOutValue);
virtual std::future<CommonAPI::CallStatus> testDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, TestDerivedTypeMethodAsyncCallback callback);
+ virtual void TestArrayOfPolymorphicStructMethod(const std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>& inArray, CommonAPI::CallStatus& callStatus);
+ virtual std::future<CommonAPI::CallStatus> TestArrayOfPolymorphicStructMethodAsync(const std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>& inArray, TestArrayOfPolymorphicStructMethodAsyncCallback callback);
+ virtual void TestMapOfPolymorphicStructMethod(const DerivedTypeCollection::MapIntToPolymorphic& inMap, CommonAPI::CallStatus& callStatus);
+ virtual std::future<CommonAPI::CallStatus> TestMapOfPolymorphicStructMethodAsync(const DerivedTypeCollection::MapIntToPolymorphic& inMap, TestMapOfPolymorphicStructMethodAsyncCallback callback);
+ virtual void TestMapWithPolymorphicStructKeyMethod(const DerivedTypeCollection::MapPolymorphicToInt& inMap, CommonAPI::CallStatus& callStatus);
+ virtual std::future<CommonAPI::CallStatus> TestMapWithPolymorphicStructKeyMethodAsync(const DerivedTypeCollection::MapPolymorphicToInt& inMap, TestMapWithPolymorphicStructKeyMethodAsyncCallback callback);
+ virtual void TestStructWithPolymorphicMemberMethod(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, CommonAPI::CallStatus& callStatus);
+ virtual std::future<CommonAPI::CallStatus> TestStructWithPolymorphicMemberMethodAsync(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, TestStructWithPolymorphicMemberMethodAsyncCallback callback);
virtual void getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const;
diff --git a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp
index bbd9a93..0b6231b 100644
--- a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp
+++ b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp
@@ -117,6 +117,21 @@ const char* TestInterfaceDBusStubAdapter::getMethodsDBusIntrospectionXmlData() c
"<arg name=\"testEnumExtended2OutValue\" type=\"i\" direction=\"out\" />\n"
"<arg name=\"testMapOutValue\" type=\"a{ua(sq)}\" direction=\"out\" />\n"
"</method>\n"
+<<<<<<< Upstream, based on origin/master
+=======
+ "<method name=\"TestArrayOfPolymorphicStructMethod\">\n"
+ "<arg name=\"inArray\" type=\"a(uv)\" direction=\"in\" />\n"
+ "</method>\n"
+ "<method name=\"TestMapOfPolymorphicStructMethod\">\n"
+ "<arg name=\"inMap\" type=\"a{y(uv)}\" direction=\"in\" />\n"
+ "</method>\n"
+ "<method name=\"TestMapWithPolymorphicStructKeyMethod\">\n"
+ "<arg name=\"inMap\" type=\"a{(uv)y}\" direction=\"in\" />\n"
+ "</method>\n"
+ "<method name=\"TestStructWithPolymorphicMemberMethod\">\n"
+ "<arg name=\"inStruct\" type=\"(u(uv))\" direction=\"in\" />\n"
+ "</method>\n"
+>>>>>>> 3439751 Fixed (de-)serialization of polymorphic structs. Added unit test for polymorphic structs.
;
return introspectionData;
@@ -191,6 +206,26 @@ static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher<
std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap>,
std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap>
> testDerivedTypeMethodStubDispatcher(&TestInterfaceStub::testDerivedTypeMethod, "ia{ua(sq)}");
+static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher<
+ TestInterfaceStub,
+ std::tuple<std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>>,
+ std::tuple<>
+ > testArrayOfPolymorphicStructMethodStubDispatcher(&TestInterfaceStub::TestArrayOfPolymorphicStructMethod, "");
+static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher<
+ TestInterfaceStub,
+ std::tuple<DerivedTypeCollection::MapIntToPolymorphic>,
+ std::tuple<>
+ > testMapOfPolymorphicStructMethodStubDispatcher(&TestInterfaceStub::TestMapOfPolymorphicStructMethod, "");
+static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher<
+ TestInterfaceStub,
+ std::tuple<DerivedTypeCollection::MapPolymorphicToInt>,
+ std::tuple<>
+ > testMapWithPolymorphicStructKeyMethodStubDispatcher(&TestInterfaceStub::TestMapWithPolymorphicStructKeyMethod, "");
+static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher<
+ TestInterfaceStub,
+ std::tuple<DerivedTypeCollection::StructWithPolymorphicMember>,
+ std::tuple<>
+ > testStructWithPolymorphicMemberMethodStubDispatcher(&TestInterfaceStub::TestStructWithPolymorphicMemberMethod, "");
void TestInterfaceDBusStubAdapter::fireTestPredefinedTypeAttributeAttributeChanged(const uint32_t& value) {
CommonAPI::DBus::DBusStubSignalHelper<CommonAPI::DBus::DBusSerializableArguments<uint32_t>>
@@ -378,7 +413,11 @@ const TestInterfaceDBusStubAdapter::StubDispatcherTable& TestInterfaceDBusStubAd
{ { "testVoidPredefinedTypeMethod", "us" }, &commonapi::tests::testVoidPredefinedTypeMethodStubDispatcher },
{ { "testPredefinedTypeMethod", "us" }, &commonapi::tests::testPredefinedTypeMethodStubDispatcher },
{ { "testVoidDerivedTypeMethod", "ia{ua(sq)}" }, &commonapi::tests::testVoidDerivedTypeMethodStubDispatcher },
- { { "testDerivedTypeMethod", "ia{ua(sq)}" }, &commonapi::tests::testDerivedTypeMethodStubDispatcher }
+ { { "testDerivedTypeMethod", "ia{ua(sq)}" }, &commonapi::tests::testDerivedTypeMethodStubDispatcher },
+ { { "TestArrayOfPolymorphicStructMethod", "a(uv)" }, &commonapi::tests::testArrayOfPolymorphicStructMethodStubDispatcher },
+ { { "TestMapOfPolymorphicStructMethod", "a{y(uv)}" }, &commonapi::tests::testMapOfPolymorphicStructMethodStubDispatcher },
+ { { "TestMapWithPolymorphicStructKeyMethod", "a{(uv)y}" }, &commonapi::tests::testMapWithPolymorphicStructKeyMethodStubDispatcher },
+ { { "TestStructWithPolymorphicMemberMethod", "(u(uv))" }, &commonapi::tests::testStructWithPolymorphicMemberMethodStubDispatcher }
,
{ { "subscribeForTestSelectiveBroadcastSelective", "" }, &commonapi::tests::subscribeTestSelectiveBroadcastSelectiveStubDispatcher },
{ { "unsubscribeFromTestSelectiveBroadcastSelective", "" }, &commonapi::tests::unsubscribeTestSelectiveBroadcastSelectiveStubDispatcher },
diff --git a/src/test/commonapi/tests/TestInterfaceProxy.h b/src/test/commonapi/tests/TestInterfaceProxy.h
index f5f70ed..8343deb 100644
--- a/src/test/commonapi/tests/TestInterfaceProxy.h
+++ b/src/test/commonapi/tests/TestInterfaceProxy.h
@@ -169,6 +169,86 @@ class TestInterfaceProxy: virtual public TestInterface, virtual public TestInter
* It will provide the same value for CallStatus as will be handed to the callback.
*/
virtual std::future<CommonAPI::CallStatus> testDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, TestDerivedTypeMethodAsyncCallback callback);
+ /**
+ * Calls TestArrayOfPolymorphicStructMethod with synchronous semantics.
+ *
+ * All const parameters are input parameters to this method.
+ * The CallStatus will be filled when the method returns and indicate either
+ * "SUCCESS" or which type of error has occurred. In case of an error, ONLY the CallStatus
+ * will be set.
+ */
+ virtual void TestArrayOfPolymorphicStructMethod(const std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>& inArray, CommonAPI::CallStatus& callStatus);
+ /**
+ * Calls TestArrayOfPolymorphicStructMethod with asynchronous semantics.
+ *
+ * The provided callback will be called when the reply to this call arrives or
+ * an error occurs during the call. The CallStatus will indicate either "SUCCESS"
+ * or which type of error has occurred. In case of any error, ONLY the CallStatus
+ * will have a defined value.
+ * The std::future returned by this method will be fulfilled at arrival of the reply.
+ * It will provide the same value for CallStatus as will be handed to the callback.
+ */
+ virtual std::future<CommonAPI::CallStatus> TestArrayOfPolymorphicStructMethodAsync(const std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>& inArray, TestArrayOfPolymorphicStructMethodAsyncCallback callback);
+ /**
+ * Calls TestMapOfPolymorphicStructMethod with synchronous semantics.
+ *
+ * All const parameters are input parameters to this method.
+ * The CallStatus will be filled when the method returns and indicate either
+ * "SUCCESS" or which type of error has occurred. In case of an error, ONLY the CallStatus
+ * will be set.
+ */
+ virtual void TestMapOfPolymorphicStructMethod(const DerivedTypeCollection::MapIntToPolymorphic& inMap, CommonAPI::CallStatus& callStatus);
+ /**
+ * Calls TestMapOfPolymorphicStructMethod with asynchronous semantics.
+ *
+ * The provided callback will be called when the reply to this call arrives or
+ * an error occurs during the call. The CallStatus will indicate either "SUCCESS"
+ * or which type of error has occurred. In case of any error, ONLY the CallStatus
+ * will have a defined value.
+ * The std::future returned by this method will be fulfilled at arrival of the reply.
+ * It will provide the same value for CallStatus as will be handed to the callback.
+ */
+ virtual std::future<CommonAPI::CallStatus> TestMapOfPolymorphicStructMethodAsync(const DerivedTypeCollection::MapIntToPolymorphic& inMap, TestMapOfPolymorphicStructMethodAsyncCallback callback);
+ /**
+ * Calls TestMapWithPolymorphicStructKeyMethod with synchronous semantics.
+ *
+ * All const parameters are input parameters to this method.
+ * The CallStatus will be filled when the method returns and indicate either
+ * "SUCCESS" or which type of error has occurred. In case of an error, ONLY the CallStatus
+ * will be set.
+ */
+ virtual void TestMapWithPolymorphicStructKeyMethod(const DerivedTypeCollection::MapPolymorphicToInt& inMap, CommonAPI::CallStatus& callStatus);
+ /**
+ * Calls TestMapWithPolymorphicStructKeyMethod with asynchronous semantics.
+ *
+ * The provided callback will be called when the reply to this call arrives or
+ * an error occurs during the call. The CallStatus will indicate either "SUCCESS"
+ * or which type of error has occurred. In case of any error, ONLY the CallStatus
+ * will have a defined value.
+ * The std::future returned by this method will be fulfilled at arrival of the reply.
+ * It will provide the same value for CallStatus as will be handed to the callback.
+ */
+ virtual std::future<CommonAPI::CallStatus> TestMapWithPolymorphicStructKeyMethodAsync(const DerivedTypeCollection::MapPolymorphicToInt& inMap, TestMapWithPolymorphicStructKeyMethodAsyncCallback callback);
+ /**
+ * Calls TestStructWithPolymorphicMemberMethod with synchronous semantics.
+ *
+ * All const parameters are input parameters to this method.
+ * The CallStatus will be filled when the method returns and indicate either
+ * "SUCCESS" or which type of error has occurred. In case of an error, ONLY the CallStatus
+ * will be set.
+ */
+ virtual void TestStructWithPolymorphicMemberMethod(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, CommonAPI::CallStatus& callStatus);
+ /**
+ * Calls TestStructWithPolymorphicMemberMethod with asynchronous semantics.
+ *
+ * The provided callback will be called when the reply to this call arrives or
+ * an error occurs during the call. The CallStatus will indicate either "SUCCESS"
+ * or which type of error has occurred. In case of any error, ONLY the CallStatus
+ * will have a defined value.
+ * The std::future returned by this method will be fulfilled at arrival of the reply.
+ * It will provide the same value for CallStatus as will be handed to the callback.
+ */
+ virtual std::future<CommonAPI::CallStatus> TestStructWithPolymorphicMemberMethodAsync(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, TestStructWithPolymorphicMemberMethodAsyncCallback callback);
/**
@@ -335,6 +415,42 @@ template <typename ... _AttributeExtensions>
std::future<CommonAPI::CallStatus> TestInterfaceProxy<_AttributeExtensions...>::testDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, TestDerivedTypeMethodAsyncCallback callback) {
return delegate_->testDerivedTypeMethodAsync(testEnumExtended2InValue, testMapInValue, callback);
}
+template <typename ... _AttributeExtensions>
+void TestInterfaceProxy<_AttributeExtensions...>::TestArrayOfPolymorphicStructMethod(const std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>& inArray, CommonAPI::CallStatus& callStatus) {
+ delegate_->TestArrayOfPolymorphicStructMethod(inArray, callStatus);
+}
+
+template <typename ... _AttributeExtensions>
+std::future<CommonAPI::CallStatus> TestInterfaceProxy<_AttributeExtensions...>::TestArrayOfPolymorphicStructMethodAsync(const std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>& inArray, TestArrayOfPolymorphicStructMethodAsyncCallback callback) {
+ return delegate_->TestArrayOfPolymorphicStructMethodAsync(inArray, callback);
+}
+template <typename ... _AttributeExtensions>
+void TestInterfaceProxy<_AttributeExtensions...>::TestMapOfPolymorphicStructMethod(const DerivedTypeCollection::MapIntToPolymorphic& inMap, CommonAPI::CallStatus& callStatus) {
+ delegate_->TestMapOfPolymorphicStructMethod(inMap, callStatus);
+}
+
+template <typename ... _AttributeExtensions>
+std::future<CommonAPI::CallStatus> TestInterfaceProxy<_AttributeExtensions...>::TestMapOfPolymorphicStructMethodAsync(const DerivedTypeCollection::MapIntToPolymorphic& inMap, TestMapOfPolymorphicStructMethodAsyncCallback callback) {
+ return delegate_->TestMapOfPolymorphicStructMethodAsync(inMap, callback);
+}
+template <typename ... _AttributeExtensions>
+void TestInterfaceProxy<_AttributeExtensions...>::TestMapWithPolymorphicStructKeyMethod(const DerivedTypeCollection::MapPolymorphicToInt& inMap, CommonAPI::CallStatus& callStatus) {
+ delegate_->TestMapWithPolymorphicStructKeyMethod(inMap, callStatus);
+}
+
+template <typename ... _AttributeExtensions>
+std::future<CommonAPI::CallStatus> TestInterfaceProxy<_AttributeExtensions...>::TestMapWithPolymorphicStructKeyMethodAsync(const DerivedTypeCollection::MapPolymorphicToInt& inMap, TestMapWithPolymorphicStructKeyMethodAsyncCallback callback) {
+ return delegate_->TestMapWithPolymorphicStructKeyMethodAsync(inMap, callback);
+}
+template <typename ... _AttributeExtensions>
+void TestInterfaceProxy<_AttributeExtensions...>::TestStructWithPolymorphicMemberMethod(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, CommonAPI::CallStatus& callStatus) {
+ delegate_->TestStructWithPolymorphicMemberMethod(inStruct, callStatus);
+}
+
+template <typename ... _AttributeExtensions>
+std::future<CommonAPI::CallStatus> TestInterfaceProxy<_AttributeExtensions...>::TestStructWithPolymorphicMemberMethodAsync(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, TestStructWithPolymorphicMemberMethodAsyncCallback callback) {
+ return delegate_->TestStructWithPolymorphicMemberMethodAsync(inStruct, callback);
+}
template <typename ... _AttributeExtensions>
std::string TestInterfaceProxy<_AttributeExtensions...>::getAddress() const {
diff --git a/src/test/commonapi/tests/TestInterfaceProxyBase.h b/src/test/commonapi/tests/TestInterfaceProxyBase.h
index 52d260e..3be09cb 100644
--- a/src/test/commonapi/tests/TestInterfaceProxyBase.h
+++ b/src/test/commonapi/tests/TestInterfaceProxyBase.h
@@ -14,6 +14,7 @@
#include <commonapi/tests/DerivedTypeCollection.h>
+#include <commonapi/tests/PredefinedTypeCollection.h>
#if !defined (COMMONAPI_INTERNAL_COMPILATION)
#define COMMONAPI_INTERNAL_COMPILATION
@@ -21,6 +22,7 @@
#include <CommonAPI/InputStream.h>
#include <CommonAPI/OutputStream.h>
+#include <CommonAPI/SerializableStruct.h>
#include <cstdint>
#include <unordered_map>
#include <vector>
@@ -51,6 +53,10 @@ class TestInterfaceProxyBase: virtual public CommonAPI::Proxy {
typedef std::function<void(const CommonAPI::CallStatus&, const uint32_t&, const std::string&)> TestPredefinedTypeMethodAsyncCallback;
typedef std::function<void(const CommonAPI::CallStatus&)> TestVoidDerivedTypeMethodAsyncCallback;
typedef std::function<void(const CommonAPI::CallStatus&, const DerivedTypeCollection::TestEnumExtended2&, const DerivedTypeCollection::TestMap&)> TestDerivedTypeMethodAsyncCallback;
+ typedef std::function<void(const CommonAPI::CallStatus&)> TestArrayOfPolymorphicStructMethodAsyncCallback;
+ typedef std::function<void(const CommonAPI::CallStatus&)> TestMapOfPolymorphicStructMethodAsyncCallback;
+ typedef std::function<void(const CommonAPI::CallStatus&)> TestMapWithPolymorphicStructKeyMethodAsyncCallback;
+ typedef std::function<void(const CommonAPI::CallStatus&)> TestStructWithPolymorphicMemberMethodAsyncCallback;
virtual TestPredefinedTypeAttributeAttribute& getTestPredefinedTypeAttributeAttribute() = 0;
virtual TestDerivedStructAttributeAttribute& getTestDerivedStructAttributeAttribute() = 0;
@@ -70,6 +76,14 @@ class TestInterfaceProxyBase: virtual public CommonAPI::Proxy {
virtual std::future<CommonAPI::CallStatus> testVoidDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2Value, const DerivedTypeCollection::TestMap& testMapValue, TestVoidDerivedTypeMethodAsyncCallback callback) = 0;
virtual void testDerivedTypeMethod(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, CommonAPI::CallStatus& callStatus, DerivedTypeCollection::TestEnumExtended2& testEnumExtended2OutValue, DerivedTypeCollection::TestMap& testMapOutValue) = 0;
virtual std::future<CommonAPI::CallStatus> testDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, TestDerivedTypeMethodAsyncCallback callback) = 0;
+ virtual void TestArrayOfPolymorphicStructMethod(const std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>& inArray, CommonAPI::CallStatus& callStatus) = 0;
+ virtual std::future<CommonAPI::CallStatus> TestArrayOfPolymorphicStructMethodAsync(const std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>& inArray, TestArrayOfPolymorphicStructMethodAsyncCallback callback) = 0;
+ virtual void TestMapOfPolymorphicStructMethod(const DerivedTypeCollection::MapIntToPolymorphic& inMap, CommonAPI::CallStatus& callStatus) = 0;
+ virtual std::future<CommonAPI::CallStatus> TestMapOfPolymorphicStructMethodAsync(const DerivedTypeCollection::MapIntToPolymorphic& inMap, TestMapOfPolymorphicStructMethodAsyncCallback callback) = 0;
+ virtual void TestMapWithPolymorphicStructKeyMethod(const DerivedTypeCollection::MapPolymorphicToInt& inMap, CommonAPI::CallStatus& callStatus) = 0;
+ virtual std::future<CommonAPI::CallStatus> TestMapWithPolymorphicStructKeyMethodAsync(const DerivedTypeCollection::MapPolymorphicToInt& inMap, TestMapWithPolymorphicStructKeyMethodAsyncCallback callback) = 0;
+ virtual void TestStructWithPolymorphicMemberMethod(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, CommonAPI::CallStatus& callStatus) = 0;
+ virtual std::future<CommonAPI::CallStatus> TestStructWithPolymorphicMemberMethodAsync(const DerivedTypeCollection::StructWithPolymorphicMember& inStruct, TestStructWithPolymorphicMemberMethodAsyncCallback callback) = 0;
};
} // namespace tests
diff --git a/src/test/commonapi/tests/TestInterfaceStub.h b/src/test/commonapi/tests/TestInterfaceStub.h
index a769102..93c67ac 100644
--- a/src/test/commonapi/tests/TestInterfaceStub.h
+++ b/src/test/commonapi/tests/TestInterfaceStub.h
@@ -13,6 +13,7 @@
#include <commonapi/tests/DerivedTypeCollection.h>
+#include <commonapi/tests/PredefinedTypeCollection.h>
#include "TestInterface.h"
@@ -22,6 +23,7 @@
#include <CommonAPI/InputStream.h>
#include <CommonAPI/OutputStream.h>
+#include <CommonAPI/SerializableStruct.h>
#include <cstdint>
#include <unordered_map>
#include <unordered_set>
@@ -147,6 +149,14 @@ class TestInterfaceStub : public CommonAPI::Stub<TestInterfaceStubAdapter , Test
virtual void testVoidDerivedTypeMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestEnumExtended2 testEnumExtended2Value, DerivedTypeCollection::TestMap testMapValue) = 0;
/// This is the method that will be called on remote calls on the method testDerivedTypeMethod.
virtual void testDerivedTypeMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestEnumExtended2 testEnumExtended2InValue, DerivedTypeCollection::TestMap testMapInValue, DerivedTypeCollection::TestEnumExtended2& testEnumExtended2OutValue, DerivedTypeCollection::TestMap& testMapOutValue) = 0;
+ /// This is the method that will be called on remote calls on the method TestArrayOfPolymorphicStructMethod.
+ virtual void TestArrayOfPolymorphicStructMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>> inArray) = 0;
+ /// This is the method that will be called on remote calls on the method TestMapOfPolymorphicStructMethod.
+ virtual void TestMapOfPolymorphicStructMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::MapIntToPolymorphic inMap) = 0;
+ /// This is the method that will be called on remote calls on the method TestMapWithPolymorphicStructKeyMethod.
+ virtual void TestMapWithPolymorphicStructKeyMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::MapPolymorphicToInt inMap) = 0;
+ /// This is the method that will be called on remote calls on the method TestStructWithPolymorphicMemberMethod.
+ virtual void TestStructWithPolymorphicMemberMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::StructWithPolymorphicMember inStruct) = 0;
/// Sends a broadcast event for TestPredefinedTypeBroadcast.
virtual void fireTestPredefinedTypeBroadcastEvent(const uint32_t& uint32Value, const std::string& stringValue) = 0;
/**
diff --git a/src/test/commonapi/tests/TestInterfaceStubDefault.cpp b/src/test/commonapi/tests/TestInterfaceStubDefault.cpp
index b24ab3a..93d43bc 100644
--- a/src/test/commonapi/tests/TestInterfaceStubDefault.cpp
+++ b/src/test/commonapi/tests/TestInterfaceStubDefault.cpp
@@ -206,6 +206,38 @@ void TestInterfaceStubDefault::testDerivedTypeMethod(DerivedTypeCollection::Test
// No operation in default
}
+void TestInterfaceStubDefault::TestArrayOfPolymorphicStructMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>> inArray) {
+ // Call old style methods in default
+ TestArrayOfPolymorphicStructMethod(inArray);
+}
+void TestInterfaceStubDefault::TestArrayOfPolymorphicStructMethod(std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>> inArray) {
+ // No operation in default
+}
+
+void TestInterfaceStubDefault::TestMapOfPolymorphicStructMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::MapIntToPolymorphic inMap) {
+ // Call old style methods in default
+ TestMapOfPolymorphicStructMethod(inMap);
+}
+void TestInterfaceStubDefault::TestMapOfPolymorphicStructMethod(DerivedTypeCollection::MapIntToPolymorphic inMap) {
+ // No operation in default
+}
+
+void TestInterfaceStubDefault::TestMapWithPolymorphicStructKeyMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::MapPolymorphicToInt inMap) {
+ // Call old style methods in default
+ TestMapWithPolymorphicStructKeyMethod(inMap);
+}
+void TestInterfaceStubDefault::TestMapWithPolymorphicStructKeyMethod(DerivedTypeCollection::MapPolymorphicToInt inMap) {
+ // No operation in default
+}
+
+void TestInterfaceStubDefault::TestStructWithPolymorphicMemberMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::StructWithPolymorphicMember inStruct) {
+ // Call old style methods in default
+ TestStructWithPolymorphicMemberMethod(inStruct);
+}
+void TestInterfaceStubDefault::TestStructWithPolymorphicMemberMethod(DerivedTypeCollection::StructWithPolymorphicMember inStruct) {
+ // No operation in default
+}
+
void TestInterfaceStubDefault::fireTestPredefinedTypeBroadcastEvent(const uint32_t& uint32Value, const std::string& stringValue) {
stubAdapter_->fireTestPredefinedTypeBroadcastEvent(uint32Value, stringValue);
diff --git a/src/test/commonapi/tests/TestInterfaceStubDefault.h b/src/test/commonapi/tests/TestInterfaceStubDefault.h
index 5e4a0fc..04998cb 100644
--- a/src/test/commonapi/tests/TestInterfaceStubDefault.h
+++ b/src/test/commonapi/tests/TestInterfaceStubDefault.h
@@ -60,6 +60,18 @@ class TestInterfaceStubDefault : public TestInterfaceStub {
virtual void testDerivedTypeMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::TestEnumExtended2 testEnumExtended2InValue, DerivedTypeCollection::TestMap testMapInValue, DerivedTypeCollection::TestEnumExtended2& testEnumExtended2OutValue, DerivedTypeCollection::TestMap& testMapOutValue);
virtual void testDerivedTypeMethod(DerivedTypeCollection::TestEnumExtended2 testEnumExtended2InValue, DerivedTypeCollection::TestMap testMapInValue, DerivedTypeCollection::TestEnumExtended2& testEnumExtended2OutValue, DerivedTypeCollection::TestMap& testMapOutValue);
+ virtual void TestArrayOfPolymorphicStructMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>> inArray);
+ virtual void TestArrayOfPolymorphicStructMethod(std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>> inArray);
+
+ virtual void TestMapOfPolymorphicStructMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::MapIntToPolymorphic inMap);
+ virtual void TestMapOfPolymorphicStructMethod(DerivedTypeCollection::MapIntToPolymorphic inMap);
+
+ virtual void TestMapWithPolymorphicStructKeyMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::MapPolymorphicToInt inMap);
+ virtual void TestMapWithPolymorphicStructKeyMethod(DerivedTypeCollection::MapPolymorphicToInt inMap);
+
+ virtual void TestStructWithPolymorphicMemberMethod(const std::shared_ptr<CommonAPI::ClientId> clientId, DerivedTypeCollection::StructWithPolymorphicMember inStruct);
+ virtual void TestStructWithPolymorphicMemberMethod(DerivedTypeCollection::StructWithPolymorphicMember inStruct);
+
virtual void fireTestPredefinedTypeBroadcastEvent(const uint32_t& uint32Value, const std::string& stringValue);
virtual void fireTestSelectiveBroadcastSelective(const std::shared_ptr<CommonAPI::ClientIdList> receivers = NULL);
diff --git a/src/test/test-derived-types.fidl b/src/test/test-derived-types.fidl
index 75e077b..b309b2b 100644
--- a/src/test/test-derived-types.fidl
+++ b/src/test/test-derived-types.fidl
@@ -56,8 +56,24 @@ typeCollection DerivedTypeCollection {
UInt16 uintValue
}
- struct TestStructEnumMap {
- TestEnumMap testMap
+ struct TestPolymorphicStruct polymorphic {
+ <** @description : the name of the property **>
+ PredefinedTypeCollection.TestString testString
+
+ <** @description : the actual value **>
+ UInt16 uintValue
+ }
+
+ struct TestExtendedPolymorphicStruct extends TestPolymorphicStruct {
+ UInt32 additionalValue
+ }
+
+ map MapIntToPolymorphic { UInt8 to DerivedTypeCollection.TestPolymorphicStruct }
+ map MapPolymorphicToInt { DerivedTypeCollection.TestPolymorphicStruct to UInt8 }
+
+ struct StructWithPolymorphicMember {
+ UInt32 numberValue
+ DerivedTypeCollection.TestPolymorphicStruct polymorphicMember
}
}
diff --git a/src/test/test-interface-proxy.fidl b/src/test/test-interface-proxy.fidl
index 0dd97fe..4e57734 100644
--- a/src/test/test-interface-proxy.fidl
+++ b/src/test/test-interface-proxy.fidl
@@ -51,6 +51,31 @@ interface TestInterface {
}
}
+ method TestArrayOfPolymorphicStructMethod {
+ in {
+ DerivedTypeCollection.TestPolymorphicStruct [] inArray
+ }
+ }
+
+ method TestMapOfPolymorphicStructMethod {
+ in {
+ DerivedTypeCollection.MapIntToPolymorphic inMap
+ }
+ }
+
+ method TestMapWithPolymorphicStructKeyMethod {
+ in {
+ DerivedTypeCollection.MapPolymorphicToInt inMap
+ }
+ }
+
+ method TestStructWithPolymorphicMemberMethod {
+ in {
+ DerivedTypeCollection.StructWithPolymorphicMember inStruct
+ }
+ }
+
+
broadcast TestPredefinedTypeBroadcast {
out {
UInt32 uint32Value