| eRPC API Reference Rev. 1.8.1 NXP Semiconductors

- Main Page
- API Reference
- Classes
- Files

- File List
- File Members

erpc_client_manager.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
3 * Copyright 2016-2017 NXP
4 * Copyright 2020-2021 ACRIOS Systems s.r.o.
5 * All rights reserved.
6 *
7 *
8 * SPDX-License-Identifier: BSD-3-Clause
9 */
10
11 #ifndef _EMBEDDED_RPC__CLIENT_MANAGER_H_
12 #define _EMBEDDED_RPC__CLIENT_MANAGER_H_
13
14 #ifdef __cplusplus
15 #include "erpc_client_server_common.h"
16 #include "erpc_codec.h"
17 #include "erpc_config_internal.h"
18 #if ERPC_NESTED_CALLS
19 #include "erpc_server.h"
20 #include "erpc_threading.h"
21 #endif
22
29 extern "C" {
30 #endif
31
32 typedef void (*client_error_handler_t)(erpc_status_t err,
33 uint32_t functionID);
35 #ifdef __cplusplus
36 }
37
39 // Classes
41
42 namespace erpc {
43 class RequestContext;
44 #if ERPC_NESTED_CALLS
45 class Server;
46 #endif
47
53 class ClientManager : public ClientServerCommon
54 {
55 public:
61 ClientManager(void)
62 : ClientServerCommon()
63 , m_messageFactory(NULL)
64 , m_codecFactory(NULL)
65 , m_transport(NULL)
66 , m_sequence(0)
67 , m_errorHandler(NULL)
68 #if ERPC_NESTED_CALLS
69 , m_server(NULL)
70 , m_serverThreadId(NULL)
71 #endif
72 {
73 }
74
78 virtual ~ClientManager(void) {}
79
85 void setMessageBufferFactory(MessageBufferFactory *factory) { m_messageFactory = factory; }
86
92 void setCodecFactory(CodecFactory *factory) { m_codecFactory = factory; }
93
101 void setTransport(Transport *transport);
102
108 virtual RequestContext createRequest(bool isOneway);
109
115 virtual void performRequest(RequestContext &request);
116
122 virtual void releaseRequest(RequestContext &request);
123
129 void setErrorHandler(client_error_handler_t error_handler) { m_errorHandler = error_handler; }
130
139 void callErrorHandler(erpc_status_t err, uint32_t functionID);
140
141 #if ERPC_NESTED_CALLS
142
147 void setServer(Server *server) { m_server = server; }
148
154 void setServerThreadId(Thread::thread_id_t serverThreadId) { m_serverThreadId = serverThreadId; }
155 #endif
156
157 protected:
158 MessageBufferFactory *m_messageFactory;
159 CodecFactory *m_codecFactory;
160 Transport *m_transport;
161 uint32_t m_sequence;
162 client_error_handler_t m_errorHandler;
163 #if ERPC_NESTED_CALLS
164 Server *m_server;
165 Thread::thread_id_t m_serverThreadId;
166 #endif
167
176 virtual void performClientRequest(RequestContext &request);
177
178 #if ERPC_NESTED_CALLS
179
186 virtual void performNestedClientRequest(RequestContext &request);
187 #endif
188
190 virtual void verifyReply(RequestContext &request);
191
200 Codec *createBufferAndCodec(void);
201
202 private:
203 ClientManager(const ClientManager &other);
204 ClientManager &operator=(const ClientManager &other);
205 };
206
212 class RequestContext
213 {
214 public:
224 RequestContext(uint32_t sequence, Codec *codec, bool argIsOneway)
225 : m_sequence(sequence)
226 , m_codec(codec)
227 , m_oneway(argIsOneway)
228 {
229 }
230
236 Codec *getCodec(void) { return m_codec; }
237
243 uint32_t getSequence(void) const { return m_sequence; }
244
250 bool isOneway(void) const { return m_oneway; }
251
257 void setIsOneway(bool oneway) { m_oneway = oneway; }
258
259 protected:
260 uint32_t m_sequence;
261 Codec *m_codec;
262 bool m_oneway;
263 };
264
265 } // namespace erpc
266
269 #endif
270
271 #endif // _EMBEDDED_RPC__CLIENT_MANAGER_H_
erpc::Transport
Abstract interface for transport layer.
Definition: erpc_transport.h:36
erpc::ClientManager::m_transport
Transport * m_transport
Transport layer to use.
Definition: erpc_client_manager.h:160
erpc_status_t
enum _erpc_status erpc_status_t
Type used for all status and error return values.
Definition: erpc_common.h:87
erpc::ClientManager
Base client implementation.
Definition: erpc_client_manager.h:53
erpc::ClientManager::m_sequence
uint32_t m_sequence
Sequence number.
Definition: erpc_client_manager.h:161
erpc_client_server_common.h
erpc::Codec
Abstract serialization encoder/decoder interface.
Definition: erpc_codec.h:53
erpc::ClientManager::m_codecFactory
CodecFactory * m_codecFactory
Codec to use.
Definition: erpc_client_manager.h:159
erpc::RequestContext::m_oneway
bool m_oneway
When true, request context will be oneway type (only send data).
Definition: erpc_client_manager.h:262
erpc::RequestContext::m_sequence
uint32_t m_sequence
Sequence number. To be sure that reply belong to current request.
Definition: erpc_client_manager.h:260
erpc::RequestContext::setIsOneway
void setIsOneway(bool oneway)
Set request context to be oneway type (only send data).
Definition: erpc_client_manager.h:257
erpc_codec.h
erpc::ClientManager::verifyReply
virtual void verifyReply(RequestContext &request)
Validate that an incoming message is a reply.
Definition: erpc_client_manager.cpp:168
erpc::ClientManager::callErrorHandler
void callErrorHandler(erpc_status_t err, uint32_t functionID)
This function calls error handler callback function with given status.
Definition: erpc_client_manager.cpp:221
erpc::RequestContext::isOneway
bool isOneway(void) const
Returns information if request context is oneway or not.
Definition: erpc_client_manager.h:250
erpc::ClientServerCommon
Common class inheritand by client and server class.
Definition: erpc_client_server_common.h:38
erpc::CodecFactory
Abstract interface for codec factory.
Definition: erpc_codec.h:441
erpc::ClientManager::ClientManager
ClientManager(void)
Constructor.
Definition: erpc_client_manager.h:61
erpc::ClientManager::performClientRequest
virtual void performClientRequest(RequestContext &request)
This function performs request.
Definition: erpc_client_manager.cpp:66
erpc::ClientManager::setTransport
void setTransport(Transport *transport)
This function sets transport layer to use.
Definition: erpc_client_manager.cpp:29
erpc::Server
Based server functionality.
Definition: erpc_server.h:103
erpc::RequestContext::getSequence
uint32_t getSequence(void) const
Get sequence number (be sure that reply belong to current request).
Definition: erpc_client_manager.h:243
ERPC_NESTED_CALLS
#define ERPC_NESTED_CALLS
erpc
Definition: erpc_arbitrated_client_manager.h:25
erpc::ClientManager::m_messageFactory
MessageBufferFactory * m_messageFactory
Message buffer factory to use.
Definition: erpc_client_manager.h:158
erpc::ClientManager::~ClientManager
virtual ~ClientManager(void)
ClientManager destructor.
Definition: erpc_client_manager.h:78
erpc::RequestContext::RequestContext
RequestContext(uint32_t sequence, Codec *codec, bool argIsOneway)
Constructor.
Definition: erpc_client_manager.h:224
erpc_threading.h
erpc::RequestContext::getCodec
Codec * getCodec(void)
Get inout codec (for writing).
Definition: erpc_client_manager.h:236
erpc::RequestContext::m_codec
Codec * m_codec
Inout codec. Codec for receiving and sending data.
Definition: erpc_client_manager.h:261
erpc::ClientManager::createBufferAndCodec
Codec * createBufferAndCodec(void)
Create message buffer and codec.
Definition: erpc_client_manager.cpp:192
client_error_handler_t
void(* client_error_handler_t)(erpc_status_t err, uint32_t functionID)
Definition: erpc_client_manager.h:32
erpc::Thread::thread_id_t
void * thread_id_t
Unique identifier for a thread.
Definition: erpc_threading.h:70
erpc::ClientManager::createRequest
virtual RequestContext createRequest(bool isOneway)
This function creates request context.
Definition: erpc_client_manager.cpp:34
erpc::MessageBufferFactory
Abstract interface for message buffer factory.
Definition: erpc_message_buffer.h:365
erpc_server.h
erpc::ClientManager::setCodecFactory
void setCodecFactory(CodecFactory *factory)
This function sets codec factory to use.
Definition: erpc_client_manager.h:92
erpc::ClientManager::setErrorHandler
void setErrorHandler(client_error_handler_t error_handler)
This function sets error handler function for infrastructure errors.
Definition: erpc_client_manager.h:129
erpc::ClientManager::setMessageBufferFactory
void setMessageBufferFactory(MessageBufferFactory *factory)
This function sets message buffer factory to use.
Definition: erpc_client_manager.h:85
erpc::ClientManager::performRequest
virtual void performRequest(RequestContext &request)
This function performs request.
Definition: erpc_client_manager.cpp:42
erpc::ClientManager::releaseRequest
virtual void releaseRequest(RequestContext &request)
This function releases request context.
Definition: erpc_client_manager.cpp:215
erpc::RequestContext
Encapsulates all information about a request.
Definition: erpc_client_manager.h:212
erpc::ClientManager::m_errorHandler
client_error_handler_t m_errorHandler
Pointer to function error handler.
Definition: erpc_client_manager.h:162