eRPC API Reference  Rev. 1.11.0
NXP Semiconductors
erpc_transport_arbitrator.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  *
7  * SPDX-License-Identifier: BSD-3-Clause
8  */
9 #if !defined(__embedded_rpc__transport_arbitrator__)
10 #define __embedded_rpc__transport_arbitrator__
11 
12 #include "erpc_client_manager.h"
13 #include "erpc_codec.hpp"
14 #include "erpc_threading.h"
15 #include "erpc_transport.hpp"
16 
23 // Classes
26 
27 namespace erpc {
28 class Codec;
29 
41 {
42 public:
44  typedef uintptr_t client_token_t;
45 
49  TransportArbitrator(void);
50 
54  virtual ~TransportArbitrator(void);
55 
61  void setSharedTransport(Transport *shared) { m_sharedTransport = shared; }
62 
69 
75  void setCodec(Codec *codec) { m_codec = codec; }
76 
82  Codec *getCodec(void) { return m_codec; }
83 
93  virtual erpc_status_t receive(MessageBuffer *message) override;
94 
106  client_token_t prepareClientReceive(RequestContext &request);
107 
118  erpc_status_t clientReceive(client_token_t token);
119 
129  virtual erpc_status_t send(MessageBuffer *message) override;
130 
136  virtual void setCrc16(Crc16 *crcImpl) override;
137 
143  virtual Crc16 *getCrc16(void) override;
144 
151  virtual bool hasMessage(void) override;
152 
157  {
160  bool m_isValid;
166  PendingClientInfo(void);
167 
171  ~PendingClientInfo(void);
172  };
173 
174 protected:
177 
181 
188 
195 
202 
208  void freeClientList(PendingClientInfo *list);
209 
210 private:
211  // Disable copy ctor.
213  TransportArbitrator &operator=(const TransportArbitrator &other);
214 };
215 
216 } // namespace erpc
217 
220 #endif // defined(__embedded_rpc__transport_arbitrator__)
221 // EOF
Abstract interface for transport layer.
Definition: erpc_transport.hpp:36
Codec * getCodec(void)
This function get codec.
Definition: erpc_transport_arbitrator.hpp:82
Interposer to share transport between client and server.
Definition: erpc_transport_arbitrator.hpp:40
~PendingClientInfo(void)
Destructor.
Definition: erpc_transport_arbitrator.cpp:263
enum _erpc_status erpc_status_t
Type used for all status and error return values.
Definition: erpc_common.h:85
erpc_status_t clientReceive(client_token_t token)
Receive method for the client.
Definition: erpc_transport_arbitrator.cpp:165
PendingClientInfo * createPendingClient(void)
Create a Pending Client object.
Definition: erpc_transport_arbitrator.cpp:180
virtual Crc16 * getCrc16(void) override
This functions gets the CRC-16 object.
Definition: erpc_transport_arbitrator.cpp:54
Abstract serialization encoder/decoder interface.
Definition: erpc_codec.hpp:53
client_token_t prepareClientReceive(RequestContext &request)
Add a client request to the client list.
Definition: erpc_transport_arbitrator.cpp:154
PendingClientInfo * addPendingClient(void)
This function adds pending client.
Definition: erpc_transport_arbitrator.cpp:183
Request info for a client trying to receive a response.
Definition: erpc_transport_arbitrator.hpp:156
Transport * getSharedTransport(void)
This function returns shared client/server transport.
Definition: erpc_transport_arbitrator.hpp:68
PendingClientInfo(void)
Constructor.
Definition: erpc_transport_arbitrator.cpp:255
bool m_isValid
Definition: erpc_transport_arbitrator.hpp:160
Transport * m_sharedTransport
Transport being shared through this arbitrator.
Definition: erpc_transport_arbitrator.hpp:175
void freeClientList(PendingClientInfo *list)
This function removes pending client list.
Definition: erpc_transport_arbitrator.cpp:242
PendingClientInfo * m_clientFreeList
Unused client receive info structs.
Definition: erpc_transport_arbitrator.hpp:179
Represents a memory buffer containing a message.
Definition: erpc_message_buffer.hpp:37
Definition: erpc_arbitrated_client_manager.hpp:25
PendingClientInfo * m_next
Definition: erpc_transport_arbitrator.hpp:161
void removePendingClient(PendingClientInfo *info)
This function removes pending client.
Definition: erpc_transport_arbitrator.cpp:209
virtual ~TransportArbitrator(void)
Destructor.
Definition: erpc_transport_arbitrator.cpp:40
Class for compute crc16.
Definition: erpc_crc16.hpp:29
RequestContext * m_request
Definition: erpc_transport_arbitrator.hpp:158
virtual void setCrc16(Crc16 *crcImpl) override
This functions sets the CRC-16 implementation.
Definition: erpc_transport_arbitrator.cpp:47
void setCodec(Codec *codec)
This function set codec.
Definition: erpc_transport_arbitrator.hpp:75
PendingClientInfo * m_clientList
Active client receive requests.
Definition: erpc_transport_arbitrator.hpp:178
Codec * m_codec
Codec used to read incoming message headers.
Definition: erpc_transport_arbitrator.hpp:176
Mutex m_clientListMutex
Mutex guarding the client active and free lists.
Definition: erpc_transport_arbitrator.hpp:180
virtual erpc_status_t receive(MessageBuffer *message) override
Prototype for receiving message.
Definition: erpc_transport_arbitrator.cpp:67
void setSharedTransport(Transport *shared)
This function set shared client/server transport.
Definition: erpc_transport_arbitrator.hpp:61
Semaphore m_sem
Definition: erpc_transport_arbitrator.hpp:159
TransportArbitrator(void)
Constructor.
Definition: erpc_transport_arbitrator.cpp:30
virtual erpc_status_t send(MessageBuffer *message) override
Prototype for send message.
Definition: erpc_transport_arbitrator.cpp:148
uintptr_t client_token_t
Represents a single client's receive request.
Definition: erpc_transport_arbitrator.hpp:44
Mutex.
Definition: erpc_threading.h:338
virtual bool hasMessage(void) override
Check if the underlying shared transport has a message.
Definition: erpc_transport_arbitrator.cpp:60
Simple semaphore class.
Definition: erpc_threading.h:445
Encapsulates all information about a request.
Definition: erpc_client_manager.h:184