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 #ifndef COMMONAPI_TESTS_TEST_INTERFACE_PROXY_H_
5 #define COMMONAPI_TESTS_TEST_INTERFACE_PROXY_H_
7 #include "TestInterfaceProxyBase.h"
8 #include <CommonAPI/AttributeExtension.h>
13 template <typename ... _AttributeExtensions>
14 class TestInterfaceProxy: virtual public TestInterface, virtual public TestInterfaceProxyBase, public _AttributeExtensions... {
16 TestInterfaceProxy(std::shared_ptr<CommonAPI::Proxy> delegate);
17 ~TestInterfaceProxy();
19 virtual TestPredefinedTypeAttributeAttribute& getTestPredefinedTypeAttributeAttribute();
20 virtual TestDerivedStructAttributeAttribute& getTestDerivedStructAttributeAttribute();
21 virtual TestDerivedArrayAttributeAttribute& getTestDerivedArrayAttributeAttribute();
23 virtual TestPredefinedTypeBroadcastEvent& getTestPredefinedTypeBroadcastEvent();
26 virtual void testVoidPredefinedTypeMethod(const uint32_t& uint32Value, const std::string& stringValue, CommonAPI::CallStatus& callStatus);
27 virtual std::future<CommonAPI::CallStatus> testVoidPredefinedTypeMethodAsync(const uint32_t& uint32Value, const std::string& stringValue, TestVoidPredefinedTypeMethodAsyncCallback callback);
29 virtual void testPredefinedTypeMethod(const uint32_t& uint32InValue, const std::string& stringInValue, CommonAPI::CallStatus& callStatus, uint32_t& uint32OutValue, std::string& stringOutValue);
30 virtual std::future<CommonAPI::CallStatus> testPredefinedTypeMethodAsync(const uint32_t& uint32InValue, const std::string& stringInValue, TestPredefinedTypeMethodAsyncCallback callback);
32 virtual void testVoidDerivedTypeMethod(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2Value, const DerivedTypeCollection::TestMap& testMapValue, CommonAPI::CallStatus& callStatus);
33 virtual std::future<CommonAPI::CallStatus> testVoidDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2Value, const DerivedTypeCollection::TestMap& testMapValue, TestVoidDerivedTypeMethodAsyncCallback callback);
35 virtual void testDerivedTypeMethod(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, CommonAPI::CallStatus& callStatus, DerivedTypeCollection::TestEnumExtended2& testEnumExtended2OutValue, DerivedTypeCollection::TestMap& testMapOutValue);
36 virtual std::future<CommonAPI::CallStatus> testDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, TestDerivedTypeMethodAsyncCallback callback);
38 virtual std::string getAddress() const;
39 virtual const std::string& getDomain() const;
40 virtual const std::string& getServiceId() const;
41 virtual const std::string& getInstanceId() const;
42 virtual bool isAvailable() const;
43 virtual CommonAPI::ProxyStatusEvent& getProxyStatusEvent();
44 virtual CommonAPI::InterfaceVersionAttribute& getInterfaceVersionAttribute();
47 std::shared_ptr<TestInterfaceProxyBase> delegate_;
50 namespace TestInterfaceExtensions {
51 template <template <typename > class _ExtensionType>
52 class TestPredefinedTypeAttributeAttributeExtension {
54 typedef _ExtensionType<TestInterfaceProxyBase::TestPredefinedTypeAttributeAttribute> extension_type;
56 static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestInterfaceProxyBase::TestPredefinedTypeAttributeAttribute>, extension_type>::value,
57 "Not CommonAPI Attribute Extension!");
59 TestPredefinedTypeAttributeAttributeExtension(TestInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestPredefinedTypeAttributeAttribute()) {
62 inline extension_type& getTestPredefinedTypeAttributeAttributeExtension() {
63 return attributeExtension_;
67 extension_type attributeExtension_;
70 template <template <typename > class _ExtensionType>
71 class TestDerivedStructAttributeAttributeExtension {
73 typedef _ExtensionType<TestInterfaceProxyBase::TestDerivedStructAttributeAttribute> extension_type;
75 static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestInterfaceProxyBase::TestDerivedStructAttributeAttribute>, extension_type>::value,
76 "Not CommonAPI Attribute Extension!");
78 TestDerivedStructAttributeAttributeExtension(TestInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestDerivedStructAttributeAttribute()) {
81 inline extension_type& getTestDerivedStructAttributeAttributeExtension() {
82 return attributeExtension_;
86 extension_type attributeExtension_;
89 template <template <typename > class _ExtensionType>
90 class TestDerivedArrayAttributeAttributeExtension {
92 typedef _ExtensionType<TestInterfaceProxyBase::TestDerivedArrayAttributeAttribute> extension_type;
94 static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestInterfaceProxyBase::TestDerivedArrayAttributeAttribute>, extension_type>::value,
95 "Not CommonAPI Attribute Extension!");
97 TestDerivedArrayAttributeAttributeExtension(TestInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestDerivedArrayAttributeAttribute()) {
100 inline extension_type& getTestDerivedArrayAttributeAttributeExtension() {
101 return attributeExtension_;
105 extension_type attributeExtension_;
108 } // namespace TestInterfaceExtensions
111 // TestInterfaceProxy Implementation
113 template <typename ... _AttributeExtensions>
114 TestInterfaceProxy<_AttributeExtensions...>::TestInterfaceProxy(std::shared_ptr<CommonAPI::Proxy> delegate):
115 delegate_(std::dynamic_pointer_cast<TestInterfaceProxyBase>(delegate)),
116 _AttributeExtensions(*(std::dynamic_pointer_cast<TestInterfaceProxyBase>(delegate)))... {
119 template <typename ... _AttributeExtensions>
120 TestInterfaceProxy<_AttributeExtensions...>::~TestInterfaceProxy() {
123 template <typename ... _AttributeExtensions>
124 typename TestInterfaceProxy<_AttributeExtensions...>::TestPredefinedTypeAttributeAttribute& TestInterfaceProxy<_AttributeExtensions...>::getTestPredefinedTypeAttributeAttribute() {
125 return delegate_->getTestPredefinedTypeAttributeAttribute();
128 template <typename ... _AttributeExtensions>
129 typename TestInterfaceProxy<_AttributeExtensions...>::TestDerivedStructAttributeAttribute& TestInterfaceProxy<_AttributeExtensions...>::getTestDerivedStructAttributeAttribute() {
130 return delegate_->getTestDerivedStructAttributeAttribute();
133 template <typename ... _AttributeExtensions>
134 typename TestInterfaceProxy<_AttributeExtensions...>::TestDerivedArrayAttributeAttribute& TestInterfaceProxy<_AttributeExtensions...>::getTestDerivedArrayAttributeAttribute() {
135 return delegate_->getTestDerivedArrayAttributeAttribute();
139 template <typename ... _AttributeExtensions>
140 typename TestInterfaceProxy<_AttributeExtensions...>::TestPredefinedTypeBroadcastEvent& TestInterfaceProxy<_AttributeExtensions...>::getTestPredefinedTypeBroadcastEvent() {
141 return delegate_->getTestPredefinedTypeBroadcastEvent();
145 template <typename ... _AttributeExtensions>
146 void TestInterfaceProxy<_AttributeExtensions...>::testVoidPredefinedTypeMethod(const uint32_t& uint32Value, const std::string& stringValue, CommonAPI::CallStatus& callStatus) {
147 delegate_->testVoidPredefinedTypeMethod(uint32Value, stringValue, callStatus);
150 template <typename ... _AttributeExtensions>
151 std::future<CommonAPI::CallStatus> TestInterfaceProxy<_AttributeExtensions...>::testVoidPredefinedTypeMethodAsync(const uint32_t& uint32Value, const std::string& stringValue, TestVoidPredefinedTypeMethodAsyncCallback callback) {
152 return delegate_->testVoidPredefinedTypeMethodAsync(uint32Value, stringValue, callback);
155 template <typename ... _AttributeExtensions>
156 void TestInterfaceProxy<_AttributeExtensions...>::testPredefinedTypeMethod(const uint32_t& uint32InValue, const std::string& stringInValue, CommonAPI::CallStatus& callStatus, uint32_t& uint32OutValue, std::string& stringOutValue) {
157 delegate_->testPredefinedTypeMethod(uint32InValue, stringInValue, callStatus, uint32OutValue, stringOutValue);
160 template <typename ... _AttributeExtensions>
161 std::future<CommonAPI::CallStatus> TestInterfaceProxy<_AttributeExtensions...>::testPredefinedTypeMethodAsync(const uint32_t& uint32InValue, const std::string& stringInValue, TestPredefinedTypeMethodAsyncCallback callback) {
162 return delegate_->testPredefinedTypeMethodAsync(uint32InValue, stringInValue, callback);
165 template <typename ... _AttributeExtensions>
166 void TestInterfaceProxy<_AttributeExtensions...>::testVoidDerivedTypeMethod(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2Value, const DerivedTypeCollection::TestMap& testMapValue, CommonAPI::CallStatus& callStatus) {
167 delegate_->testVoidDerivedTypeMethod(testEnumExtended2Value, testMapValue, callStatus);
170 template <typename ... _AttributeExtensions>
171 std::future<CommonAPI::CallStatus> TestInterfaceProxy<_AttributeExtensions...>::testVoidDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2Value, const DerivedTypeCollection::TestMap& testMapValue, TestVoidDerivedTypeMethodAsyncCallback callback) {
172 return delegate_->testVoidDerivedTypeMethodAsync(testEnumExtended2Value, testMapValue, callback);
175 template <typename ... _AttributeExtensions>
176 void TestInterfaceProxy<_AttributeExtensions...>::testDerivedTypeMethod(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, CommonAPI::CallStatus& callStatus, DerivedTypeCollection::TestEnumExtended2& testEnumExtended2OutValue, DerivedTypeCollection::TestMap& testMapOutValue) {
177 delegate_->testDerivedTypeMethod(testEnumExtended2InValue, testMapInValue, callStatus, testEnumExtended2OutValue, testMapOutValue);
180 template <typename ... _AttributeExtensions>
181 std::future<CommonAPI::CallStatus> TestInterfaceProxy<_AttributeExtensions...>::testDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, TestDerivedTypeMethodAsyncCallback callback) {
182 return delegate_->testDerivedTypeMethodAsync(testEnumExtended2InValue, testMapInValue, callback);
186 template <typename ... _AttributeExtensions>
187 std::string TestInterfaceProxy<_AttributeExtensions...>::getAddress() const {
188 return delegate_->getAddress();
191 template <typename ... _AttributeExtensions>
192 const std::string& TestInterfaceProxy<_AttributeExtensions...>::getDomain() const {
193 return delegate_->getDomain();
196 template <typename ... _AttributeExtensions>
197 const std::string& TestInterfaceProxy<_AttributeExtensions...>::getServiceId() const {
198 return delegate_->getServiceId();
201 template <typename ... _AttributeExtensions>
202 const std::string& TestInterfaceProxy<_AttributeExtensions...>::getInstanceId() const {
203 return delegate_->getInstanceId();
206 template <typename ... _AttributeExtensions>
207 bool TestInterfaceProxy<_AttributeExtensions...>::isAvailable() const {
208 return delegate_->isAvailable();
211 template <typename ... _AttributeExtensions>
212 CommonAPI::ProxyStatusEvent& TestInterfaceProxy<_AttributeExtensions...>::getProxyStatusEvent() {
213 return delegate_->getProxyStatusEvent();
216 template <typename ... _AttributeExtensions>
217 CommonAPI::InterfaceVersionAttribute& TestInterfaceProxy<_AttributeExtensions...>::getInterfaceVersionAttribute() {
218 return delegate_->getInterfaceVersionAttribute();
222 } // namespace commonapi
224 namespace CommonAPI {
225 template<template<typename > class _AttributeExtension>
226 struct DefaultAttributeProxyFactoryHelper<commonapi::tests::TestInterfaceProxy,
227 _AttributeExtension> {
228 typedef typename commonapi::tests::TestInterfaceProxy<
229 commonapi::tests::TestInterfaceExtensions::TestPredefinedTypeAttributeAttributeExtension<_AttributeExtension>,
230 commonapi::tests::TestInterfaceExtensions::TestDerivedStructAttributeAttributeExtension<_AttributeExtension>,
231 commonapi::tests::TestInterfaceExtensions::TestDerivedArrayAttributeAttributeExtension<_AttributeExtension>
237 #endif // COMMONAPI_TESTS_TEST_INTERFACE_PROXY_H_