template <typename Interface, typename ImplPtr = Interface*>

class BindingSet

Defined at line 30 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

Manages a set of bindings to implementations owned by the bound channels.

The implementation pointer type of the binding is also parameterized,

allowing the use of smart pointer types such as |std::unique_ptr

<

>| to

reference the implementation.

See also:

* |InterfacePtrSet|, which is the client analog of |BindingSet|.

Public Methods

void BindingSet<Interface, ImplPtr> ()

Defined at line 38 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

void BindingSet<Interface, ImplPtr> (const BindingSet<Interface, ImplPtr> & )

Defined at line 40 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

BindingSet<Interface, ImplPtr> & operator= (const BindingSet<Interface, ImplPtr> & )

Defined at line 41 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

void BindingSet<Interface, ImplPtr> (BindingSet<Interface, ImplPtr> && )

The implementation of this class provides external references to class members via pointers.

As a result, instances cannot be move-constructed or move-assigned.

Defined at line 45 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

BindingSet<Interface, ImplPtr> & operator= (BindingSet<Interface, ImplPtr> && )

Defined at line 46 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

void AddBinding (ImplPtr impl, InterfaceRequest<Interface> request, async_dispatcher_t * dispatcher, ErrorHandler handler)

Adds a binding to the set.

The given |ImplPtr| is bound to the channel underlying the

|InterfaceRequest|. The binding is removed (and the |~ImplPtr| called)

when the created binding has an error (e.g., if the remote endpoint of

the channel sends an invalid message). The binding can also be removed

by calling |RemoveBinding()|.

Whether this method takes ownership of |impl| depends on |ImplPtr|. If

|ImplPtr| is a raw pointer, then this method does not take ownership of

|impl|. If |ImplPtr| is a |unique_ptr|, then running |~ImplPtr| when the

binding generates an error will delete |impl| because |~ImplPtr| is

|~unique_ptr|, which deletes |impl|.

Defined at line 61 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

InterfaceHandle<Interface> AddBinding (ImplPtr impl, async_dispatcher_t * dispatcher, ErrorHandler handler)

Adds a binding to the set for the given implementation.

Creates a channel for the binding and returns the client endpoint of

the channel as an |InterfaceHandle|. If |AddBinding| fails to create the

underlying channel, the returned |InterfaceHandle| will return false from

|is_valid()|.

The given |ImplPtr| is bound to the newly created channel. The binding is

removed (and the |~ImplPtr| called) when the created binding has an error

(e.g., if the remote endpoint of the channel sends an invalid message).

Whether this method takes ownership of |impl| depends on |ImplPtr|. If

|ImplPtr| is a raw pointer, then this method does not take ownership of

|impl|. If |ImplPtr| is a |unique_ptr|, then running |~ImplPtr| when the

binding generates an error will delete |impl| because |~ImplPtr| is

|~unique_ptr|, which deletes |impl|.

Defined at line 105 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

template <class T>
bool RemoveBinding (const T & impl)

Removes a binding from the set.

Returns true iff the binding was successfully found and removed.

Upon removal, the server endpoint of the channel is closed without sending an epitaph.

Defined at line 120 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

template <class T>
bool CloseBinding (const T & impl, zx_status_t epitaph_value)

Removes a binding from the set.

Returns true iff the binding was successfully found and removed.

Upon removal, the server endpoint of the channel is closed and the epitaph provided is sent.

Defined at line 132 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

InterfaceRequestHandler<Interface> GetHandler (ImplPtr impl, async_dispatcher_t * dispatcher)

Returns an InterfaceRequestHandler that binds the incoming

InterfaceRequests this object.

Defined at line 148 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

void CloseAll ()

Removes all the bindings from the set.

Closes all the channels associated with this |BindingSet|.

Bindings are destroyed AFTER it is removed from the bindings set. An

example of when this is useful is if an error handler on a binding has

some behavior where it needs to read from the binding set; the set would

then properly reflect that the binding is not present in the set.

Defined at line 162 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

void CloseAll (zx_status_t epitaph_value)

Removes all the bindings from the set using the provided epitaph.

Closes all the channels associated with this |BindingSet| after sending

an epitaph. As with CloseAll(void) above, bindings are destroyed after they

are removed from the bindings set.

Defined at line 172 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

size_t size ()

The number of bindings in this |BindingSet|.

Defined at line 181 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

void set_empty_set_handler (fit::closure empty_set_handler)

Called when the last binding has been removed from this |BindingSet|.

This function is not called by |CloseAll| or by |~BindingSet|.

Defined at line 186 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h

const StorageType & bindings ()

The bindings stored in this set.

This collection of bindings can be invalidated when a |Binding| in the

set encounters a connection error because connection errors causes the

|BindingSet| to remove the |Binding| from the set.

Defined at line 195 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/binding_set.h