| // WARNING: This file is machine generated by fidlgen. |
| |
| // fidl_experiment = output_index_json |
| |
| #pragma once |
| |
| #include <fidl/test.driverservice/cpp/markers.h> |
| #include <fidl/test.driverservice/cpp/wire_types.h> |
| #include <lib/fidl_driver/cpp/wire_messaging.h> |
| |
| #ifdef __Fuchsia__ |
| |
| #include <lib/fidl/cpp/wire/connect_service.h> |
| #include <lib/fidl/cpp/wire/server.h> |
| #include <lib/fidl/cpp/wire/service_handler.h> |
| #include <lib/fidl/cpp/wire/sync_call.h> |
| #include <lib/fidl_driver/cpp/server.h> |
| #include <lib/fidl_driver/cpp/wire_client.h> |
| |
| #endif // __Fuchsia__ |
| |
| #pragma clang diagnostic push |
| #pragma clang diagnostic ignored "-Wshadow" |
| |
| namespace test_driverservice { |
| |
| class SomeDriverProtocol; |
| |
| class DriverOnlyService; |
| |
| } // namespace test_driverservice |
| |
| #ifdef __Fuchsia__ |
| |
| template <> |
| struct ::fidl::internal::ProtocolDetails<::test_driverservice::SomeDriverProtocol> { |
| }; |
| |
| #endif // __Fuchsia__ |
| |
| #ifdef __Fuchsia__ |
| |
| template <> |
| struct ::fidl::internal::WireServerDispatcher<::test_driverservice::SomeDriverProtocol> final { |
| WireServerDispatcher() = delete; |
| static ::fidl::DispatchResult TryDispatch(::fdf::WireServer<::test_driverservice::SomeDriverProtocol>* impl, ::fidl::IncomingHeaderAndMessage& msg, |
| internal::MessageStorageViewBase* storage_view, |
| ::fidl::Transaction* txn); |
| static void Dispatch(::fdf::WireServer<::test_driverservice::SomeDriverProtocol>* impl, ::fidl::IncomingHeaderAndMessage&& msg, |
| internal::MessageStorageViewBase* storage_view, |
| ::fidl::Transaction* txn); |
| |
| private: |
| static const ::fidl::internal::MethodEntry entries_[]; |
| static const ::fidl::internal::MethodEntry* entries_end_; |
| static constexpr const ::fidl::internal::UnknownMethodHandlerEntry& unknown_method_handler_entry_ = |
| ::fidl::internal::UnknownMethodHandlerEntry::kClosedProtocolHandlerEntry; |
| }; |
| |
| #endif // __Fuchsia__ |
| |
| namespace fidl { |
| |
| #ifdef __Fuchsia__ |
| } // namespace fidl |
| |
| template <> |
| class ::fidl::internal::WireEventHandlerInterface<::test_driverservice::SomeDriverProtocol> : public ::fidl::internal::BaseEventHandlerInterface { |
| public: |
| WireEventHandlerInterface() = default; |
| virtual ~WireEventHandlerInterface() = default; |
| }; |
| |
| template <> |
| class ::fdf::WireAsyncEventHandler<::test_driverservice::SomeDriverProtocol> |
| : public ::fidl::internal::WireEventHandlerInterface<::test_driverservice::SomeDriverProtocol>, public ::fidl::internal::AsyncEventHandler { |
| public: |
| WireAsyncEventHandler() = default; |
| }; |
| |
| template <> |
| class ::fidl::internal::WireEventDispatcher<::test_driverservice::SomeDriverProtocol> final : public ::fidl::internal::IncomingEventDispatcher<::fidl::internal::WireEventHandlerInterface<::test_driverservice::SomeDriverProtocol>> { |
| public: |
| explicit WireEventDispatcher(::fidl::internal::WireEventHandlerInterface<::test_driverservice::SomeDriverProtocol>* event_handler) |
| : IncomingEventDispatcher(event_handler) {} |
| }; |
| |
| template <> |
| class ::fidl::internal::WireSyncBufferClientImpl<::test_driverservice::SomeDriverProtocol> final : public ::fdf::internal::SyncEndpointBufferVeneer<::fidl::internal::WireSyncBufferClientImpl<::test_driverservice::SomeDriverProtocol>> { |
| public: |
| private: |
| ::fdf::UnownedClientEnd<::test_driverservice::SomeDriverProtocol> _client_end() const { |
| return ::fdf::UnownedClientEnd<::test_driverservice::SomeDriverProtocol>( |
| _transport().get<::fidl::internal::DriverTransport>()); |
| } |
| }; |
| |
| // Pure-virtual interface to be implemented by a server. |
| // This interface uses typed channels (i.e. |::fdf::ClientEnd<::test_driverservice::SomeDriverProtocol>| |
| // and |::fdf::ServerEnd<::test_driverservice::SomeDriverProtocol>|). |
| template <> |
| class ::fdf::WireServer<::test_driverservice::SomeDriverProtocol> : public ::fidl::internal::IncomingMessageDispatcher { |
| public: |
| WireServer() = default; |
| virtual ~WireServer() = default; |
| |
| // The FIDL protocol type that is implemented by this server. |
| using _EnclosingProtocol = ::test_driverservice::SomeDriverProtocol; |
| |
| using Handler = fidl::ProtocolHandler<::test_driverservice::SomeDriverProtocol>; |
| |
| // |bind_handler| returns a handler that binds incoming connections to this |
| // server implementation. |
| // |
| // The returned handler borrows the server instance. |
| // The server must outlive the provided |dispatcher|. Only after |
| // the dispatcher is shutdown will it be safe to destroy the servers. |
| // The server should not be moved. |
| Handler bind_handler(fdf_dispatcher_t* dispatcher) { |
| return [impl = this, dispatcher = dispatcher](::fdf::ServerEnd<::test_driverservice::SomeDriverProtocol> request) { |
| (void)::fdf::BindServer(dispatcher, std::move(request), impl); |
| }; |
| } |
| |
| private: |
| void dispatch_message( |
| ::fidl::IncomingHeaderAndMessage&& msg, ::fidl::Transaction* txn, |
| ::fidl::internal::MessageStorageViewBase* storage_view) final; |
| }; |
| namespace fidl { |
| |
| #endif // __Fuchsia__ |
| |
| } // namespace fidl |
| namespace test_driverservice { |
| |
| class DriverOnlyService final { |
| DriverOnlyService() = default; |
| |
| public: |
| static constexpr bool kIsService = true; |
| static constexpr char Name[] = "test.driverservice.DriverOnlyService"; |
| using Transport = ::fidl::internal::DriverTransport; |
| #ifdef __Fuchsia__ |
| using ServiceInstanceHandler = fidl::ServiceInstanceHandler<::fidl::internal::DriverTransport>; |
| |
| #endif // __Fuchsia__ |
| |
| class Member final { |
| public: |
| static constexpr bool kIsServiceMember = true; |
| static constexpr char Name[] = "member"; |
| static constexpr char ServiceName[] = "test.driverservice.DriverOnlyService"; |
| using ProtocolType = ::test_driverservice::SomeDriverProtocol; |
| }; |
| |
| // Client protocol for connecting to member protocols of a service instance. |
| class ServiceClient final { |
| ServiceClient() = delete; |
| #ifdef __Fuchsia__ |
| public: |
| ServiceClient(::zx::channel dir, ::fidl::internal::ConnectMemberFunc connect_func) |
| : dir_(std::move(dir)), connect_func_(connect_func) {} |
| |
| // Connects |server_end| to the member protocol "member". |
| // |
| // # Errors |
| // |
| // On failure, returns a |zx::error| with status != ZX_OK. |
| // Failures can occur if there was an issue making a |fuchsia.io.Directory/Open| call. |
| // |
| // Since the call to |Open| is asynchronous, an error sent by the remote end will not |
| // result in a failure of this method. Any errors sent by the remote will appear on |
| // the reciprocal |ClientEnd| for the |ServerEnd| passed into this method. |
| ::zx::result<> connect_member(::fdf::ServerEnd<::test_driverservice::SomeDriverProtocol> server_end) { |
| return connect_func_( |
| ::zx::unowned_channel(dir_), |
| ::fidl::StringView("member"), |
| ::fidl::internal::MakeAnyTransport(server_end.TakeChannel())); |
| } |
| |
| // Connects to the member protocol "member". |
| // |
| // # Errors |
| // |
| // On failure, returns a |zx::error| with status != ZX_OK. |
| // Failures can occur if channel creation failed, or if there was an issue making |
| // a |fuchsia.io.Directory/Open| call. |
| // |
| // Since the call to |Open| is asynchronous, an error sent by the remote end will not |
| // result in a failure of this method. Any errors sent by the remote will appear on |
| // the |ClientEnd| returned from this method. |
| ::zx::result<::fdf::ClientEnd<::test_driverservice::SomeDriverProtocol>> connect_member() { |
| ::zx::result endpoints = ::fdf::CreateEndpoints<::test_driverservice::SomeDriverProtocol>(); |
| if (endpoints.is_error()) { |
| return endpoints.take_error(); |
| } |
| ::zx::result connection = connect_member(std::move(endpoints->server)); |
| if (connection.is_error()) { |
| return connection.take_error(); |
| } |
| return ::zx::ok(std::move(endpoints->client)); |
| } |
| |
| private: |
| ::zx::channel dir_; |
| ::fidl::internal::ConnectMemberFunc connect_func_; |
| |
| #endif // __Fuchsia__ |
| }; |
| #ifdef __Fuchsia__ |
| // Facilitates member protocol registration for servers. |
| class InstanceHandler final : public fidl::ServiceInstanceHandler<::fidl::internal::DriverTransport> { |
| public: |
| struct Members { |
| MemberHandler<::test_driverservice::SomeDriverProtocol> member; |
| }; |
| |
| InstanceHandler() = default; |
| |
| // Construct an instance handler for a FIDL service. It is expected that every member |
| // contained in |members| is initialized with a handler. |
| InstanceHandler(Members members) { |
| // This should always be ZX_OK. That's because the only possible |
| // error is ZX_ERR_ALREADY_EXISTS which is impossible to occur as fidlc |
| // won't allow service declarations with duplicated names. |
| ZX_ASSERT(add_member(std::move(members.member)).status_value() == ZX_OK); |
| } |
| |
| // Adds member "member" to the service instance. |handler| will be |
| // invoked on connection attempts. |
| // |
| // # Errors |
| // |
| // Returns ZX_ERR_ALREADY_EXISTS if the member was already added. |
| ::zx::result<> add_member( |
| MemberHandler<::test_driverservice::SomeDriverProtocol> handler) { |
| return this->AddMember<::test_driverservice::SomeDriverProtocol>(std::move(handler), "member"); |
| } |
| }; |
| |
| #endif // __Fuchsia__ |
| }; |
| |
| } // namespace test_driverservice |
| namespace fidl { |
| |
| #ifdef __Fuchsia__ |
| } // namespace fidl |
| |
| template <> |
| class ::fidl::internal::WireWeakOnewayBufferClientImpl<::test_driverservice::SomeDriverProtocol> : public ::fdf::internal::BufferClientImplBase { |
| public: |
| using BufferClientImplBase::BufferClientImplBase; |
| }; |
| |
| template <> |
| class ::fidl::internal::WireWeakAsyncBufferClientImpl<::test_driverservice::SomeDriverProtocol> final : public ::fidl::internal::WireWeakOnewayBufferClientImpl<::test_driverservice::SomeDriverProtocol> { |
| public: |
| using WireWeakOnewayBufferClientImpl::WireWeakOnewayBufferClientImpl; |
| }; |
| |
| template <> |
| class ::fidl::internal::WireWeakOnewayClientImpl<::test_driverservice::SomeDriverProtocol> : public ::fidl::internal::ClientImplBase { |
| public: |
| WireWeakOnewayClientImpl(fidl::internal::ClientBase* client_base, const fdf::Arena& arena) |
| : ClientImplBase(client_base), arena_(arena) {} |
| |
| protected: |
| const ::fdf::Arena& arena_; |
| }; |
| |
| template <> |
| class ::fidl::internal::WireWeakSyncClientImpl<::test_driverservice::SomeDriverProtocol> final : public ::fidl::internal::WireWeakOnewayClientImpl<::test_driverservice::SomeDriverProtocol> { |
| public: |
| using WireWeakOnewayClientImpl::WireWeakOnewayClientImpl; |
| }; |
| namespace fidl { |
| |
| #endif // __Fuchsia__ |
| |
| } // namespace fidl |
| |
| #ifdef __Fuchsia__ |
| template <> |
| class ::fidl::internal::WireWeakBufferEventSender<::test_driverservice::SomeDriverProtocol> : public ::fdf::internal::WeakBufferEventSenderBase { |
| public: |
| using WeakBufferEventSenderBase::WeakBufferEventSenderBase; |
| }; |
| |
| template <> |
| class ::fidl::internal::WireBufferEventSender<::test_driverservice::SomeDriverProtocol> |
| : public ::fdf::internal::SyncEndpointBufferVeneer<::fidl::internal::WireBufferEventSender<::test_driverservice::SomeDriverProtocol>> { |
| public: |
| using SyncEndpointBufferVeneer::SyncEndpointBufferVeneer; |
| }; |
| |
| #endif // __Fuchsia__ |
| |
| #pragma clang diagnostic pop |