Ice 3.8
C++ API Reference
Loading...
Searching...
No Matches
Service.h
1// Copyright (c) ZeroC, Inc.
2
3#ifndef ICEBOX_SERVICE_H
4#define ICEBOX_SERVICE_H
5
6#include "Ice/Ice.h"
7
8#ifndef ICEBOX_API
9# if defined(ICEBOX_API_EXPORTS)
10# define ICEBOX_API ICE_DECLSPEC_EXPORT
11# else
12# define ICEBOX_API ICE_DECLSPEC_IMPORT
13# endif
14#endif
15
16namespace IceBox
17{
18 /// The exception that is thrown when an IceBox service fails to start.
19 /// @remark You can throw any exception from your implementation of Service::start. This exception is provided for
20 /// backward compatibility with earlier versions of IceBox.
21 /// @headerfile IceBox/IceBox.h
22 class ICEBOX_API FailureException final : public Ice::LocalException
23 {
24 public:
26
27 [[nodiscard]] const char* ice_id() const noexcept final;
28 };
29
30 /// Represents an IceBox service that you implement and that the IceBox service manager starts and later stops.
31 /// The same service can be started and stopped multiple times.
32 /// @headerfile IceBox/IceBox.h
33 class ICEBOX_API Service
34 {
35 public:
36 virtual ~Service();
37
38 /// Starts the service.
39 /// @param name The service's name, as specified in configuration.
40 /// @param communicator A communicator for use by the service. The IceBox service manager creates this
41 /// communicator when it starts, and destroys this communicator when it shuts down.
42 /// @param args The service arguments that were not converted into properties of @p communicator.
43 virtual void
44 start(const std::string& name, const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args) = 0;
45
46 /// Stops the service.
47 virtual void stop() = 0;
48 };
49
50 /// A shared pointer to a Service.
51 using ServicePtr = std::shared_ptr<Service>;
52}
53
54#endif
const char * ice_id() const noexcept final
Returns the type ID of this exception.
The exception that is thrown when an IceBox service fails to start.
Definition Service.h:23
virtual void start(const std::string &name, const Ice::CommunicatorPtr &communicator, const Ice::StringSeq &args)=0
Starts the service.
virtual void stop()=0
Stops the service.
Represents an IceBox service that you implement and that the IceBox service manager starts and later ...
Definition Service.h:34
LocalException(const char *file, int line, std::string message)
Constructs a local exception.
Base class for all Ice exceptions not defined in Slice.
std::shared_ptr< Service > ServicePtr
A shared pointer to a Service.
Definition Service.h:51
Host multiple independent services in the same Ice server.
std::shared_ptr< Communicator > CommunicatorPtr
A shared pointer to a Communicator.
std::vector< std::string > StringSeq
A sequence of strings.