eRPC API Reference  Rev. 1.11.0
NXP Semiconductors
erpc_server.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * Copyright 2020 ACRIOS Systems s.r.o.
5  * All rights reserved.
6  *
7  *
8  * SPDX-License-Identifier: BSD-3-Clause
9  */
10 
11 #ifndef _EMBEDDED_RPC__SERVER_H_
12 #define _EMBEDDED_RPC__SERVER_H_
13 
15 #include "erpc_config_internal.h"
16 #if ERPC_NESTED_CALLS
17 #include "erpc_client_manager.h"
18 #endif
19 
26 // Classes
29 
30 namespace erpc {
31 #if ERPC_NESTED_CALLS
32 class RequestContext;
33 #endif
34 
39 class Service
40 {
41 public:
47  Service(uint32_t serviceId)
48  : m_serviceId(serviceId)
49  , m_next(NULL)
50  {
51  }
52 
56  virtual ~Service(void) {}
57 
63  uint32_t getServiceId(void) const { return m_serviceId; }
64 
70  Service *getNext(void) { return m_next; }
71 
77  void setNext(Service *next) { m_next = next; }
78 
89  virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, Codec *codec,
90  MessageBufferFactory *messageFactory) = 0;
91 
92 protected:
93  uint32_t m_serviceId;
95 };
96 
103 {
104 public:
110  Server(void)
112  , m_firstService(NULL)
113  {
114  }
115 
119  virtual ~Server(void) {}
120 
126  void addService(Service *service);
127 
133  void removeService(Service *service);
134 
138  virtual erpc_status_t run(void) = 0;
139 
143  virtual void stop(void) = 0;
144 
145 protected:
159  virtual erpc_status_t processMessage(Codec *codec, message_type_t msgType, uint32_t serviceId, uint32_t methodId,
160  uint32_t sequence);
161 
173  virtual erpc_status_t readHeadOfMessage(Codec *codec, message_type_t &msgType, uint32_t &serviceId,
174  uint32_t &methodId, uint32_t &sequence);
175 
183  virtual Service *findServiceWithId(uint32_t serviceId);
184 
185 #if ERPC_NESTED_CALLS
186  friend class ClientManager;
187  friend class ArbitratedClientManager;
188 
194  virtual erpc_status_t run(RequestContext &request) = 0;
195 #endif
196 
197 private:
198  // Disable copy ctor.
199  Server(const Server &other);
200  Server &operator=(const Server &other);
201 };
202 
203 } // namespace erpc
204 
207 #endif // _EMBEDDED_RPC__SERVER_H_
Service(uint32_t serviceId)
Constructor.
Definition: erpc_server.hpp:47
message_type_t
Types of messages that can be encoded.
Definition: erpc_codec.hpp:35
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:54
Abstract interface for service, which can be executed on server side.
Definition: erpc_server.hpp:39
uint32_t m_serviceId
Definition: erpc_server.hpp:93
Abstract serialization encoder/decoder interface.
Definition: erpc_codec.hpp:53
virtual ~Service(void)
Service destructor.
Definition: erpc_server.hpp:56
Service * m_next
Definition: erpc_server.hpp:94
Server(void)
Constructor.
Definition: erpc_server.hpp:110
Common class inherited by client and server class.
Definition: erpc_client_server_common.hpp:39
virtual ~Server(void)
Server destructor.
Definition: erpc_server.hpp:119
Service * getNext(void)
Return next service.
Definition: erpc_server.hpp:70
Client that can share a transport with a server.
Definition: erpc_arbitrated_client_manager.hpp:40
Based server functionality.
Definition: erpc_server.hpp:102
Definition: erpc_arbitrated_client_manager.hpp:25
uint32_t getServiceId(void) const
Return service id number.
Definition: erpc_server.hpp:63
void setNext(Service *next)
Set next service.
Definition: erpc_server.hpp:77
virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, Codec *codec, MessageBufferFactory *messageFactory)=0
This function call function implementation of current service.
Abstract interface for message buffer factory.
Definition: erpc_message_buffer.hpp:349
Service * m_firstService
Definition: erpc_server.hpp:146
Encapsulates all information about a request.
Definition: erpc_client_manager.h:184