summaryrefslogtreecommitdiff
path: root/src/test/commonapi/tests/DerivedTypeCollection.h
blob: 9e43d78725533e5677d1d0bf311a3c57675021a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
/*
* This file was generated by the CommonAPI Generators.
* Used org.genivi.commonapi.core 2.1.5.qualifier.
* Used org.franca.core 0.8.10.201309262002.
*
* 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/.
*/
#ifndef COMMONAPI_TESTS_Derived_Type_Collection_H_
#define COMMONAPI_TESTS_Derived_Type_Collection_H_


#include <commonapi/tests/PredefinedTypeCollection.h>

#if !defined (COMMONAPI_INTERNAL_COMPILATION)
#define COMMONAPI_INTERNAL_COMPILATION
#endif

#include <CommonAPI/InputStream.h>
#include <CommonAPI/OutputStream.h>
#include <CommonAPI/SerializableStruct.h>
#include <CommonAPI/types.h>
#include <cstdint>
#include <string>
#include <unordered_map>
#include <vector>

#undef COMMONAPI_INTERNAL_COMPILATION

namespace commonapi {
namespace tests {

namespace DerivedTypeCollection {
    struct TestStruct: CommonAPI::SerializableStruct {
        /**
         * the name of the property
         */
         PredefinedTypeCollection::TestString testString;
        /**
         * the actual value
         */
         uint16_t uintValue;
    
        TestStruct() = default;
        TestStruct(const PredefinedTypeCollection::TestString& testString, const uint16_t& uintValue);
    
    
        virtual void readFromInputStream(CommonAPI::InputStream& inputStream);
        virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const;
    
        static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
            typeOutputStream.writeStringType();
            typeOutputStream.writeUInt16Type();
        }
    };
    typedef std::vector<TestStruct> TestArrayTestStruct;
    typedef std::unordered_map<uint32_t, TestArrayTestStruct> TestMap;
    /**
     * Common errors.
     */
    enum class TestEnum: int32_t {
        /**
         * default
         */
        E_UNKNOWN = 0x0,
        /**
         * no error - positive reply
         */
        E_OK = 0x1,
        /**
         * value out of range
         */
        E_OUT_OF_RANGE = 0x2,
        /**
         * not used
         */
        E_NOT_USED = 0x3
    };
    
    // Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1
    struct TestEnumComparator;
    enum class TestEnumExtended: int32_t {
        E_UNKNOWN = TestEnum::E_UNKNOWN,
        E_OK = TestEnum::E_OK,
        E_OUT_OF_RANGE = TestEnum::E_OUT_OF_RANGE,
        E_NOT_USED = TestEnum::E_NOT_USED
        ,
        /**
         * new error
         */
        E_NEW = 0x4
    };
    
    // Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1
    struct TestEnumExtendedComparator;
    enum class TestEnumExtended2: int32_t {
        E_UNKNOWN = TestEnum::E_UNKNOWN,
        E_OK = TestEnum::E_OK,
        E_OUT_OF_RANGE = TestEnum::E_OUT_OF_RANGE,
        E_NOT_USED = TestEnum::E_NOT_USED,
        
        E_NEW = TestEnumExtended::E_NEW
        ,
        /**
         * new error
         */
        E_NEW2 = 0x5
    };
    
    // Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1
    struct TestEnumExtended2Comparator;
    struct TestStructExtended: TestStruct {
         TestEnumExtended2 testEnumExtended2;
    
        TestStructExtended() = default;
        TestStructExtended(const PredefinedTypeCollection::TestString& testString, const uint16_t& uintValue, const TestEnumExtended2& testEnumExtended2);
    
    
        virtual void readFromInputStream(CommonAPI::InputStream& inputStream);
        virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const;
    
        static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
            TestStruct::writeToTypeOutputStream(typeOutputStream);
            typeOutputStream.writeInt32Type();
        }
    };
    typedef std::unordered_map<TestEnum, std::string, CommonAPI::EnumHasher<TestEnum>> TestEnumMap;
    enum class TestEnumMissingValue: int32_t {
        /**
         * default
         */
        E1 = 0xa,
        E2,
        E3 = 2
    };
    
    // 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;
    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 = 0x8f51a326 };
    
        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 = 0xa49310f2 };
    
        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;
    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();
        }
    };
    struct StructWithEnumKeyMap: CommonAPI::SerializableStruct {
         TestEnumMap testMap;
    
        StructWithEnumKeyMap() = default;
        StructWithEnumKeyMap(const TestEnumMap& testMap);
    
    
        virtual void readFromInputStream(CommonAPI::InputStream& inputStream);
        virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const;
    
        static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) {
            typeOutputStream.beginWriteMapType();
            typeOutputStream.writeInt32Type();
            typeOutputStream.writeStringType();
            typeOutputStream.endWriteMapType();
        }
    };

bool operator==(const TestStructExtended& lhs, const TestStructExtended& rhs);
inline bool operator!=(const TestStructExtended& lhs, const TestStructExtended& rhs) {
    return !(lhs == rhs);
}
inline CommonAPI::InputStream& operator>>(CommonAPI::InputStream& inputStream, TestEnum& enumValue) {
    return inputStream.readEnumValue<int32_t>(enumValue);
}

