hololink::module::ServicePublisher
hololink::module::ServicePublisher
Publishes service implementations into a Publisher, making them available to lookups.
Use it from a Publisher’s own code: either to publish services eagerly (for example in Publisher::setup()) or from Publisher::construct_service() to publish the service that was just asked for.
Publishing does two things. It records the implementation in the Publisher, which keeps it alive and returns it from later lookups until Publisher::invalidate() discards it. And it makes the Publisher’s self_module() the service’s owning Module (see ServiceBase::module()), so that the service’s accessors for related services, such as a device’s get_i2c, look them up in the same binary the service was published from.
Template parameters
The service class to publish. It must declare or inherit a release_version.
Constructors
ServicePublisher
Parameters
The Publisher to publish into.
Methods
publish
Overload 1
Publish a service under one type id
Publish a service under every type id that T provides.
A service that can be used as several interfaces is made available under the type id of each, so that a lookup for any of them returns this object.
Throws: std::runtime_error if any of the (instance id, type id) pairs is already published. Pairs published before the collision was found remain published.
Parameters
Instance id to publish under; lookups must use the same value.
The service. Must not be null.