Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
entry.h
1#ifndef ENTRY_H
2#define ENTRY_H
3
4#include <stdint.h>
5#include <vector>
6#include <memory>
7#include <stdexcept>
8#include "../option/option.h"
9
10namespace ara
11{
12 namespace com
13 {
15 namespace entry
16 {
18 enum class EntryType : uint8_t
19 {
20 Finding = 0x00,
21 Offering = 0x01,
22 Subscribing = 0x06,
23 Acknowledging = 0x07
24 };
25
27 class Entry
28 {
29 private:
30 EntryType mType;
31 std::vector<std::unique_ptr<option::Option>> mFirstOptions;
32 std::vector<std::unique_ptr<option::Option>> mSecondOptions;
33 uint16_t mServiceId;
34 uint16_t mInstanceId;
35 uint8_t mMajorVersion;
36 uint32_t mTTL;
37
38 protected:
45 Entry(EntryType type,
46 uint16_t serviceId,
47 uint16_t instanceId,
48 uint32_t ttl,
49 uint8_t majorVersion = cAnyMajorVersion) noexcept;
50
54 virtual bool ValidateOption(const option::Option *option) const noexcept;
55
59 bool ContainsOption(option::OptionType optionType) const noexcept;
60
64 virtual std::vector<uint8_t> BasePayload(uint8_t &optionIndex) const;
65
66 public:
68 static const uint16_t cAnyInstanceId = 0xffff;
70 static const uint8_t cAnyMajorVersion = 0xff;
72 static const uint8_t cOptionSizeBitLength = 4;
73
74 Entry(Entry &&other);
75 virtual ~Entry() noexcept = default;
76
77 Entry &operator=(Entry &&other);
78
81 EntryType Type() const noexcept;
82
85 uint16_t ServiceId() const noexcept;
86
89 uint16_t InstanceId() const noexcept;
90
93 uint8_t MajorVersion() const noexcept;
94
97 uint32_t TTL() const noexcept;
98
101 const std::vector<std::unique_ptr<option::Option>> &FirstOptions() const noexcept;
102
105 void AddFirstOption(std::unique_ptr<option::Option> firstOption);
106
109 const std::vector<std::unique_ptr<option::Option>> &SecondOptions() const noexcept;
110
113 void AddSecondOption(std::unique_ptr<option::Option> secondOption);
114
118 virtual std::vector<uint8_t> Payload(uint8_t &optionIndex) const = 0;
119 };
120 }
121 }
122}
123
124#endif
Communication message abstract entry.
Definition: entry.h:28
EntryType Type() const noexcept
Get entry type.
Definition: entry.cpp:111
uint32_t TTL() const noexcept
Get TTL.
Definition: entry.cpp:131
void AddSecondOption(std::unique_ptr< option::Option > secondOption)
Add a second (specific) option.
Definition: entry.cpp:160
void AddFirstOption(std::unique_ptr< option::Option > firstOption)
Add a first (general) option.
Definition: entry.cpp:141
uint16_t InstanceId() const noexcept
Get instance ID.
Definition: entry.cpp:121
uint16_t ServiceId() const noexcept
Get service ID.
Definition: entry.cpp:116
static const uint16_t cAnyInstanceId
Any service instance ID.
Definition: entry.h:68
uint8_t MajorVersion() const noexcept
Get major version.
Definition: entry.cpp:126
static const uint8_t cOptionSizeBitLength
Option number field bit size.
Definition: entry.h:72
const std::vector< std::unique_ptr< option::Option > > & SecondOptions() const noexcept
Get second (specific) options.
Definition: entry.cpp:155
static const uint8_t cAnyMajorVersion
Any service major version.
Definition: entry.h:70
Entry(EntryType type, uint16_t serviceId, uint16_t instanceId, uint32_t ttl, uint8_t majorVersion=cAnyMajorVersion) noexcept
Constructor.
Definition: entry.cpp:9
virtual bool ValidateOption(const option::Option *option) const noexcept
Validate an option for adding.
Definition: entry.cpp:44
virtual std::vector< uint8_t > BasePayload(uint8_t &optionIndex) const
Get baseentity payload.
Definition: entry.cpp:174
bool ContainsOption(option::OptionType optionType) const noexcept
Indicate whether the entry contains a specific option type or not.
Definition: entry.cpp:90
const std::vector< std::unique_ptr< option::Option > > & FirstOptions() const noexcept
Get first (general) options.
Definition: entry.cpp:136
virtual std::vector< uint8_t > Payload(uint8_t &optionIndex) const =0
Get entity payload.
Communication message entry abstract option.
Definition: option.h:37
EntryType
Message entry type.
Definition: entry.h:19
@ Subscribing
Event start/stop subscribing.
@ Finding
Service finding.
@ Offering
Service start/stop offering.
@ Acknowledging
Event subscribe positive/negative acknowledging.
OptionType
Entry option type.
Definition: option.h:17