inline CommonAPI::OutputStream& operator<<(CommonAPI::OutputStream& outputStream, const TestEnum& enumValue) {
    return outputStream.writeEnumValue(static_cast<int32_t>(enumValue));
}

struct TestEnumComparator {
    inline bool operator()(const TestEnum& lhs, const TestEnum& rhs) const {
        return static_cast<int32_t>(lhs) < static_cast<int32_t>(rhs);
    }
};

inline CommonAPI::InputStream& operator>>(CommonAPI::InputStream& inputStream, TestEnumExtended2& enumValue) {
    return inputStream.readEnumValue<int32_t>(enumValue);
}

inline CommonAPI::OutputStream& operator<<(CommonAPI::OutputStream& outputStream, const TestEnumExtended2& enumValue) {
    return outputStream.writeEnumValue(static_cast<int32_t>(enumValue));
}

struct TestEnumExtended2Comparator {
    inline bool operator()(const TestEnumExtended2& lhs, const TestEnumExtended2& rhs) const {
        return static_cast<int32_t>(lhs) < static_cast<int32_t>(rhs);
    }
};


inline bool operator==(const TestEnumExtended2& lhs, const DerivedTypeCollection::TestEnum& rhs) {
    return static_cast<int32_t>(lhs) == static_cast<int32_t>(rhs);
}
inline bool operator==(const DerivedTypeCollection::TestEnum& lhs, const TestEnumExtended2& rhs) {
    return static_cast<int32_t>(lhs) == static_cast<int32_t>(rhs);
} 
inline bool operator!=(const TestEnumExtended2& lhs, const DerivedTypeCollection::TestEnum& rhs) {
    return static_cast<int32_t>(lhs) != static_cast<int32_t>(rhs);
}
inline bool operator!=(const DerivedTypeCollection::TestEnum& lhs, const TestEnumExtended2& rhs) {
    return static_cast<int32_t>(lhs) != static_cast<int32_t>(rhs);
} 

inline bool operator==(const TestEnumExtended2& lhs, const DerivedTypeCollection::TestEnumExtended& rhs) {
    return static_cast<int32_t>(lhs) == static_cast<int32_t>(rhs);
}
inline bool operator==(const DerivedTypeCollection::TestEnumExtended& lhs, const TestEnumExtended2& rhs) {
    return static_cast<int32_t>(lhs) == static_cast<int32_t>(rhs);
} 
inline bool operator!=(const TestEnumExtended2& lhs, const DerivedTypeCollection::TestEnumExtended& rhs) {
    return static_cast<int32_t>(lhs) != static_cast<int32_t>(rhs);
}
inline bool operator!=(const DerivedTypeCollection::TestEnumExtended& lhs, const TestEnumExtended2& rhs) {
    return static_cast<int32_t>(lhs) != static_cast<int32_t>(rhs);
} 
inline CommonAPI::InputStream& operator>>(CommonAPI::InputStream& inputStream, TestEnumMissingValue& enumValue) {
    return inputStream.readEnumValue<int32_t>(enumValue);
}

inline CommonAPI::OutputStream& operator<<(CommonAPI::OutputStream& outputStream, const TestEnumMissingValue& enumValue) {
    return outputStream.writeEnumValue(static_cast<int32_t>(enumValue));
}

struct TestEnumMissingValueComparator {
    inline bool operator()(const TestEnumMissingValue& lhs, const TestEnumMissingValue& rhs) const {
        return static_cast<int32_t>(lhs) < static_cast<int32_t>(rhs);
    }
};

inline CommonAPI::InputStream& operator>>(CommonAPI::InputStream& inputStream, TestEnumExtended& enumValue) {
    return inputStream.readEnumValue<int32_t>(enumValue);
}

inline CommonAPI::OutputStream& operator<<(CommonAPI::OutputStream& outputStream, const TestEnumExtended& enumValue) {
    return outputStream.writeEnumValue(static_cast<int32_t>(enumValue));
}

struct TestEnumExtendedComparator {
    inline bool operator()(const TestEnumExtended& lhs, const TestEnumExtended& rhs) const {
        return static_cast<int32_t>(lhs) < static_cast<int32_t>(rhs);
    }
};


inline bool operator==(const TestEnumExtended& lhs, const DerivedTypeCollection::TestEnum& rhs) {
    return static_cast<int32_t>(lhs) == static_cast<int32_t>(rhs);
}
inline bool operator==(const DerivedTypeCollection::TestEnum& lhs, const TestEnumExtended& rhs) {
    return static_cast<int32_t>(lhs) == static_cast<int32_t>(rhs);
} 
inline bool operator!=(const TestEnumExtended& lhs, const DerivedTypeCollection::TestEnum& rhs) {
    return static_cast<int32_t>(lhs) != static_cast<int32_t>(rhs);
}
inline bool operator!=(const DerivedTypeCollection::TestEnum& lhs, const TestEnumExtended& rhs) {
    return static_cast<int32_t>(lhs) != static_cast<int32_t>(rhs);
} 
bool operator==(const TestStruct& lhs, const TestStruct& rhs);
inline bool operator!=(const TestStruct& lhs, const TestStruct& rhs) {
    return !(lhs == 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) {
    return !(lhs == rhs);
}
bool operator==(const StructWithEnumKeyMap& lhs, const StructWithEnumKeyMap& rhs);
inline bool operator!=(const StructWithEnumKeyMap& lhs, const StructWithEnumKeyMap& rhs) {
    return !(lhs == rhs);
}


static inline const char* getTypeCollectionName() {
    static const char* typeCollectionName = "commonapi.tests.DerivedTypeCollection";
    return typeCollectionName;
}


} // namespace DerivedTypeCollection

} // namespace tests
} // namespace commonapi

