| eRPC API Reference Rev. 1.8.1 NXP Semiconductors

- Main Page
- API Reference
- Classes
- Files

- File List
- File Members

erpc_server.h
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
14 #include "erpc_client_server_common.h"
15 #include "erpc_codec.h"
16 #include "erpc_config_internal.h"
17 #if ERPC_NESTED_CALLS
18 #include "erpc_client_manager.h"
19 #endif
20
27 // Classes
30
31 namespace erpc {
32 #if ERPC_NESTED_CALLS
33 class RequestContext;
34 #endif
35
40 class Service
41 {
42 public:
48 Service(uint32_t serviceId)
49 : m_serviceId(serviceId)
50 , m_next(NULL)
51 {
52 }
53
57 virtual ~Service(void) {}
58
64 uint32_t getServiceId(void) const { return m_serviceId; }
65
71 Service *getNext(void) { return m_next; }
72
78 void setNext(Service *next) { m_next = next; }
79
90 virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, Codec *codec,
91 MessageBufferFactory *messageFactory) = 0;
92
93 protected:
94 uint32_t m_serviceId;
95 Service *m_next;
96 };
97
103 class Server : public ClientServerCommon
104 {
105 public:
111 Server(void)
112 : ClientServerCommon()
113 , m_messageFactory(NULL)
114 , m_codecFactory(NULL)
115 , m_transport(NULL)
116 , m_firstService(NULL)
117 {
118 }
119
123 virtual ~Server(void) {}
124
130 void setMessageBufferFactory(MessageBufferFactory *factory) { m_messageFactory = factory; }
131
137 void setCodecFactory(CodecFactory *factory) { m_codecFactory = factory; }
138
146 void setTransport(Transport *transport);
147
153 void addService(Service *service);
154
160 void removeService(Service *service);
161
165 virtual erpc_status_t run(void) = 0;
166
170 virtual void stop(void) = 0;
171
172 protected:
173 MessageBufferFactory *m_messageFactory;
174 CodecFactory *m_codecFactory;
175 Transport *m_transport;
176 Service *m_firstService;
189 virtual erpc_status_t processMessage(Codec *codec, message_type_t msgType, uint32_t serviceId, uint32_t methodId,
190 uint32_t sequence);
191
203 virtual erpc_status_t readHeadOfMessage(Codec *codec, message_type_t &msgType, uint32_t &serviceId,
204 uint32_t &methodId, uint32_t &sequence);
205
213 virtual Service *findServiceWithId(uint32_t serviceId);
214
215 #if ERPC_NESTED_CALLS
216 friend class ClientManager;
217 friend class ArbitratedClientManager;
218
224 virtual erpc_status_t run(RequestContext &request) = 0;
225 #endif
226
227 private:
228 // Disable copy ctor.
229 Server(const Server &other);
230 Server &operator=(const Server &other);
231 };
232
233 } // namespace erpc
234
237 #endif // _EMBEDDED_RPC__SERVER_H_
erpc::Transport
Abstract interface for transport layer.
Definition: erpc_transport.h:36
erpc::Server::setCodecFactory
void setCodecFactory(CodecFactory *factory)
Set CodecFactory to use.
Definition: erpc_server.h:137
erpc::Service::Service
Service(uint32_t serviceId)
Constructor.
Definition: erpc_server.h:48
erpc::message_type_t
message_type_t
Types of messages that can be encoded.
Definition: erpc_codec.h:35
erpc_client_manager.h
erpc_status_t
enum _erpc_status erpc_status_t
Type used for all status and error return values.
Definition: erpc_common.h:87
erpc::Server::m_transport
Transport * m_transport
Definition: erpc_server.h:175
erpc::ClientManager
Base client implementation.
Definition: erpc_client_manager.h:53
erpc::Service
Abstract interface for service, which can be executed on server side.
Definition: erpc_server.h:40
erpc::Service::m_serviceId
uint32_t m_serviceId
Definition: erpc_server.h:94
erpc_client_server_common.h
erpc::Codec
Abstract serialization encoder/decoder interface.
Definition: erpc_codec.h:53
erpc::Server::m_codecFactory
CodecFactory * m_codecFactory
Definition: erpc_server.h:174
erpc_codec.h
erpc::Service::~Service
virtual ~Service(void)
Service destructor.
Definition: erpc_server.h:57
erpc::Service::m_next
Service * m_next
Definition: erpc_server.h:95
erpc::Server::Server
Server(void)
Constructor.
Definition: erpc_server.h:111
erpc::ClientServerCommon
Common class inheritand by client and server class.
Definition: erpc_client_server_common.h:38
erpc::Server::~Server
virtual ~Server(void)
ClientManager destructor.
Definition: erpc_server.h:123
erpc::CodecFactory
Abstract interface for codec factory.
Definition: erpc_codec.h:441
erpc::Service::getNext
Service * getNext(void)
Return next service.
Definition: erpc_server.h:71
erpc::ArbitratedClientManager
Client that can share a transport with a server.
Definition: erpc_arbitrated_client_manager.h:40
erpc::Server
Based server functionality.
Definition: erpc_server.h:103
erpc
Definition: erpc_arbitrated_client_manager.h:25
erpc::Server::setMessageBufferFactory
void setMessageBufferFactory(MessageBufferFactory *factory)
Set MessageBufferFactory to use.
Definition: erpc_server.h:130
erpc::Service::getServiceId
uint32_t getServiceId(void) const
Return service id number.
Definition: erpc_server.h:64
erpc::Service::setNext
void setNext(Service *next)
Set next service.
Definition: erpc_server.h:78
erpc::Server::m_messageFactory
MessageBufferFactory * m_messageFactory
Definition: erpc_server.h:173
erpc::Service::handleInvocation
virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, Codec *codec, MessageBufferFactory *messageFactory)=0
This function call function implementation of current service.
erpc::MessageBufferFactory
Abstract interface for message buffer factory.
Definition: erpc_message_buffer.h:365
erpc::Server::m_firstService
Service * m_firstService
Definition: erpc_server.h:176
erpc::RequestContext
Encapsulates all information about a request.
Definition: erpc_client_manager.h:212