Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
network_configuration.h
1#ifndef NETWORK_CONFIGURATION_H
2#define NETWORK_CONFIGURATION_H
3
4#include <map>
5#include <string>
6#include "../../arxml/arxml_reader.h"
7#include "../../ara/com/option/option.h"
8
9namespace application
10{
11 namespace helper
12 {
13 static const std::array<std::string, 7> cIpAddressShallowChildren(
14 {"AUTOSAR",
15 "AR-PACKAGES",
16 "AR-PACKAGE",
17 "ELEMENTS",
18 "COMMUNICATION-CLUSTER",
19 "ETHERNET-PHYSICAL-CHANNEL",
20 "NETWORK-ENDPOINTS"});
21
22 static const std::array<std::string, 4> cIpAddressDeepChildren(
23 {"NETWORK-ENDPOINT",
24 "NETWORK-ENDPOINT-ADDRESSES",
25 "IPV-4-CONFIGURATION",
26 "IPV-4-ADDRESS"});
27
28 static const std::array<std::string, 6> cPortNumberShallowChildren(
29 {"AUTOSAR",
30 "AR-PACKAGES",
31 "AR-PACKAGE",
32 "ELEMENTS",
33 "ETHERNET-COMMUNICATION-CONNECTOR",
34 "AP-APPLICATION-ENDPOINTS"});
35
36 static const std::array<std::string, 5> cTcpPortNumberDeepChildren(
37 {"AP-APPLICATION-ENDPOINT",
38 "TP-CONFIGURATION",
39 "TCP-TP",
40 "TCP-TP-PORT",
41 "PORT-NUMBER"});
42
43 static const std::array<std::string, 5> cUdpPortNumberDeepChildren(
44 {"AP-APPLICATION-ENDPOINT",
45 "TP-CONFIGURATION",
46 "UDP-TP",
47 "UDP-TP-PORT",
48 "PORT-NUMBER"});
49
52 {
54 std::string ipAddress;
55
57 uint16_t portNumber;
58 };
59
70 template <typename T, size_t M, size_t N>
72 const arxml::ArxmlReader &shallowReader,
73 const std::array<std::string, M> &shallowChildren,
74 const std::array<std::string, N> &deepChildren,
75 std::string shortNameFilter,
76 T &deepValue)
77 {
78 const arxml::ArxmlNodeRange cShallowNodes{
79 shallowReader.GetNodes(shallowChildren)};
80
81 for (const auto cShallowNode : cShallowNodes)
82 {
83 if (shortNameFilter.empty())
84 {
85 deepValue = cShallowNode.GetValue<T>();
86 return true;
87 }
88
89 std::string _shortName{cShallowNode.GetShortName()};
90 if (_shortName == shortNameFilter)
91 {
92 std::string _content{cShallowNode.GetContent()};
93 arxml::ArxmlReader _deepReader(_content.c_str(), _content.length());
94 arxml::ArxmlNode _deepNode{_deepReader.GetRootNode(deepChildren)};
95 deepValue = _deepNode.GetValue<T>();
96
97 return true;
98 }
99 }
100
101 return false;
102 }
103
112 const arxml::ArxmlReader &reader,
113 std::string networkEndpoint,
114 std::string applicationEndpoint,
116 NetworkConfiguration &configuration);
117
126 const std::string &configFilepath,
127 std::string networkEndpoint,
128 std::string applicationEndpoint,
130 NetworkConfiguration &configuration);
131 }
132
133}
134
135#endif
Read-only range of ARXML nodes.
Definition: arxml_node_range.h:13
A class that represents a XML node within a ARXML configuration.
Definition: arxml_node.h:11
T GetValue(T defaultValue={}) const
Get the node value.
Definition: arxml_node.h:27
A class to read ARXML configuration files.
Definition: arxml_reader.h:14
ArxmlNodeRange GetNodes(std::initializer_list< std::string > children) const
Get a range of ARXML nodes deep down the ARXML content.
Definition: arxml_reader.cpp:77
ArxmlNode GetRootNode(std::initializer_list< std::string > children) const
Get (relative) ARXML root node.
Definition: arxml_reader.cpp:63
bool TryGetNetworkConfiguration(const arxml::ArxmlReader &reader, std::string networkEndpoint, std::string applicationEndpoint, ara::com::option::Layer4ProtocolType protocol, NetworkConfiguration &configuration)
Try to get a nework configuration based on a ARXML configuration file.
Definition: network_configuration.cpp:7
bool TryExtractDeepValue(const arxml::ArxmlReader &shallowReader, const std::array< std::string, M > &shallowChildren, const std::array< std::string, N > &deepChildren, std::string shortNameFilter, T &deepValue)
Try to extract a deep value from an XML content.
Definition: network_configuration.h:71
AUTOSAR application namespace.
Definition: diag_message_handler.cpp:5
Layer4ProtocolType
OSI layer-4 protocol type.
Definition: option.h:30
Data model for a network configuration.
Definition: network_configuration.h:52
std::string ipAddress
Netowrk IPv4 address.
Definition: network_configuration.h:54
uint16_t portNumber
Network TCP/UDP port number.
Definition: network_configuration.h:57