eRPC API Reference  Rev. 1.12.0
NXP Semiconductors
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
16 #if ERPC_NESTED_CALLS
17 #include "erpc_server.hpp"
18 #include "erpc_threading.h"
19 #endif
20 
27 extern "C" {
28 #else
29 #include "erpc_common.h"
30 #endif
31 
33  uint32_t functionID);
35 typedef struct ClientType *erpc_client_t;
37 
38 #ifdef __cplusplus
39 }
40 
42 // Classes
44 
45 namespace erpc {
46 class RequestContext;
47 #if ERPC_NESTED_CALLS
48 class Server;
49 #endif
50 
57 {
58 public:
64  ClientManager(void) :
67  ,
68  m_server(NULL), m_serverThreadId(NULL)
69 #endif
70  {
71  }
72 
76  virtual ~ClientManager(void) {}
77 
83  virtual RequestContext createRequest(bool isOneway);
84 
90  virtual void performRequest(RequestContext &request);
91 
97  virtual void releaseRequest(RequestContext &request);
98 
104  void setErrorHandler(client_error_handler_t error_handler) { m_errorHandler = error_handler; }
105 
114  void callErrorHandler(erpc_status_t err, uint32_t functionID);
115 
116 #if ERPC_NESTED_CALLS
117 
122  void setServer(Server *server) { m_server = server; }
123 
129  void setServerThreadId(Thread::thread_id_t serverThreadId) { m_serverThreadId = serverThreadId; }
130 #endif
131 
132 protected:
133  uint32_t m_sequence;
135 #if ERPC_NESTED_CALLS
136  Server *m_server;
137  Thread::thread_id_t m_serverThreadId;
138 #endif
139 
148  virtual void performClientRequest(RequestContext &request);
149 
150 #if ERPC_NESTED_CALLS
151 
158  virtual void performNestedClientRequest(RequestContext &request);
159 #endif
160 
162  virtual void verifyReply(RequestContext &request);
163 
173 
174 private:
175  ClientManager(const ClientManager &other);
176  ClientManager &operator=(const ClientManager &other);
177 };
178 
185 {
186 public:
196  RequestContext(uint32_t sequence, Codec *codec, bool argIsOneway) :
197  m_sequence(sequence), m_codec(codec), m_oneway(argIsOneway)
198  {
199  }
200 
206  Codec *getCodec(void) { return m_codec; }
207 
213  uint32_t getSequence(void) const { return m_sequence; }
214 
220  bool isOneway(void) const { return m_oneway; }
221 
227  void setIsOneway(bool oneway) { m_oneway = oneway; }
228 
229 protected:
230  uint32_t m_sequence;
232  bool m_oneway;
233 };
234 
235 } // namespace erpc
236 
239 #endif
240 
241 #endif // _EMBEDDED_RPC__CLIENT_MANAGER_H_
enum _erpc_status erpc_status_t
Type used for all status and error return values.
Definition: erpc_common.h:85
Base client implementation.
Definition: erpc_client_manager.h:56
uint32_t m_sequence
Sequence number.
Definition: erpc_client_manager.h:133
Abstract serialization encoder/decoder interface.
Definition: erpc_codec.hpp:53
bool m_oneway
When true, request context will be oneway type (only send data).
Definition: erpc_client_manager.h:232
uint32_t m_sequence
Sequence number. To be sure that reply belong to current request.
Definition: erpc_client_manager.h:230
void setIsOneway(bool oneway)
Set request context to be oneway type (only send data).
Definition: erpc_client_manager.h:227
virtual void verifyReply(RequestContext &request)
Validate that an incoming message is a reply.
Definition: erpc_client_manager.cpp:161
void callErrorHandler(erpc_status_t err, uint32_t functionID)
This function calls error handler callback function with given status.
Definition: erpc_client_manager.cpp:218
bool isOneway(void) const
Returns information if request context is oneway or not.
Definition: erpc_client_manager.h:220
Common class inherited by client and server class.
Definition: erpc_client_server_common.hpp:39
ClientManager(void)
Constructor.
Definition: erpc_client_manager.h:64
virtual void performClientRequest(RequestContext &request)
This function performs request.
Definition: erpc_client_manager.cpp:59
Based server functionality.
Definition: erpc_server.hpp:98
uint32_t getSequence(void) const
Get sequence number (be sure that reply belong to current request).
Definition: erpc_client_manager.h:213
#define ERPC_NESTED_CALLS
Definition: erpc_arbitrated_client_manager.hpp:25
virtual ~ClientManager(void)
ClientManager destructor.
Definition: erpc_client_manager.h:76
RequestContext(uint32_t sequence, Codec *codec, bool argIsOneway)
Constructor.
Definition: erpc_client_manager.h:196
Codec * getCodec(void)
Get inout codec (for writing).
Definition: erpc_client_manager.h:206
Codec * m_codec
Inout codec. Codec for receiving and sending data.
Definition: erpc_client_manager.h:231
Codec * createBufferAndCodec(void)
Create message buffer and codec.
Definition: erpc_client_manager.cpp:185
struct ClientType * erpc_client_t
Opaque client object type.
Definition: erpc_client_manager.h:36
void(* client_error_handler_t)(erpc_status_t err, uint32_t functionID)
Definition: erpc_client_manager.h:32
void * thread_id_t
Unique identifier for a thread.
Definition: erpc_threading.h:73
virtual RequestContext createRequest(bool isOneway)
This function creates request context.
Definition: erpc_client_manager.cpp:27
void setErrorHandler(client_error_handler_t error_handler)
This function sets error handler function for infrastructure errors.
Definition: erpc_client_manager.h:104
virtual void performRequest(RequestContext &request)
This function performs request.
Definition: erpc_client_manager.cpp:35
virtual void releaseRequest(RequestContext &request)
This function releases request context.
Definition: erpc_client_manager.cpp:209
Encapsulates all information about a request.
Definition: erpc_client_manager.h:184
client_error_handler_t m_errorHandler
Pointer to function error handler.
Definition: erpc_client_manager.h:134