Ice 3.8
C++ API Reference
Loading...
Searching...
No Matches
Plugin.h
1// Copyright (c) ZeroC, Inc.
2
3#ifndef ICE_PLUGIN_H
4#define ICE_PLUGIN_H
5
6#include "Ice/BuiltinSequences.h"
7
8#include <memory>
9
10namespace Ice
11{
12 /// Represents a communicator plug-in. A plug-in generally adds a feature to a communicator, such as support for an
13 /// additional transport.
14 /// The communicator loads its plug-ins in two stages: the first stage creates the plug-ins, and the second stage
15 /// calls Plugin::initialize on each one.
16 /// @headerfile Ice/Ice.h
17 class ICE_API Plugin
18 {
19 public:
20 virtual ~Plugin();
21
22 /// Performs any necessary initialization steps.
23 virtual void initialize() = 0;
24
25 /// Destroys this plugin. This function is called when the communicator is destroyed.
26 virtual void destroy() = 0;
27 };
28
29 /// A shared pointer to a Plugin.
30 using PluginPtr = std::shared_ptr<Plugin>;
31
32 /// Manages the plug-ins of a communicator.
33 /// @headerfile Ice/Ice.h
34 class ICE_API PluginManager
35 {
36 public:
37 virtual ~PluginManager();
38
39 /// Initializes the configured plug-ins. The communicator automatically initializes the plug-ins by default, but
40 /// an application may need to interact directly with a plug-in prior to initialization. In this case, the
41 /// application must set `Ice.InitPlugins=0` and then invoke `initializePlugins` manually. The plug-ins are
42 /// initialized in the order in which they are loaded. If a plug-in throws an exception during initialization,
43 /// the communicator calls Plugin::destroy on the plug-ins that have already been initialized.
44 /// @throws InitializationException Thrown when the plug-ins have already been initialized.
45 virtual void initializePlugins() = 0;
46
47 /// Gets the installed plug-ins.
48 /// @return The names of the installed plug-ins.
49 /// @see #getPlugin
50 virtual StringSeq getPlugins() = 0;
51
52 /// Gets a plug-in by name.
53 /// @param name The plug-in's name.
54 /// @return The plug-in.
55 /// @throws NotRegisteredException Thrown when no plug-in is found with the given name.
56 virtual PluginPtr getPlugin(std::string_view name) = 0;
57
58 /// Installs a new plug-in.
59 /// @param name The plug-in's name.
60 /// @param pi The plug-in.
61 /// @throws AlreadyRegisteredException Thrown when a plug-in already exists with the given name.
62 virtual void addPlugin(std::string name, PluginPtr pi) = 0;
63
64 /// @private
65 /// Destroys this plug-in manager. Called when the communicator is being destroyed.
66 virtual void destroy() noexcept = 0;
67 };
68
69 /// A shared pointer to a PluginManager.
70 using PluginManagerPtr = std::shared_ptr<PluginManager>;
71}
72
73#endif
virtual StringSeq getPlugins()=0
Gets the installed plug-ins.
virtual void initializePlugins()=0
Initializes the configured plug-ins.
virtual void addPlugin(std::string name, PluginPtr pi)=0
Installs a new plug-in.
virtual PluginPtr getPlugin(std::string_view name)=0
Gets a plug-in by name.
Manages the plug-ins of a communicator.
Definition Plugin.h:35
virtual void destroy()=0
Destroys this plugin. This function is called when the communicator is destroyed.
virtual void initialize()=0
Performs any necessary initialization steps.
Represents a communicator plug-in.
Definition Plugin.h:18
std::shared_ptr< PluginManager > PluginManagerPtr
A shared pointer to a PluginManager.
Definition Plugin.h:70
std::shared_ptr< Plugin > PluginPtr
A shared pointer to a Plugin.
Definition Plugin.h:30
std::vector< std::string > StringSeq
A sequence of strings.
The Ice RPC framework.
Definition SampleEvent.h:59