| // Copyright 2022 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef SRC_BIND_LIBRARY_PARENT_DRIVER_H_ |
| #define SRC_BIND_LIBRARY_PARENT_DRIVER_H_ |
| |
| #include <fidl/fuchsia.gizmo.protocol/cpp/wire.h> |
| #include <lib/driver2/driver2.h> |
| #include <lib/sys/component/llcpp/outgoing_directory.h> |
| |
| namespace parent_driver { |
| |
| class ParentDriver : public fidl::WireServer<fuchsia_gizmo_protocol::TestingProtocol> { |
| public: |
| ParentDriver(async_dispatcher_t* dispatcher, |
| fidl::WireSharedClient<fuchsia_driver_framework::Node> node, driver::Namespace ns, |
| driver::Logger logger) |
| : dispatcher_(dispatcher), |
| outgoing_(component::OutgoingDirectory::Create(dispatcher)), |
| node_(std::move(node)), |
| ns_(std::move(ns)), |
| logger_(std::move(logger)) {} |
| virtual ~ParentDriver() = default; |
| |
| static constexpr const char* Name() { return "parent-driver"; } |
| |
| static zx::status<std::unique_ptr<ParentDriver>> Start( |
| fuchsia_driver_framework::wire::DriverStartArgs& start_args, |
| fdf::UnownedDispatcher dispatcher, |
| fidl::WireSharedClient<fuchsia_driver_framework::Node> node, driver::Namespace ns, |
| driver::Logger logger); |
| |
| private: |
| zx::status<> Run(fidl::ServerEnd<fuchsia_io::Directory> outgoing_dir); |
| zx::status<> AddChild(); |
| |
| // fidl::WireServer<fuchsia_gizmo_protocol::TestingProtocol> |
| void Get(GetRequestView request, GetCompleter::Sync& completer); |
| |
| async_dispatcher_t* const dispatcher_; |
| component::OutgoingDirectory outgoing_; |
| fidl::WireSharedClient<fuchsia_driver_framework::Node> node_; |
| driver::Namespace ns_; |
| driver::Logger logger_; |
| }; |
| |
| } // namespace parent_driver |
| |
| #endif // SRC_BIND_LIBRARY_PARENT_DRIVER_H_ |