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 : #include "someip/RpcBaseClient.h"
12 :
13 : #include "someip/IRpcChannel.h"
14 :
15 : namespace someip
16 : {
17 3 : RpcBaseClient::RpcBaseClient() : _pChannel(nullptr) {}
18 :
19 1 : void RpcBaseClient::connect(IRpcChannel& channel) { _pChannel = &channel; }
20 :
21 1 : void RpcBaseClient::disconnect() { _pChannel = nullptr; }
22 :
23 5 : bool RpcBaseClient::isConnected() const { return _pChannel != nullptr; }
24 :
25 1 : void RpcBaseClient::callMethod(
26 : uint16_t const methodId,
27 : ISomeIpSerializable const* const request,
28 : ISomeIpSerializable* const response,
29 : uint8_t const interfaceVersion,
30 : CallDoneClosure& done,
31 : uint32_t const timeout)
32 : {
33 1 : ServiceResultCode result = RPC_ERROR_NO_CHANNEL;
34 :
35 : {
36 1 : if (isConnected())
37 : {
38 0 : result = _pChannel->callMethod(
39 : methodId, request, interfaceVersion, response, done, timeout);
40 : }
41 : }
42 :
43 1 : if (RPC_SENT_SUCCESSFULLY != result)
44 : {
45 1 : done(result);
46 : }
47 1 : }
48 :
49 1 : void RpcBaseClient::callFireAndForget(
50 : uint16_t const methodId,
51 : ISomeIpSerializable const* const request,
52 : uint8_t const interfaceVersion,
53 : CallDoneClosure& done)
54 : {
55 1 : ServiceResultCode result = RPC_ERROR_NO_CHANNEL;
56 :
57 : {
58 1 : if (isConnected())
59 : {
60 0 : result = _pChannel->callFireAndForgetMethod(methodId, request, interfaceVersion);
61 : }
62 : }
63 :
64 1 : done(result);
65 1 : }
66 :
67 : } // namespace someip
|