/*
 * This RPC client stub was autogenerated by idlc (version c8601c6e). DO NOT EDIT!
 * Generated from Display.idl for interface Display at 2021-07-08T01:00:48-0500
 *
 * You may use these generated stubs directly as the RPC interface, or you can subclass it to
 * override the behavior of the function calls, or to perform some preprocessing to the data as
 * needed before sending it.
 *
 * See the full RPC documentation for more details.
 */
#ifndef RPC_CLIENT_GENERATED_10322778102778773913
#define RPC_CLIENT_GENERATED_10322778102778773913

#include <string>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <span>
#include <string_view>
#include <vector>

#define RPC_USER_TYPES_INCLUDES
#include <DriverSupport/gfx/Types.h>
#undef RPC_USER_TYPES_INCLUDES

namespace rpc {
namespace rt { class ClientRpcIoStream; }
class DisplayClient {
    struct MessageHeader {
        enum Flags: uint32_t {
            Request                     = (1 << 0),
            Response                    = (1 << 1),
        };

        uint64_t type;
        Flags flags;
        uint32_t tag;

        std::byte payload[];
    };
    static_assert(!(offsetof(MessageHeader, payload) % sizeof(uintptr_t)),
        "message header's payload is not word aligned");

    constexpr static const std::string_view kServiceName{"Display"};

    protected:
        using IoStream = rt::ClientRpcIoStream;

    public:
        // Return types for method 'GetDeviceCapabilities'
        struct GetDeviceCapabilitiesReturn {
            int32_t status;
            uint32_t caps;
        };
        // Return types for method 'GetFramebuffer'
        struct GetFramebufferReturn {
            int32_t status;
            uint64_t handle;
            uint64_t size;
        };
        // Return types for method 'GetFramebufferInfo'
        struct GetFramebufferInfoReturn {
            int32_t status;
            uint32_t w;
            uint32_t h;
            uint32_t pitch;
        };

    public:
        DisplayClient(const std::shared_ptr<IoStream> &stream);
        virtual ~DisplayClient();

        virtual GetDeviceCapabilitiesReturn GetDeviceCapabilities();
        virtual int32_t SetOutputEnabled(bool enabled);
        virtual int32_t SetOutputMode(const DriverSupport::gfx::DisplayMode &mode);
        virtual int32_t RegionUpdated(int32_t x, int32_t y, uint32_t w, uint32_t h);
        virtual GetFramebufferReturn GetFramebuffer();
        virtual GetFramebufferInfoReturn GetFramebufferInfo();

    // Helpers provided to subclasses for implementation of interface methods
    protected:
        constexpr inline auto &getIo() {
            return this->io;
        }

        /// Handles errors occurring during client operations; typically terminates the task
        virtual void _HandleError(const bool fatal, const std::string_view &what);

    // Implementation details; pretend this does not exist
    private:
        std::shared_ptr<IoStream> io;
        size_t txBufSize{0};
        void *txBuf{nullptr};

        uint32_t nextTag{0};

        void _ensureTxBuf(const size_t);
        uint32_t _sendRequest(const uint64_t type, const size_t payloadBytes);
}; // class DisplayClient
} // namespace rpc
#endif // defined(RPC_CLIENT_GENERATED_10322778102778773913)
