29class ServiceRegistry {
77 return registerTypedService(type, service);
87 return static_cast<T*
>(getTypedService(type));
119 size_t count()
const {
return count_; }
127 bool registerTypedService(
ServiceType type,
void* service);
139 static constexpr size_t MAX_TYPED_SERVICES = 8;
140 void* typedServices_[MAX_TYPED_SERVICES] = {};
144#define CDC_SERVICE(type, name) \
145 cdc::core::ServiceRegistry::instance().get<type>(name)
147#define CDC_PROVIDE_SERVICE(type, ptr) \
148 cdc::core::ServiceRegistry::instance().provide<decltype(*(ptr))>(type, ptr)
150#define CDC_REQUEST_SERVICE(type, T) \
151 cdc::core::ServiceRegistry::instance().request<T>(type)
char name[cdc::hal::ISecureElement::RMEM_NAME_LEN]
bool provide(ServiceType type, T *service)
bool startAll()
Starts all initialized services.
void stopAll()
Stops started services in reverse registration order.
T * get(const char *name)
static ServiceRegistry & instance()
Returns singleton service registry instance.
bool registerService(const char *name, IService *service)
Registers a named service instance.
bool isAvailable(ServiceType type) const
Checks whether typed service exists.
T * request(ServiceType type)
IService * getService(const char *name)
Looks up a service by name.
bool initAll()
Initializes all registered services in registration order.
static constexpr size_t MAX_SERVICES