The Pedigree Project 0.1
Classes | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
ServiceManager Class Reference

#include <ServiceManager.h>

+ Collaboration diagram for ServiceManager:

Classes

class  InternalService
 

Public Member Functions

ServiceFeatures * enumerateOperations (const String &serviceName)
 
void addService (const String &serviceName, Service *s, ServiceFeatures *feats)
 
void removeService (const String &serviceName)
 
Service * getService (const String &serviceName)
 
bool tryGetService (const String &serviceName, Service *&service, ServiceFeatures *&features)
 
bool serve (const String &serviceName, ServiceFeatures::Type type, void *data, size_t dataLen)
 

Static Public Member Functions

static ServiceManager & instance ()
 

Private Attributes

Mutex m_Lock
 
RadixTree< InternalService * > m_Services
 

Static Private Attributes

static ServiceManager m_Instance
 

Detailed Description

Todo:
Integrate with the Event system somehow

Service Manager

The service manager controls Services in a central location, by allowing them to be referred to by name.

It also provides services such as enumeration of Service operations.

Definition at line 41 of file ServiceManager.h.

Constructor & Destructor Documentation

◆ ServiceManager()

ServiceManager::ServiceManager ( )

Definition at line 30 of file ServiceManager.cc.

◆ ~ServiceManager()

ServiceManager::~ServiceManager ( )
virtual

Definition at line 32 of file ServiceManager.cc.

Member Function Documentation

◆ addService()

void ServiceManager::addService ( const String &  serviceName,
Service *  s,
ServiceFeatures *  feats 
)

◆ enumerateOperations()

ServiceFeatures * ServiceManager::enumerateOperations ( const String &  serviceName)

Enumerates all possible operations that can be performed for a given Service. The caller must externally pin the service lifetime.

Definition at line 48 of file ServiceManager.cc.

References m_Lock.

Referenced by ScsiDisk::initialise().

+ Here is the caller graph for this function:

◆ getService()

Service * ServiceManager::getService ( const String &  serviceName)

Gets a Service pointer whose lifetime the caller must externally pin.

Definition at line 100 of file ServiceManager.cc.

References m_Lock.

Referenced by ScsiDisk::initialise(), and UsbDeviceContainer::replaceUsbDevice().

+ Here is the caller graph for this function:

◆ instance()

static ServiceManager & ServiceManager::instance ( )
inlinestatic

Definition at line 46 of file ServiceManager.h.

◆ removeService()

void ServiceManager::removeService ( const String &  serviceName)

Removes a service and drains admitted calls before its owner deletes it. A service callback must not remove or replace its own registration.

Definition at line 84 of file ServiceManager.cc.

References OperationBarrier::close(), m_Lock, and OperationBarrier::wait().

◆ serve()

bool ServiceManager::serve ( const String &  serviceName,
ServiceFeatures::Type  type,
void *  data,
size_t  dataLen 
)

Invokes a supported operation while retaining the registered service.

Definition at line 127 of file ServiceManager.cc.

References m_Lock, ServiceFeatures::provides(), and Service::serve().

Referenced by UsbDeviceContainer::replaceUsbDevice().

+ Here is the caller graph for this function:

◆ tryGetService()

bool ServiceManager::tryGetService ( const String &  serviceName,
Service *&  service,
ServiceFeatures *&  features 
)

Nonblocking lookup for diagnostics. Returned objects require an external lifetime guarantee; unavailable or contended lookup resets both outputs.

Definition at line 110 of file ServiceManager.cc.

References ProcessorBase::getInterrupts(), m_Lock, Semaphore::release(), and Semaphore::tryAcquire().

Member Data Documentation

◆ m_Instance

ServiceManager ServiceManager::m_Instance
staticprivate

Definition at line 76 of file ServiceManager.h.

◆ m_Lock

Mutex ServiceManager::m_Lock
private

Services we know about

Definition at line 91 of file ServiceManager.h.

Referenced by addService(), enumerateOperations(), getService(), removeService(), serve(), and tryGetService().

◆ m_Services

RadixTree<InternalService*> ServiceManager::m_Services
private

Definition at line 92 of file ServiceManager.h.


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