increased version number to 2.1.5 and regenerated code for test fidl
[profile/ivi/common-api-dbus-runtime.git] / src / test / commonapi / tests / DerivedTypeCollection.h
1 /*
2 * This file was generated by the CommonAPI Generators.
3 * Used org.genivi.commonapi.core 2.1.5.qualifier.
4 * Used org.franca.core 0.8.10.201309262002.
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7 * If a copy of the MPL was not distributed with this file, You can obtain one at
8 * http://mozilla.org/MPL/2.0/.
9 */
10 #ifndef COMMONAPI_TESTS_Derived_Type_Collection_H_
11 #define COMMONAPI_TESTS_Derived_Type_Collection_H_
12
13
14 #include <commonapi/tests/PredefinedTypeCollection.h>
15
16 #if !defined (COMMONAPI_INTERNAL_COMPILATION)
17 #define COMMONAPI_INTERNAL_COMPILATION
18 #endif
19
20 #include <CommonAPI/InputStream.h>
21 #include <CommonAPI/OutputStream.h>
22 #include <CommonAPI/SerializableStruct.h>
23 #include <CommonAPI/types.h>
24 #include <cstdint>
25 #include <string>
26 #include <unordered_map>
27 #include <vector>
28
29 #undef COMMONAPI_INTERNAL_COMPILATION
30
31 namespace commonapi {
32 namespace tests {
33
34 namespace DerivedTypeCollection {
35     struct TestStruct: CommonAPI::SerializableStruct {
36         /**
37          * the name of the property
38          */
39          PredefinedTypeCollection::TestString testString;
40         /**
41          * the actual value
42          */
43          uint16_t uintValue;
44     
45         TestStruct() = default;
46         TestStruct(const PredefinedTypeCollection::TestString& testString, const uint16_t& uintValue);
47     
48     
49         virtual void readFromInputStream(CommonAPI::InputStream& inputStream);
50         virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const;
51     
52         static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
53             typeOutputStream.writeStringType();
54             typeOutputStream.writeUInt16Type();
55         }
56     };
57     typedef std::vector<TestStruct> TestArrayTestStruct;
58     typedef std::unordered_map<uint32_t, TestArrayTestStruct> TestMap;
59     /**
60      * Common errors.
61      */
62     enum class TestEnum: int32_t {
63         /**
64          * default
65          */
66         E_UNKNOWN = 0x0,
67         /**
68          * no error - positive reply
69          */
70         E_OK = 0x1,
71         /**
72          * value out of range
73          */
74         E_OUT_OF_RANGE = 0x2,
75         /**
76          * not used
77          */
78         E_NOT_USED = 0x3
79     };
80     
81     // Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1
82     struct TestEnumComparator;
83     enum class TestEnumExtended: int32_t {
84         E_UNKNOWN = TestEnum::E_UNKNOWN,
85         E_OK = TestEnum::E_OK,
86         E_OUT_OF_RANGE = TestEnum::E_OUT_OF_RANGE,
87         E_NOT_USED = TestEnum::E_NOT_USED
88         ,
89         /**
90          * new error
91          */
92         E_NEW = 0x4
93     };
94     
95     // Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1
96     struct TestEnumExtendedComparator;
97     enum class TestEnumExtended2: int32_t {
98         E_UNKNOWN = TestEnum::E_UNKNOWN,
99         E_OK = TestEnum::E_OK,
100         E_OUT_OF_RANGE = TestEnum::E_OUT_OF_RANGE,
101         E_NOT_USED = TestEnum::E_NOT_USED,
102         
103         E_NEW = TestEnumExtended::E_NEW
104         ,
105         /**
106          * new error
107          */
108         E_NEW2 = 0x5
109     };
110     
111     // Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1
112     struct TestEnumExtended2Comparator;
113     struct TestStructExtended: TestStruct {
114          TestEnumExtended2 testEnumExtended2;
115     
116         TestStructExtended() = default;
117         TestStructExtended(const PredefinedTypeCollection::TestString& testString, const uint16_t& uintValue, const TestEnumExtended2& testEnumExtended2);
118     
119     
120         virtual void readFromInputStream(CommonAPI::InputStream& inputStream);
121         virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const;
122     
123         static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
124             TestStruct::writeToTypeOutputStream(typeOutputStream);
125             typeOutputStream.writeInt32Type();
126         }
127     };
128     typedef std::unordered_map<TestEnum, std::string, CommonAPI::EnumHasher<TestEnum>> TestEnumMap;
129     enum class TestEnumMissingValue: int32_t {
130         /**
131          * default
132          */
133         E1 = 0xa,
134         E2,
135         E3 = 2
136     };
137     
138     // Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1
139     struct TestEnumMissingValueComparator;
140     typedef std::vector<uint64_t> TestArrayUInt64;
141     struct TestPolymorphicStruct: CommonAPI::SerializablePolymorphicStruct {
142         /**
143          * the name of the property
144          */
145          PredefinedTypeCollection::TestString testString;
146         /**
147          * the actual value
148          */
149          uint16_t uintValue;
150     
151         TestPolymorphicStruct() = default;
152         TestPolymorphicStruct(const PredefinedTypeCollection::TestString& testString, const uint16_t& uintValue);
153     
154         enum: uint32_t { SERIAL_ID = 0x8f51a326 };
155     
156         static TestPolymorphicStruct* createInstance(const uint32_t& serialId);
157     
158         virtual uint32_t getSerialId() const;
159         virtual void createTypeSignature(CommonAPI::TypeOutputStream& typeOutputStream) const;
160     
161         virtual void readFromInputStream(CommonAPI::InputStream& inputStream);
162         virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const;
163     
164         static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
165             typeOutputStream.writeStringType();
166             typeOutputStream.writeUInt16Type();
167         }
168     };
169     struct TestExtendedPolymorphicStruct: TestPolymorphicStruct {
170          uint32_t additionalValue;
171     
172         TestExtendedPolymorphicStruct() = default;
173         TestExtendedPolymorphicStruct(const PredefinedTypeCollection::TestString& testString, const uint16_t& uintValue, const uint32_t& additionalValue);
174     
175         enum: uint32_t { SERIAL_ID = 0xa49310f2 };
176     
177         static TestExtendedPolymorphicStruct* createInstance(const uint32_t& serialId);
178     
179         virtual uint32_t getSerialId() const;
180         virtual void createTypeSignature(CommonAPI::TypeOutputStream& typeOutputStream) const;
181     
182         virtual void readFromInputStream(CommonAPI::InputStream& inputStream);
183         virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const;
184     
185         static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
186             TestPolymorphicStruct::writeToTypeOutputStream(typeOutputStream);
187             typeOutputStream.writeUInt32Type();
188         }
189     };
190     typedef std::unordered_map<uint8_t, std::shared_ptr<TestPolymorphicStruct>> MapIntToPolymorphic;
191     struct StructWithPolymorphicMember: CommonAPI::SerializableStruct {
192          uint32_t numberValue;
193          std::shared_ptr<TestPolymorphicStruct> polymorphicMember;
194     
195         StructWithPolymorphicMember() = default;
196         StructWithPolymorphicMember(const uint32_t& numberValue, const std::shared_ptr<TestPolymorphicStruct>& polymorphicMember);
197     
198     
199         virtual void readFromInputStream(CommonAPI::InputStream& inputStream);
200         virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const;
201     
202         static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
203             typeOutputStream.writeUInt32Type();
204             typeOutputStream.beginWriteStructType();
205             typeOutputStream.writeStringType();typeOutputStream.writeUInt16Type();
206             typeOutputStream.endWriteStructType();
207         }
208     };
209     struct StructWithEnumKeyMap: CommonAPI::SerializableStruct {
210          TestEnumMap testMap;
211     
212         StructWithEnumKeyMap() = default;
213         StructWithEnumKeyMap(const TestEnumMap& testMap);
214     
215     
216         virtual void readFromInputStream(CommonAPI::InputStream& inputStream);
217         virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const;
218     
219         static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
220             typeOutputStream.beginWriteMapType();
221             typeOutputStream.writeInt32Type();
222             typeOutputStream.writeStringType();
223             typeOutputStream.endWriteMapType();
224         }
225     };
226
227 bool operator==(const TestStructExtended& lhs, const TestStructExtended& rhs);
228 inline bool operator!=(const TestStructExtended& lhs, const TestStructExtended& rhs) {
229     return !(lhs == rhs);
230 }
231 inline CommonAPI::InputStream& operator>>(CommonAPI::InputStream& inputStream, TestEnum& enumValue) {
232     return inputStream.readEnumValue<int32_t>(enumValue);
233 }
234
235 inline CommonAPI::OutputStream& operator<<(CommonAPI::OutputStream& outputStream, const TestEnum& enumValue) {
236     return outputStream.writeEnumValue(static_cast<int32_t>(enumValue));
237 }
238
239 struct TestEnumComparator {
240     inline bool operator()(const TestEnum& lhs, const TestEnum& rhs) const {
241         return static_cast<int32_t>(lhs) < static_cast<int32_t>(rhs);
242     }
243 };
244
245 inline CommonAPI::InputStream& operator>>(CommonAPI::InputStream& inputStream, TestEnumExtended2& enumValue) {
246     return inputStream.readEnumValue<int32_t>(enumValue);
247 }
248
249 inline CommonAPI::OutputStream& operator<<(CommonAPI::OutputStream& outputStream, const TestEnumExtended2& enumValue) {
250     return outputStream.writeEnumValue(static_cast<int32_t>(enumValue));
251 }
252
253 struct TestEnumExtended2Comparator {
254     inline bool operator()(const TestEnumExtended2& lhs, const TestEnumExtended2& rhs) const {
255         return static_cast<int32_t>(lhs) < static_cast<int32_t>(rhs);
256     }
257 };
258
259
260 inline bool operator==(const TestEnumExtended2& lhs, const DerivedTypeCollection::TestEnum& rhs) {
261     return static_cast<int32_t>(lhs) == static_cast<int32_t>(rhs);
262 }
263 inline bool operator==(const DerivedTypeCollection::TestEnum& lhs, const TestEnumExtended2& rhs) {
264     return static_cast<int32_t>(lhs) == static_cast<int32_t>(rhs);
265
266 inline bool operator!=(const TestEnumExtended2& lhs, const DerivedTypeCollection::TestEnum& rhs) {
267     return static_cast<int32_t>(lhs) != static_cast<int32_t>(rhs);
268 }
269 inline bool operator!=(const DerivedTypeCollection::TestEnum& lhs, const TestEnumExtended2& rhs) {
270     return static_cast<int32_t>(lhs) != static_cast<int32_t>(rhs);
271
272
273 inline bool operator==(const TestEnumExtended2& lhs, const DerivedTypeCollection::TestEnumExtended& rhs) {
274     return static_cast<int32_t>(lhs) == static_cast<int32_t>(rhs);
275 }
276 inline bool operator==(const DerivedTypeCollection::TestEnumExtended& lhs, const TestEnumExtended2& rhs) {
277     return static_cast<int32_t>(lhs) == static_cast<int32_t>(rhs);
278
279 inline bool operator!=(const TestEnumExtended2& lhs, const DerivedTypeCollection::TestEnumExtended& rhs) {
280     return static_cast<int32_t>(lhs) != static_cast<int32_t>(rhs);
281 }
282 inline bool operator!=(const DerivedTypeCollection::TestEnumExtended& lhs, const TestEnumExtended2& rhs) {
283     return static_cast<int32_t>(lhs) != static_cast<int32_t>(rhs);
284
285 inline CommonAPI::InputStream& operator>>(CommonAPI::InputStream& inputStream, TestEnumMissingValue& enumValue) {
286     return inputStream.readEnumValue<int32_t>(enumValue);
287 }
288
289 inline CommonAPI::OutputStream& operator<<(CommonAPI::OutputStream& outputStream, const TestEnumMissingValue& enumValue) {
290     return outputStream.writeEnumValue(static_cast<int32_t>(enumValue));
291 }
292
293 struct TestEnumMissingValueComparator {
294     inline bool operator()(const TestEnumMissingValue& lhs, const TestEnumMissingValue& rhs) const {
295         return static_cast<int32_t>(lhs) < static_cast<int32_t>(rhs);
296     }
297 };
298
299 inline CommonAPI::InputStream& operator>>(CommonAPI::InputStream& inputStream, TestEnumExtended& enumValue) {
300     return inputStream.readEnumValue<int32_t>(enumValue);
301 }
302
303 inline CommonAPI::OutputStream& operator<<(CommonAPI::OutputStream& outputStream, const TestEnumExtended& enumValue) {
304     return outputStream.writeEnumValue(static_cast<int32_t>(enumValue));
305 }
306
307 struct TestEnumExtendedComparator {
308     inline bool operator()(const TestEnumExtended& lhs, const TestEnumExtended& rhs) const {
309         return static_cast<int32_t>(lhs) < static_cast<int32_t>(rhs);
310     }
311 };
312
313
314 inline bool operator==(const TestEnumExtended& lhs, const DerivedTypeCollection::TestEnum& rhs) {
315     return static_cast<int32_t>(lhs) == static_cast<int32_t>(rhs);
316 }
317 inline bool operator==(const DerivedTypeCollection::TestEnum& lhs, const TestEnumExtended& rhs) {
318     return static_cast<int32_t>(lhs) == static_cast<int32_t>(rhs);
319
320 inline bool operator!=(const TestEnumExtended& lhs, const DerivedTypeCollection::TestEnum& rhs) {
321     return static_cast<int32_t>(lhs) != static_cast<int32_t>(rhs);
322 }
323 inline bool operator!=(const DerivedTypeCollection::TestEnum& lhs, const TestEnumExtended& rhs) {
324     return static_cast<int32_t>(lhs) != static_cast<int32_t>(rhs);
325
326 bool operator==(const TestStruct& lhs, const TestStruct& rhs);
327 inline bool operator!=(const TestStruct& lhs, const TestStruct& rhs) {
328     return !(lhs == rhs);
329 }
330 bool operator==(const TestPolymorphicStruct& lhs, const TestPolymorphicStruct& rhs);
331 inline bool operator!=(const TestPolymorphicStruct& lhs, const TestPolymorphicStruct& rhs) {
332     return !(lhs == rhs);
333 }
334 bool operator==(const TestExtendedPolymorphicStruct& lhs, const TestExtendedPolymorphicStruct& rhs);
335 inline bool operator!=(const TestExtendedPolymorphicStruct& lhs, const TestExtendedPolymorphicStruct& rhs) {
336     return !(lhs == rhs);
337 }
338 bool operator==(const StructWithPolymorphicMember& lhs, const StructWithPolymorphicMember& rhs);
339 inline bool operator!=(const StructWithPolymorphicMember& lhs, const StructWithPolymorphicMember& rhs) {
340     return !(lhs == rhs);
341 }
342 bool operator==(const StructWithEnumKeyMap& lhs, const StructWithEnumKeyMap& rhs);
343 inline bool operator!=(const StructWithEnumKeyMap& lhs, const StructWithEnumKeyMap& rhs) {
344     return !(lhs == rhs);
345 }
346
347
348 static inline const char* getTypeCollectionName() {
349     static const char* typeCollectionName = "commonapi.tests.DerivedTypeCollection";
350     return typeCollectionName;
351 }
352
353
354 } // namespace DerivedTypeCollection
355
356 } // namespace tests
357 } // namespace commonapi
358
359 namespace CommonAPI {
360
361     template<>
362     struct BasicTypeWriter<commonapi::tests::DerivedTypeCollection::TestEnum> {
363         inline static void writeType (CommonAPI::TypeOutputStream& typeStream) {
364             typeStream.writeInt32EnumType();
365         }
366     };
367     
368     template<>
369     struct InputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnum> {
370         static void beginReadVector(InputStream& inputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnum>& vectorValue) {
371             inputStream.beginReadInt32EnumVector();
372         }
373     };
374     
375     template <>
376     struct OutputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnum> {
377         static void beginWriteVector(OutputStream& outputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnum>& vectorValue) {
378             outputStream.beginWriteInt32EnumVector(vectorValue.size());
379         }
380     };
381     template<>
382     struct BasicTypeWriter<commonapi::tests::DerivedTypeCollection::TestEnumExtended2> {
383         inline static void writeType (CommonAPI::TypeOutputStream& typeStream) {
384             typeStream.writeInt32EnumType();
385         }
386     };
387     
388     template<>
389     struct InputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnumExtended2> {
390         static void beginReadVector(InputStream& inputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnumExtended2>& vectorValue) {
391             inputStream.beginReadInt32EnumVector();
392         }
393     };
394     
395     template <>
396     struct OutputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnumExtended2> {
397         static void beginWriteVector(OutputStream& outputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnumExtended2>& vectorValue) {
398             outputStream.beginWriteInt32EnumVector(vectorValue.size());
399         }
400     };
401     template<>
402     struct BasicTypeWriter<commonapi::tests::DerivedTypeCollection::TestEnumMissingValue> {
403         inline static void writeType (CommonAPI::TypeOutputStream& typeStream) {
404             typeStream.writeInt32EnumType();
405         }
406     };
407     
408     template<>
409     struct InputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnumMissingValue> {
410         static void beginReadVector(InputStream& inputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnumMissingValue>& vectorValue) {
411             inputStream.beginReadInt32EnumVector();
412         }
413     };
414     
415     template <>
416     struct OutputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnumMissingValue> {
417         static void beginWriteVector(OutputStream& outputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnumMissingValue>& vectorValue) {
418             outputStream.beginWriteInt32EnumVector(vectorValue.size());
419         }
420     };
421     template<>
422     struct BasicTypeWriter<commonapi::tests::DerivedTypeCollection::TestEnumExtended> {
423         inline static void writeType (CommonAPI::TypeOutputStream& typeStream) {
424             typeStream.writeInt32EnumType();
425         }
426     };
427     
428     template<>
429     struct InputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnumExtended> {
430         static void beginReadVector(InputStream& inputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnumExtended>& vectorValue) {
431             inputStream.beginReadInt32EnumVector();
432         }
433     };
434     
435     template <>
436     struct OutputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnumExtended> {
437         static void beginWriteVector(OutputStream& outputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnumExtended>& vectorValue) {
438             outputStream.beginWriteInt32EnumVector(vectorValue.size());
439         }
440     };
441
442 }
443
444
445 namespace std {
446     //Hash for TestEnum
447     template<>
448     struct hash<commonapi::tests::DerivedTypeCollection::TestEnum> {
449         inline size_t operator()(const commonapi::tests::DerivedTypeCollection::TestEnum& testEnum) const {
450             return static_cast<int32_t>(testEnum);
451         }
452     };
453     //Hash for TestEnumExtended2
454     template<>
455     struct hash<commonapi::tests::DerivedTypeCollection::TestEnumExtended2> {
456         inline size_t operator()(const commonapi::tests::DerivedTypeCollection::TestEnumExtended2& testEnumExtended2) const {
457             return static_cast<int32_t>(testEnumExtended2);
458         }
459     };
460     //Hash for TestEnumMissingValue
461     template<>
462     struct hash<commonapi::tests::DerivedTypeCollection::TestEnumMissingValue> {
463         inline size_t operator()(const commonapi::tests::DerivedTypeCollection::TestEnumMissingValue& testEnumMissingValue) const {
464             return static_cast<int32_t>(testEnumMissingValue);
465         }
466     };
467     //Hash for TestEnumExtended
468     template<>
469     struct hash<commonapi::tests::DerivedTypeCollection::TestEnumExtended> {
470         inline size_t operator()(const commonapi::tests::DerivedTypeCollection::TestEnumExtended& testEnumExtended) const {
471             return static_cast<int32_t>(testEnumExtended);
472         }
473     };
474 }
475
476 #endif // COMMONAPI_TESTS_Derived_Type_Collection_H_