Line data Source code
1 : /********************************************************************************
2 : * Copyright (c) 2026 Accenture
3 : *
4 : * This program and the accompanying materials are made available under the
5 : * terms of the Apache License Version 2.0 which is available at
6 : * https://www.apache.org/licenses/LICENSE-2.0
7 : *
8 : * SPDX-License-Identifier: Apache-2.0
9 : ********************************************************************************/
10 :
11 : #pragma once
12 :
13 : #include <cstdint>
14 :
15 : namespace someip
16 : {
17 : class SomeIpParser;
18 : class SomeIpSerializer;
19 :
20 : /**
21 : * Interface for serializable SOME/IP data types. The SOME/IP code generator
22 : * will generate classes that extend this interface.
23 : */
24 : class ISomeIpSerializable
25 : {
26 : protected:
27 44 : ISomeIpSerializable() = default;
28 :
29 : public:
30 : ISomeIpSerializable(ISomeIpSerializable const&) = delete;
31 : ISomeIpSerializable& operator=(ISomeIpSerializable const&) = delete;
32 :
33 44 : virtual ~ISomeIpSerializable() = default;
34 :
35 : /**
36 : * Pure virtual function for serializing the content
37 : * of the data type to the specified serializer object.
38 : *
39 : * \param serializer The serializer object used for writing this object to bytes.
40 : */
41 : virtual void serializeToArray(SomeIpSerializer& serializer) const = 0;
42 :
43 : /**
44 : * Pure virtual function that parses the content of
45 : * this object from the specified parser.
46 : *
47 : * \param parser The parser object used for reading this object from bytes.
48 : */
49 : virtual void parseFromArray(SomeIpParser& parser) = 0;
50 :
51 : /**
52 : * Pure virtual function that returns the number of bytes
53 : * required for serializing this data type.
54 : */
55 : virtual uint32_t getSize() const = 0;
56 : };
57 :
58 : } // namespace someip
|