CatapultServer  v0.5.0.1 (Elephant)
catapult::extensions::ServiceLocator Class Reference

A service locator for local node services. More...

Collaboration diagram for catapult::extensions::ServiceLocator:

Public Member Functions

 ServiceLocator (const crypto::KeyPair &keyPair)
 Creates a locator around keyPair. More...
 
 ~ServiceLocator ()
 Destroys the locator. More...
 
const crypto::KeyPairkeyPair () const
 Gets the local key pair. More...
 
const std::vector< utils::DiagnosticCounter > & counters () const
 Gets the diagnostic counters. More...
 
size_t numServices () const
 Gets the number of registered services. More...
 
template<typename TService >
std::shared_ptr< TService > service (const std::string &serviceName) const
 Gets the service with serviceName. More...
 
void registerService (const std::string &serviceName, const std::shared_ptr< void > &pService)
 Adds a service (pService) with serviceName. More...
 
void registerRootedService (const std::string &serviceName, const std::shared_ptr< void > &pService)
 Adds a rooted service (pService) with serviceName that is kept alive by the service locator. More...
 
template<typename TService , typename TSupplier >
void registerServiceCounter (const std::string &serviceName, const std::string &counterName, TSupplier supplier)
 Adds a service-dependent counter with counterName for service serviceName given supplier. More...
 

Static Public Attributes

static constexpr uint64_t Sentinel_Counter_Value = static_cast<uint64_t>(-1)
 Value that is returned when a statistics source is nullptr. More...
 

Private Member Functions

template<typename TService >
bool tryGetService (const std::string &serviceName, std::shared_ptr< TService > &pService) const
 

Private Attributes

const crypto::KeyPairm_keyPair
 
std::vector< utils::DiagnosticCounterm_counters
 
std::unordered_map< std::string, std::weak_ptr< void > > m_services
 
std::vector< std::pair< std::string, std::shared_ptr< void > > > m_rootedServices
 

Detailed Description

A service locator for local node services.

Constructor & Destructor Documentation

◆ ServiceLocator()

catapult::extensions::ServiceLocator::ServiceLocator ( const crypto::KeyPair keyPair)
inlineexplicit

Creates a locator around keyPair.

◆ ~ServiceLocator()

catapult::extensions::ServiceLocator::~ServiceLocator ( )
inline

Destroys the locator.

Here is the call graph for this function:

Member Function Documentation

◆ counters()

const std::vector<utils::DiagnosticCounter>& catapult::extensions::ServiceLocator::counters ( ) const
inline

Gets the diagnostic counters.

◆ keyPair()

const crypto::KeyPair& catapult::extensions::ServiceLocator::keyPair ( ) const
inline

Gets the local key pair.

◆ numServices()

size_t catapult::extensions::ServiceLocator::numServices ( ) const
inline

Gets the number of registered services.

◆ registerRootedService()

void catapult::extensions::ServiceLocator::registerRootedService ( const std::string &  serviceName,
const std::shared_ptr< void > &  pService 
)
inline

Adds a rooted service (pService) with serviceName that is kept alive by the service locator.

Here is the call graph for this function:

◆ registerService()

void catapult::extensions::ServiceLocator::registerService ( const std::string &  serviceName,
const std::shared_ptr< void > &  pService 
)
inline

Adds a service (pService) with serviceName.

Here is the caller graph for this function:

◆ registerServiceCounter()

template<typename TService , typename TSupplier >
void catapult::extensions::ServiceLocator::registerServiceCounter ( const std::string &  serviceName,
const std::string &  counterName,
TSupplier  supplier 
)
inline

Adds a service-dependent counter with counterName for service serviceName given supplier.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ service()

template<typename TService >
std::shared_ptr<TService> catapult::extensions::ServiceLocator::service ( const std::string &  serviceName) const
inline

Gets the service with serviceName.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryGetService()

template<typename TService >
bool catapult::extensions::ServiceLocator::tryGetService ( const std::string &  serviceName,
std::shared_ptr< TService > &  pService 
) const
inlineprivate
Here is the caller graph for this function:

Member Data Documentation

◆ m_counters

std::vector<utils::DiagnosticCounter> catapult::extensions::ServiceLocator::m_counters
private

◆ m_keyPair

const crypto::KeyPair& catapult::extensions::ServiceLocator::m_keyPair
private

◆ m_rootedServices

std::vector<std::pair<std::string, std::shared_ptr<void> > > catapult::extensions::ServiceLocator::m_rootedServices
private

◆ m_services

std::unordered_map<std::string, std::weak_ptr<void> > catapult::extensions::ServiceLocator::m_services
private

◆ Sentinel_Counter_Value

constexpr uint64_t catapult::extensions::ServiceLocator::Sentinel_Counter_Value = static_cast<uint64_t>(-1)
staticconstexpr

Value that is returned when a statistics source is nullptr.


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