MySQL 8.0.40
Source Code Documentation
mysql_registry_imp Class Reference

#include <registry_imp.h>

Static Public Member Functions

static void init ()
 Initializes registry for usage. More...
 
static void deinit ()
 De-initializes registry. More...
 
static void rw_lock_deinit ()
 De-initializes RW lock. More...
 
static minimal_chassis::rwlock_scoped_lock lock_registry_for_write ()
 Locks whole registry for write. More...
 
static uint64_t get_service_implementation_reference_count (my_h_service interface)
 Gets current reference count for a Service Implementation related to the specified pointer to the interface structure. More...
 
static bool acquire_nolock (const char *service_name, my_h_service *out_service)
 Finds and acquires a Service by name. More...
 
static bool release_nolock (my_h_service service)
 Releases the Service Implementation previously acquired. More...
 
static bool register_service_nolock (const char *service_implementation_name, my_h_service ptr)
 Registers a new Service Implementation. More...
 
static bool unregister_nolock (const char *service_implementation_name)
 Removes previously registered Service Implementation from registry. More...
 
static mysql_service_status_t acquire (const char *service_name, my_h_service *out_service) noexcept
 Finds and acquires a Service by name. More...
 
static mysql_service_status_t acquire_related (const char *service_name, my_h_service service, my_h_service *out_service) noexcept
 Finds a Service by name. More...
 
static mysql_service_status_t release (my_h_service service) noexcept
 Releases the Service Implementation previously acquired. More...
 
static mysql_service_status_t register_service (const char *service_implementation_name, my_h_service ptr) noexcept
 Registers a new Service Implementation. More...
 
static mysql_service_status_t unregister (const char *service_implementation_name) noexcept
 Removes previously registered Service Implementation from registry. More...
 
static mysql_service_status_t set_default (const char *service_implementation_name) noexcept
 Sets new default Service Implementation for corresponding Service name. More...
 
static mysql_service_status_t iterator_create (const char *service_name_pattern, my_h_service_iterator *out_iterator) noexcept
 Creates iterator that iterates through all registered Service Implementations. More...
 
static void iterator_release (my_h_service_iterator iterator) noexcept
 Releases Service implementations iterator. More...
 
static mysql_service_status_t iterator_get (my_h_service_iterator iterator, const char **out_name) noexcept
 Gets name of Service pointed to by iterator. More...
 
static mysql_service_status_t iterator_next (my_h_service_iterator iterator) noexcept
 Advances specified iterator to next element. More...
 
static mysql_service_status_t iterator_is_valid (my_h_service_iterator iterator) noexcept
 Checks if specified iterator is valid, i.e. More...
 

Private Types

typedef std::map< my_h_service, mysql_service_implementation * > my_interface_mapping
 

Static Private Member Functions

static mysql_service_implementationget_service_implementation_by_interface (my_h_service interface)
 Finds a Service Implementation data structure based on the pointer to interface struct supplied. More...
 

Static Private Attributes

static my_service_registry service_registry
 
static my_interface_mapping interface_mapping
 
static mysql_rwlock_t LOCK_registry
 

Member Typedef Documentation

◆ my_interface_mapping

Member Function Documentation

◆ acquire()

mysql_service_status_t mysql_registry_imp::acquire ( const char *  service_name,
my_h_service out_service 
)
staticnoexcept

Finds and acquires a Service by name.

A name of the Service or the Service Implementation can be specified. In case of the Service name, the default Service Implementation for Service specified will be returned.

Parameters
service_nameName of Service or Service Implementation to acquire.
[out]out_servicePointer to Service handle to set acquired Service.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ acquire_nolock()

bool mysql_registry_imp::acquire_nolock ( const char *  service_name,
my_h_service out_service 
)
static

Finds and acquires a Service by name.

A name of the Service or the Service Implementation can be specified. In case of the Service name, the default Service Implementation for Service specified will be returned. Assumes caller has at least a read lock on the Registry.

Parameters
service_nameName of Service or Service Implementation to acquire.
[out]out_servicePointer to Service handle to set acquired Service.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ acquire_related()

mysql_service_status_t mysql_registry_imp::acquire_related ( const char *  service_name,
my_h_service  service,
my_h_service out_service 
)
staticnoexcept

Finds a Service by name.

If there is a Service Implementation with the same Component part of name as the input Service then the found Service is returned.

Parameters
service_nameName of Service or Service Implementation to acquire.
serviceService handle already acquired Service Implementation.
[out]out_servicePointer to Service Implementation handle to set acquired Service Implementation.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ deinit()

void mysql_registry_imp::deinit ( )
static

De-initializes registry.

De-initializes RW lock, all other structures are cleaned up.

◆ get_service_implementation_by_interface()

mysql_service_implementation * mysql_registry_imp::get_service_implementation_by_interface ( my_h_service  interface)
staticprivate

Finds a Service Implementation data structure based on the pointer to interface struct supplied.

Assumes caller has at least a read lock on the Registry.

Parameters
interfaceA pointer to the interface structure of the Service Implementation to look for.
Returns
A pointer to respective Service Implementation data structure, or NULL if no such interface pointer is registered within the Registry.

◆ get_service_implementation_reference_count()

uint64_t mysql_registry_imp::get_service_implementation_reference_count ( my_h_service  interface)
static

Gets current reference count for a Service Implementation related to the specified pointer to the interface structure.

Assumes caller has at least a read lock on the Registry.

Parameters
interfaceA pointer to the interface structure of the Service Implementation to get reference count of.
Returns
A current reference count for specified Service Implementation. Returns 0 in case there is no such interface or it is not referenced.

◆ init()

void mysql_registry_imp::init ( )
static

Initializes registry for usage.

Initializes RW lock, all other structures should be empty. Shouldn't be called multiple times.

