eRPC API Reference  Rev. 1.12.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) : m_serviceId(serviceId), m_next(NULL) {}
48 
52  virtual ~Service(void) {}
53 
59  uint32_t getServiceId(void) const { return m_serviceId; }
60 
66  Service *getNext(void) { return m_next; }
67 
73  void setNext(Service *next) { m_next = next; }
74 
85  virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, Codec *codec,
86  MessageBufferFactory *messageFactory, Transport *transport) = 0;
87 
88 protected:
89  uint32_t m_serviceId;
91 };
92 
98 class Server : public ClientServerCommon
99 {
100 public:
106  Server(void) : ClientServerCommon(), m_firstService(NULL) {}
107 
111  virtual ~Server(void) {}
112 
118  void addService(Service *service);
119 
125  void removeService(Service *service);
126 
130  virtual erpc_status_t run(void) = 0;
131 
135  virtual void stop(void) = 0;
136 
137 protected:
151  virtual erpc_status_t processMessage(Codec *codec, message_type_t msgType, uint32_t serviceId, uint32_t methodId,
152  uint32_t sequence);
153 
165  virtual erpc_status_t readHeadOfMessage(Codec *codec, message_type_t &msgType, uint32_t &serviceId,
166  uint32_t &methodId, uint32_t &sequence);
167 
175  virtual Service *findServiceWithId(uint32_t serviceId);
176 
177 #if ERPC_NESTED_CALLS
178  friend class ClientManager;
179  friend class ArbitratedClientManager;
180 
186  virtual erpc_status_t run(RequestContext &request) = 0;
187 #endif
188 
189 private:
190  // Disable copy ctor.
191  Server(const Server &other);
192  Server &operator=(const Server &other);
193 };
194 
195 } // namespace erpc
196 
199 #endif // _EMBEDDED_RPC__SERVER_H_
Abstract interface for transport layer.
Definition: erpc_transport.hpp:36
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:56
Abstract interface for service, which can be executed on server side.
Definition: erpc_server.hpp:39
uint32_t m_serviceId
Definition: erpc_server.hpp:89
Abstract serialization encoder/decoder interface.
Definition: erpc_codec.hpp:53
virtual ~Service(void)
Service destructor.
Definition: erpc_server.hpp:52
Service * m_next
Definition: erpc_server.hpp:90
Server(void)
Constructor.
Definition: erpc_server.hpp:106
Common class inherited by client and server class.
Definition: erpc_client_server_common.hpp:39
virtual ~Server(void)
Server destructor.
Definition: erpc_server.hpp:111
Service * getNext(void)
Return next service.
Definition: erpc_server.hpp:66
Client that can share a transport with a server.
Definition: erpc_arbitrated_client_manager.hpp:40
Based server functionality.
Definition: erpc_server.hpp:98
Definition: erpc_arbitrated_client_manager.hpp:25
uint32_t getServiceId(void) const
Return service id number.
Definition: erpc_server.hpp:59
virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, Codec *codec, MessageBufferFactory *messageFactory, Transport *transport)=0
This function call function implementation of current service.
void setNext(Service *next)
Set next service.
Definition: erpc_server.hpp:73
Abstract interface for message buffer factory.
Definition: erpc_message_buffer.hpp:344
Service * m_firstService
Definition: erpc_server.hpp:138
Encapsulates all information about a request.
Definition: erpc_client_manager.h:184