class OutgoingDirectory
Defined at line 57 of file ../../sdk/lib/sys/cpp/outgoing_directory.h
The directory provided by this component to the component manager.
A component's outgoing directory contains services, data, and other objects
that can be consumed by either the component manager itself or by other
components in the system.
The outgoing directory contains several subdirectories with well-known
names:
* svc. This directory contains the services offered by this component to
other components.
* debug. This directory contains arbitrary debugging output offered by this
component.
The outgoing directory may optionally contain other directories constructed
using |GetOrCreateDirectory|. Common optional directories include:
* objects. This directory contains Inspect API files and interfaces for use
in component inspection.
This class is thread-hostile.
# Simple usage
Instances of this class should be owned and managed on the same thread
that services their connections.
# Advanced usage
You can use a background thread to service connections provided:
async_dispatcher_t for the background thread is stopped or suspended
prior to destroying the class object.
Public Methods
void OutgoingDirectory ()
Defined at line 37 of file ../../sdk/lib/sys/cpp/outgoing_directory.cc
void ~OutgoingDirectory ()
Defined at line 42 of file ../../sdk/lib/sys/cpp/outgoing_directory.cc
void OutgoingDirectory (OutgoingDirectory && )
Defined at line 44 of file ../../sdk/lib/sys/cpp/outgoing_directory.cc
OutgoingDirectory & operator= (OutgoingDirectory && )
Defined at line 50 of file ../../sdk/lib/sys/cpp/outgoing_directory.cc
zx_status_t Serve (fidl::InterfaceRequest<fuchsia::io::Directory> directory_request, async_dispatcher_t * dispatcher)
Starts serving the outgoing directory on the given channel.
This object will implement the |fuchsia.io.Directory| interface using this
channel.
If |dispatcher| is NULL, this object will serve the outgoing directory
using the |async_dispatcher_t| from |async_get_default_dispatcher()|.
# Errors
ZX_ERR_BAD_HANDLE: |directory_request| is not a valid handle.
ZX_ERR_ACCESS_DENIED: |directory_request| has insufficient rights.
TODO: Document more errors.
Defined at line 60 of file ../../sdk/lib/sys/cpp/outgoing_directory.cc
void OutgoingDirectory (const OutgoingDirectory & )
Outgoing objects cannot be copied.
Defined at line 66 of file ../../sdk/lib/sys/cpp/outgoing_directory.h
OutgoingDirectory & operator= (const OutgoingDirectory & )
Defined at line 67 of file ../../sdk/lib/sys/cpp/outgoing_directory.h
zx_status_t ServeFromStartupInfo (async_dispatcher_t * dispatcher)
Starts serving the outgoing directory on the channel provided to this
process at startup as |PA_DIRECTORY_REQUEST|.
This object will implement the |fuchsia.io.Directory| interface using this
channel.
If |dispatcher| is NULL, this object will serve the outgoing directory
using the |async_dispatcher_t| from |async_get_default_dispatcher()|.
# Errors
ZX_ERR_BAD_HANDLE: the process did not receive a |PA_DIRECTORY_REQUEST|
startup handle or it was already taken.
ZX_ERR_ACCESS_DENIED: |directory_request| has insufficient rights.
TODO: Document more errors.
Defined at line 71 of file ../../sdk/lib/sys/cpp/outgoing_directory.cc
zx_status_t AddPublicService (std::unique_ptr<vfs::Service> service, std::string service_name)
Adds the specified service to the set of public services.
Adds a supported service with the given |service_name|, using the given
|service|.
# Errors
ZX_ERR_ALREADY_EXISTS: The public directory already contains an entry for
this service.
Defined at line 81 of file ../../sdk/lib/sys/cpp/outgoing_directory.cc
zx_status_t AddNamedService (ServiceHandler handler, std::string service, std::string instance)
Adds an instance of a service.
A |handler| is added to provide an |instance| of a |service|.
# Errors
ZX_ERR_ALREADY_EXISTS: The instance already exists.
Defined at line 96 of file ../../sdk/lib/sys/cpp/outgoing_directory.cc
zx_status_t RemoveNamedService (const std::string & service, const std::string & instance)
Removes an instance of a service.
# Errors
ZX_ERR_NOT_FOUND: The instance was not found.
Defined at line 102 of file ../../sdk/lib/sys/cpp/outgoing_directory.cc
vfs::PseudoDir * GetOrCreateDirectory (const std::string & name)
Gets a subdirectory with the given |name|, creates it if it does not
already exist.
The returned directory is owned by this class.
Defined at line 77 of file ../../sdk/lib/sys/cpp/outgoing_directory.cc
template <typename Interface>
zx_status_t AddPublicService (fidl::InterfaceRequestHandler<Interface> handler, std::string service_name)
Adds the specified interface to the set of public interfaces.
Adds a supported service with the given |service_name|, using the given
|interface_request_handler|. |interface_request_handler| should
remain valid for the lifetime of this object.
# Errors
ZX_ERR_ALREADY_EXISTS: The public directory already contains an entry for
this service.
# Example
```
fidl::BindingSet
<fuchsia
::foo::Controller> bindings;
outgoing.AddPublicService(bindings.GetHandler(this));
```
Defined at line 123 of file ../../sdk/lib/sys/cpp/outgoing_directory.h
template <typename Interface>
zx_status_t RemovePublicService (const std::string & name)
Removes the specified interface from the set of public interfaces.
# Errors
ZX_ERR_NOT_FOUND: The public directory does not contain an entry for this
service.
# Example
```
outgoing.RemovePublicService
<fuchsia
::foo::Controller>();
```
Defined at line 157 of file ../../sdk/lib/sys/cpp/outgoing_directory.h
template <typename Protocol>
zx_status_t AddProtocol (fidl::ProtocolHandler<Protocol> handler, std::string name)
Publishes the specified protocol to the set of outgoing capabilities.
Adds a protocol with the given |name|, using the given |handler|.
|handler| should remain valid for the lifetime of this object.
# Errors
ZX_ERR_ALREADY_EXISTS: The outgoing directory already contains an entry for
this protocol.
# Example
```
fidl::ServerBindingGroup
<fuchsia
_foo::Controller> bindings;
outgoing.AddPublicProtocol(bindings.CreateHandler(this, dispatcher, on_closed));
```
Defined at line 178 of file ../../sdk/lib/sys/cpp/outgoing_directory.h
template <typename Protocol>
zx_status_t RemoveProtocol (const std::string & name)
Removes the specified protocol from the set of outgoing capabilities.
# Errors
ZX_ERR_NOT_FOUND: The outgoing directory does not contain an entry for this
protocol.
# Example
```
outgoing.RemoveProtocol
<fuchsia
_foo::Controller>();
```
Defined at line 200 of file ../../sdk/lib/sys/cpp/outgoing_directory.h
template <typename Service>
zx_status_t AddService (ServiceHandler handler, std::string instance)
Adds an instance of a service.
A |handler| is added to provide an |instance| of a service.
# Errors
ZX_ERR_ALREADY_EXISTS: The instance already exists.
# Example
```
ServiceHandler handler;
handler.AddMember("my-member", ...);
outgoing.AddService
<MyService
>(std::move(handler), "my-instance");
```
Defined at line 221 of file ../../sdk/lib/sys/cpp/outgoing_directory.h
template <typename Service>
zx_status_t RemoveService (const std::string & instance)
Removes an instance of a service.
# Errors
ZX_ERR_NOT_FOUND: The instance was not found.
# Example
```
outgoing.RemoveService
<MyService
>("my-instance");
```
Defined at line 247 of file ../../sdk/lib/sys/cpp/outgoing_directory.h
vfs::PseudoDir * root_dir ()
Gets the root directory.
The returned directory is owned by this class.
Defined at line 261 of file ../../sdk/lib/sys/cpp/outgoing_directory.h
vfs::PseudoDir * debug_dir ()
Gets the directory to publish debug data.
The returned directory is owned by this class.
Defined at line 266 of file ../../sdk/lib/sys/cpp/outgoing_directory.h