CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
25 #include <unordered_map>
28 namespace catapult {
namespace crypto {
class KeyPair; } }
30 namespace catapult {
namespace extensions {
63 const std::vector<utils::DiagnosticCounter>&
counters()
const {
73 template<
typename TService>
74 std::shared_ptr<TService>
service(
const std::string& serviceName)
const {
75 std::shared_ptr<TService> pService;
84 void registerService(
const std::string& serviceName,
const std::shared_ptr<void>& pService) {
85 if (!
m_services.emplace(serviceName, pService).second)
96 template<
typename TService,
typename TSupplier>
99 std::shared_ptr<TService> pService;
106 template<
typename TService>
107 bool tryGetService(
const std::string& serviceName, std::shared_ptr<TService>& pService)
const {
112 auto pVoidService = iter->second.lock();
113 pService = std::shared_ptr<TService>(pVoidService, reinterpret_cast<TService*>(pVoidService.get()));
120 std::unordered_map<std::string, std::weak_ptr<void>>
m_services;
const crypto::KeyPair & m_keyPair
Definition: ServiceLocator.h:118
std::unordered_map< std::string, std::weak_ptr< void > > m_services
Definition: ServiceLocator.h:120
A diagnostic counter id.
Definition: DiagnosticCounterId.h:27
#define CATAPULT_LOG(SEV)
Writes a log entry to the default logger with SEV severity.
Definition: Logging.h:340
bool tryGetService(const std::string &serviceName, std::shared_ptr< TService > &pService) const
Definition: ServiceLocator.h:107
def debug(*args)
Definition: Parser.py:46
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.
Definition: ServiceLocator.h:90
std::vector< utils::DiagnosticCounter > m_counters
Definition: ServiceLocator.h:119
std::shared_ptr< TService > service(const std::string &serviceName) const
Gets the service with serviceName.
Definition: ServiceLocator.h:74
std::function< T()> supplier
A (stateless) supplier function.
Definition: functions.h:39
const std::vector< utils::DiagnosticCounter > & counters() const
Gets the diagnostic counters.
Definition: ServiceLocator.h:63
static constexpr uint64_t Sentinel_Counter_Value
Value that is returned when a statistics source is nullptr.
Definition: ServiceLocator.h:36
~ServiceLocator()
Destroys the locator.
Definition: ServiceLocator.h:44
Represents a pair of private key with associated public key.
Definition: KeyPair.h:33
def info(*args)
Definition: forwardsValidation.py:12
#define CATAPULT_THROW_INVALID_ARGUMENT_1(MESSAGE, PARAM1)
Macro used to throw a catapult invalid argument with a single parameter.
Definition: exceptions.h:183
void registerService(const std::string &serviceName, const std::shared_ptr< void > &pService)
Adds a service (pService) with serviceName.
Definition: ServiceLocator.h:84
std::vector< std::pair< std::string, std::shared_ptr< void > > > m_rootedServices
Definition: ServiceLocator.h:121
size_t numServices() const
Gets the number of registered services.
Definition: ServiceLocator.h:68
ServiceLocator(const crypto::KeyPair &keyPair)
Creates a locator around keyPair.
Definition: ServiceLocator.h:40
Definition: AddressExtractionExtension.cpp:28
void registerServiceCounter(const std::string &serviceName, const std::string &counterName, TSupplier supplier)
Adds a service-dependent counter with counterName for service serviceName given supplier.
Definition: ServiceLocator.h:97
const crypto::KeyPair & keyPair() const
Gets the local key pair.
Definition: ServiceLocator.h:58
A service locator for local node services.
Definition: ServiceLocator.h:33