namespace CommonAPI {

    template<>
    struct BasicTypeWriter<commonapi::tests::DerivedTypeCollection::TestEnum> {
        inline static void writeType (CommonAPI::TypeOutputStream& typeStream) {
            typeStream.writeInt32EnumType();
        }
    };
    
    template<>
    struct InputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnum> {
        static void beginReadVector(InputStream& inputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnum>& vectorValue) {
            inputStream.beginReadInt32EnumVector();
        }
    };
    
    template <>
    struct OutputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnum> {
        static void beginWriteVector(OutputStream& outputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnum>& vectorValue) {
            outputStream.beginWriteInt32EnumVector(vectorValue.size());
        }
    };
    template<>
    struct BasicTypeWriter<commonapi::tests::DerivedTypeCollection::TestEnumExtended2> {
        inline static void writeType (CommonAPI::TypeOutputStream& typeStream) {
            typeStream.writeInt32EnumType();
        }
    };
    
    template<>
    struct InputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnumExtended2> {
        static void beginReadVector(InputStream& inputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnumExtended2>& vectorValue) {
            inputStream.beginReadInt32EnumVector();
        }
    };
    
    template <>
    struct OutputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnumExtended2> {
        static void beginWriteVector(OutputStream& outputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnumExtended2>& vectorValue) {
            outputStream.beginWriteInt32EnumVector(vectorValue.size());
        }
    };
    template<>
    struct BasicTypeWriter<commonapi::tests::DerivedTypeCollection::TestEnumMissingValue> {
        inline static void writeType (CommonAPI::TypeOutputStream& typeStream) {
            typeStream.writeInt32EnumType();
        }
    };
    
    template<>
    struct InputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnumMissingValue> {
        static void beginReadVector(InputStream& inputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnumMissingValue>& vectorValue) {
            inputStream.beginReadInt32EnumVector();
        }
    };
    
    template <>
    struct OutputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnumMissingValue> {
        static void beginWriteVector(OutputStream& outputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnumMissingValue>& vectorValue) {
            outputStream.beginWriteInt32EnumVector(vectorValue.size());
        }
    };
    template<>
    struct BasicTypeWriter<commonapi::tests::DerivedTypeCollection::TestEnumExtended> {
        inline static void writeType (CommonAPI::TypeOutputStream& typeStream) {
            typeStream.writeInt32EnumType();
        }
    };
    
    template<>
    struct InputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnumExtended> {
        static void beginReadVector(InputStream& inputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnumExtended>& vectorValue) {
            inputStream.beginReadInt32EnumVector();
        }
    };
    
    template <>
    struct OutputStreamVectorHelper<commonapi::tests::DerivedTypeCollection::TestEnumExtended> {
        static void beginWriteVector(OutputStream& outputStream, const std::vector<commonapi::tests::DerivedTypeCollection::TestEnumExtended>& vectorValue) {
            outputStream.beginWriteInt32EnumVector(vectorValue.size());
        }
    };

}


namespace std {
    //Hash for TestEnum
    template<>
    struct hash<commonapi::tests::DerivedTypeCollection::TestEnum> {
        inline size_t operator()(const commonapi::tests::DerivedTypeCollection::TestEnum& testEnum) const {
            return static_cast<int32_t>(testEnum);
        }
    };
    //Hash for TestEnumExtended2
    template<>
    struct hash<commonapi::tests::DerivedTypeCollection::TestEnumExtended2> {
        inline size_t operator()(const commonapi::tests::DerivedTypeCollection::TestEnumExtended2& testEnumExtended2) const {
            return static_cast<int32_t>(testEnumExtended2);
        }
    };
    //Hash for TestEnumMissingValue
    template<>
    struct hash<commonapi::tests::DerivedTypeCollection::TestEnumMissingValue> {
        inline size_t operator()(const commonapi::tests::DerivedTypeCollection::TestEnumMissingValue& testEnumMissingValue) const {
            return static_cast<int32_t>(testEnumMissingValue);
        }
    };
    //Hash for TestEnumExtended
    template<>
    struct hash<commonapi::tests::DerivedTypeCollection::TestEnumExtended> {
        inline size_t operator()(const commonapi::tests::DerivedTypeCollection::TestEnumExtended& testEnumExtended) const {
            return static_cast<int32_t>(testEnumExtended);
        }
    };
}

#endif // COMMONAPI_TESTS_Derived_Type_Collection_H_