◆ iterator_create()

mysql_service_status_t mysql_registry_imp::iterator_create ( const char *  service_name_pattern,
my_h_service_iterator out_iterator 
)
staticnoexcept

Creates iterator that iterates through all registered Service Implementations.

If successful it leaves read lock on the Registry until iterator is released. The starting point of iteration may be specified to be on one particular Service Implementation. The iterator will move through all Service Implementations and additionally through all default Service Implementation additionally, i.e. the default Service Implementation will be returned twice. If no name is specified for search, iterator will be positioned on the first Service Implementation.

Parameters
service_name_patternName of Service or Service Implementation to start iteration from. May be empty string or NULL pointer, in which case iteration starts from the first Service Implementation.
[out]out_iteratorPointer to the Service Implementation iterator handle.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ iterator_get()

mysql_service_status_t mysql_registry_imp::iterator_get ( my_h_service_iterator  iterator,
const char **  out_name 
)
staticnoexcept

Gets name of Service pointed to by iterator.

The pointer returned will last at least up to the moment of call to the release() method on the iterator.

Parameters
iteratorService Implementation iterator handle.
[out]out_namePointer to string with name to set result pointer to.
Returns
Status of performed operation
Return values
falsesuccess
trueFailure, may be caused when called on iterator that went through all values already.

◆ iterator_is_valid()

mysql_service_status_t mysql_registry_imp::iterator_is_valid ( my_h_service_iterator  iterator)
staticnoexcept

Checks if specified iterator is valid, i.e.

have not reached one-past-last element.

Parameters
iteratorService Implementation iterator handle.
Returns
Validity of iterator
Return values
falseValid
trueInvalid or reached one-past-last element.

◆ iterator_next()

mysql_service_status_t mysql_registry_imp::iterator_next ( my_h_service_iterator  iterator)
staticnoexcept

Advances specified iterator to next element.

Will succeed but return true if it reaches one-past-last element.

Parameters
iteratorService Implementation iterator handle.
Returns
Status of performed operation and validity of iterator after operation.
Return values
falsesuccess
trueFailure or called on iterator that was on last element.

◆ iterator_release()

void mysql_registry_imp::iterator_release ( my_h_service_iterator  iterator)
staticnoexcept

Releases Service implementations iterator.

Releases read lock on registry.

Parameters
iteratorService Implementation iterator handle.

◆ lock_registry_for_write()

minimal_chassis::rwlock_scoped_lock mysql_registry_imp::lock_registry_for_write ( )
static

Locks whole registry for write.

For internal use only.

Returns
A lock acquired wrapped into RAII object.

◆ register_service()

mysql_service_status_t mysql_registry_imp::register_service ( const char *  service_implementation_name,
my_h_service  ptr 
)
staticnoexcept

Registers a new Service Implementation.

If it is the first Service Implementation for the specified Service then it is made a default one.

Parameters
service_implementation_nameName of the Service Implementation to register.
ptrPointer to the Service Implementation structure.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ register_service_nolock()

bool mysql_registry_imp::register_service_nolock ( const char *  service_implementation_name,
my_h_service  ptr 
)
static

Registers a new Service Implementation.

If it is the first Service Implementation for the specified Service then it is made a default one. Assumes caller has a write lock on the Registry.

Parameters
service_implementation_nameName of the Service Implementation to register.
ptrPointer to the Service Implementation structure.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ release()

mysql_service_status_t mysql_registry_imp::release ( my_h_service  service)
staticnoexcept

Releases the Service Implementation previously acquired.

After the call to this method the usage of the Service Implementation handle will lead to unpredicted results.

Parameters
serviceService Implementation handle of already acquired Service.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ release_nolock()

bool mysql_registry_imp::release_nolock ( my_h_service  service)
static

Releases the Service Implementation previously acquired.

After the call to this method the usage of the Service Implementation handle will lead to unpredicted results. Assumes caller has at least a read lock on the Registry.

Parameters
serviceService Implementation handle of already acquired Service.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ rw_lock_deinit()

void mysql_registry_imp::rw_lock_deinit ( )
static

De-initializes RW lock.

◆ set_default()

mysql_service_status_t mysql_registry_imp::set_default ( const char *  service_implementation_name)
staticnoexcept

Sets new default Service Implementation for corresponding Service name.

Parameters
service_implementation_nameName of the Service Implementation to set as default one.
Returns
Status of performed operation
Return values
falsesuccess
truefailure

◆ unregister()

mysql_service_status_t mysql_registry_imp::unregister ( const char *  service_implementation_name)
staticnoexcept

Removes previously registered Service Implementation from registry.

If it is the default one for specified Service then any one still registered is made default. If there is no other, the default entry is removed from the Registry too.

Parameters
service_implementation_nameName of the Service Implementation to unregister.
Returns
Status of performed operation
Return values
falsesuccess
trueFailure. May happen when Service is still being referenced.

◆ unregister_nolock()

bool mysql_registry_imp::unregister_nolock ( const char *  service_implementation_name)
static

Removes previously registered Service Implementation from registry.

If it is the default one for specified Service then any one still registered is made default. If there is no other, the default entry is removed from the Registry too. Assumes caller has a write lock on the Registry.

Parameters
service_implementation_nameName of the Service Implementation to unregister.
Returns
Status of performed operation
Return values
falsesuccess
trueFailure. May happen when Service is still being referenced.

Member Data Documentation

◆ interface_mapping

mysql_registry_imp::my_interface_mapping mysql_registry_imp::interface_mapping
staticprivate

◆ LOCK_registry

mysql_rwlock_t mysql_registry_imp::LOCK_registry
staticprivate

◆ service_registry

my_service_registry mysql_registry_imp::service_registry
staticprivate

The documentation for this class was generated from the following files: