Reorganise to remove redundant folder
[profile/ivi/common-api-dbus-runtime.git] / src / test / commonapi / tests / TestInterfaceProxy.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 #ifndef COMMONAPI_TESTS_TEST_INTERFACE_PROXY_H_
5 #define COMMONAPI_TESTS_TEST_INTERFACE_PROXY_H_
6
7 #include "TestInterfaceProxyBase.h"
8 #include <CommonAPI/AttributeExtension.h>
9
10 namespace commonapi {
11 namespace tests {
12
13 template <typename ... _AttributeExtensions>
14 class TestInterfaceProxy: virtual public TestInterface, virtual public TestInterfaceProxyBase, public _AttributeExtensions... {
15  public:
16     TestInterfaceProxy(std::shared_ptr<CommonAPI::Proxy> delegate);
17     ~TestInterfaceProxy();
18
19     virtual TestPredefinedTypeAttributeAttribute& getTestPredefinedTypeAttributeAttribute();
20     virtual TestDerivedStructAttributeAttribute& getTestDerivedStructAttributeAttribute();
21     virtual TestDerivedArrayAttributeAttribute& getTestDerivedArrayAttributeAttribute();
22
23     virtual TestPredefinedTypeBroadcastEvent& getTestPredefinedTypeBroadcastEvent();
24
25
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);
28
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);
31
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);
34
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);
37
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();
45
46  private:
47     std::shared_ptr<TestInterfaceProxyBase> delegate_;
48 };
49
50 namespace TestInterfaceExtensions {
51     template <template <typename > class _ExtensionType>
52     class TestPredefinedTypeAttributeAttributeExtension {
53      public:
54         typedef _ExtensionType<TestInterfaceProxyBase::TestPredefinedTypeAttributeAttribute> extension_type;
55     
56         static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestInterfaceProxyBase::TestPredefinedTypeAttributeAttribute>, extension_type>::value,
57                       "Not CommonAPI Attribute Extension!");
58     
59         TestPredefinedTypeAttributeAttributeExtension(TestInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestPredefinedTypeAttributeAttribute()) {
60         }
61     
62         inline extension_type& getTestPredefinedTypeAttributeAttributeExtension() {
63             return attributeExtension_;
64         }
65     
66      private:
67         extension_type attributeExtension_;
68     };
69
70     template <template <typename > class _ExtensionType>
71     class TestDerivedStructAttributeAttributeExtension {
72      public:
73         typedef _ExtensionType<TestInterfaceProxyBase::TestDerivedStructAttributeAttribute> extension_type;
74     
75         static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestInterfaceProxyBase::TestDerivedStructAttributeAttribute>, extension_type>::value,
76                       "Not CommonAPI Attribute Extension!");
77     
78         TestDerivedStructAttributeAttributeExtension(TestInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestDerivedStructAttributeAttribute()) {
79         }
80     
81         inline extension_type& getTestDerivedStructAttributeAttributeExtension() {
82             return attributeExtension_;
83         }
84     
85      private:
86         extension_type attributeExtension_;
87     };
88
89     template <template <typename > class _ExtensionType>
90     class TestDerivedArrayAttributeAttributeExtension {
91      public:
92         typedef _ExtensionType<TestInterfaceProxyBase::TestDerivedArrayAttributeAttribute> extension_type;
93     
94         static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestInterfaceProxyBase::TestDerivedArrayAttributeAttribute>, extension_type>::value,
95                       "Not CommonAPI Attribute Extension!");
96     
97         TestDerivedArrayAttributeAttributeExtension(TestInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestDerivedArrayAttributeAttribute()) {
98         }
99     
100         inline extension_type& getTestDerivedArrayAttributeAttributeExtension() {
101             return attributeExtension_;
102         }
103     
104      private:
105         extension_type attributeExtension_;
106     };
107
108 } // namespace TestInterfaceExtensions
109
110 //
111 // TestInterfaceProxy Implementation
112 //
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)))... {
117 }
118
119 template <typename ... _AttributeExtensions>
120 TestInterfaceProxy<_AttributeExtensions...>::~TestInterfaceProxy() {
121 }
122
123 template <typename ... _AttributeExtensions>
124 typename TestInterfaceProxy<_AttributeExtensions...>::TestPredefinedTypeAttributeAttribute& TestInterfaceProxy<_AttributeExtensions...>::getTestPredefinedTypeAttributeAttribute() {
125     return delegate_->getTestPredefinedTypeAttributeAttribute();
126 }
127
128 template <typename ... _AttributeExtensions>
129 typename TestInterfaceProxy<_AttributeExtensions...>::TestDerivedStructAttributeAttribute& TestInterfaceProxy<_AttributeExtensions...>::getTestDerivedStructAttributeAttribute() {
130     return delegate_->getTestDerivedStructAttributeAttribute();
131 }
132
133 template <typename ... _AttributeExtensions>
134 typename TestInterfaceProxy<_AttributeExtensions...>::TestDerivedArrayAttributeAttribute& TestInterfaceProxy<_AttributeExtensions...>::getTestDerivedArrayAttributeAttribute() {
135     return delegate_->getTestDerivedArrayAttributeAttribute();
136 }
137
138
139 template <typename ... _AttributeExtensions>
140 typename TestInterfaceProxy<_AttributeExtensions...>::TestPredefinedTypeBroadcastEvent& TestInterfaceProxy<_AttributeExtensions...>::getTestPredefinedTypeBroadcastEvent() {
141     return delegate_->getTestPredefinedTypeBroadcastEvent();
142 }
143
144
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);
148 }
149
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);
153 }
154
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);
158 }
159
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);
163 }
164
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);
168 }
169
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);
173 }
174
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);
178 }
179
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);
183 }
184
185
186 template <typename ... _AttributeExtensions>
187 std::string TestInterfaceProxy<_AttributeExtensions...>::getAddress() const {
188     return delegate_->getAddress();
189 }
190
191 template <typename ... _AttributeExtensions>
192 const std::string& TestInterfaceProxy<_AttributeExtensions...>::getDomain() const {
193     return delegate_->getDomain();
194 }
195
196 template <typename ... _AttributeExtensions>
197 const std::string& TestInterfaceProxy<_AttributeExtensions...>::getServiceId() const {
198     return delegate_->getServiceId();
199 }
200
201 template <typename ... _AttributeExtensions>
202 const std::string& TestInterfaceProxy<_AttributeExtensions...>::getInstanceId() const {
203     return delegate_->getInstanceId();
204 }
205
206 template <typename ... _AttributeExtensions>
207 bool TestInterfaceProxy<_AttributeExtensions...>::isAvailable() const {
208     return delegate_->isAvailable();
209 }
210
211 template <typename ... _AttributeExtensions>
212 CommonAPI::ProxyStatusEvent& TestInterfaceProxy<_AttributeExtensions...>::getProxyStatusEvent() {
213     return delegate_->getProxyStatusEvent();
214 }
215
216 template <typename ... _AttributeExtensions>
217 CommonAPI::InterfaceVersionAttribute& TestInterfaceProxy<_AttributeExtensions...>::getInterfaceVersionAttribute() {
218     return delegate_->getInterfaceVersionAttribute();
219 }
220
221 } // namespace tests
222 } // namespace commonapi
223
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>
232     > class_t;
233 };
234 }
235
236
237 #endif // COMMONAPI_TESTS_TEST_INTERFACE_PROXY_H_