Skip to content

Class endstone::ServiceManager

ClassList > endstone > ServiceManager

Represent a service manager that manages services and service providers. More...

  • #include <endstone/plugin/service_manager.h>

Public Functions

Type Name
virtual std::shared_ptr< Service > get (std::string name) const = 0
Queries for a provider.
std::shared_ptr< T > load (std::string name) const
Queries for a provider and casts it to the requested service type.
virtual void registerService (std::string name, std::shared_ptr< Service > provider, const Plugin & plugin, ServicePriority priority) = 0
Register a provider of a service.
virtual void unregister (std::string name, const Service & provider) = 0
Unregister a particular provider for a particular service.
virtual void unregister (const Service & provider) = 0
Unregister a particular provider.
virtual void unregisterAll (const Plugin & plugin) = 0
Unregister all the services registered by a particular plugin.
virtual ~ServiceManager () = default

Detailed Description

Services are an interface specifying a list of methods that a provider must implement. Providers are implementations of these services.

Public Functions Documentation

function get

Queries for a provider.

virtual std::shared_ptr< Service > endstone::ServiceManager::get (
    std::string name
) const = 0

This may return an empty shared_ptr if no provider has been registered for the service. The highest priority provider is returned.

Parameters:

  • name The service name

Returns:

The highest priority provider, or an empty shared_ptr if none is registered.


function load

Queries for a provider and casts it to the requested service type.

template<typename  T>
inline std::shared_ptr< T > endstone::ServiceManager::load (
    std::string name
) const

The highest priority provider is returned.

Template parameters:

  • T The service type to cast the provider to

Parameters:

  • name The service name

Returns:

The highest priority provider cast to T, or an empty shared_ptr if none is registered.


function registerService

Register a provider of a service.

virtual void endstone::ServiceManager::registerService (
    std::string name,
    std::shared_ptr< Service > provider,
    const  Plugin & plugin,
    ServicePriority priority
) = 0

Parameters:

  • name service name
  • provider service provider to register
  • plugin plugin associated with the service
  • priority priority of the provider

function unregister [½]

Unregister a particular provider for a particular service.

virtual void endstone::ServiceManager::unregister (
    std::string name,
    const  Service & provider
) = 0

Parameters:

  • name The service name
  • provider The service provider implementation

function unregister [2/2]

Unregister a particular provider.

virtual void endstone::ServiceManager::unregister (
    const  Service & provider
) = 0

Parameters:

  • provider The service provider implementation

function unregisterAll

Unregister all the services registered by a particular plugin.

virtual void endstone::ServiceManager::unregisterAll (
    const  Plugin & plugin
) = 0

Parameters:

  • plugin The plugin

function ~ServiceManager

virtual endstone::ServiceManager::~ServiceManager () = default


The documentation for this class was generated from the following file include/endstone/plugin/service_manager.h