//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// Provides parameters for creating a resource view pool.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlresourceviewpooldescriptor?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MTLResourceViewPoolDescriptor;
);

extern_conformance!(
    unsafe impl NSCopying for MTLResourceViewPoolDescriptor {}
);

unsafe impl CopyingHelper for MTLResourceViewPoolDescriptor {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for MTLResourceViewPoolDescriptor {}
);

impl MTLResourceViewPoolDescriptor {
    extern_methods!(
        /// Configures the number of resource views with which Metal creates the resource view pool.
        #[unsafe(method(resourceViewCount))]
        #[unsafe(method_family = none)]
        pub fn resourceViewCount(&self) -> NSUInteger;

        /// Setter for [`resourceViewCount`][Self::resourceViewCount].
        ///
        /// # Safety
        ///
        /// This might not be bounds-checked.
        #[unsafe(method(setResourceViewCount:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setResourceViewCount(&self, resource_view_count: NSUInteger);

        /// Assigns an optional label you to the resource view pool for debugging purposes.
        #[unsafe(method(label))]
        #[unsafe(method_family = none)]
        pub fn label(&self) -> Option<Retained<NSString>>;

        /// Setter for [`label`][Self::label].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setLabel:))]
        #[unsafe(method_family = none)]
        pub fn setLabel(&self, label: Option<&NSString>);
    );
}

/// Methods declared on superclass `NSObject`.
impl MTLResourceViewPoolDescriptor {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for MTLResourceViewPoolDescriptor {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_protocol!(
    /// Contains views over resources of a specific type, and allows you to manage those views.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/metal/mtlresourceviewpool?language=objc)
    pub unsafe trait MTLResourceViewPool: NSObjectProtocol {
        #[cfg(feature = "MTLTypes")]
        /// Obtains the resource ID corresponding to the resource view at index 0 in this resource view pool.
        #[unsafe(method(baseResourceID))]
        #[unsafe(method_family = none)]
        fn baseResourceID(&self) -> MTLResourceID;

        /// Queries the number of resource views that this pool contains.
        #[unsafe(method(resourceViewCount))]
        #[unsafe(method_family = none)]
        fn resourceViewCount(&self) -> NSUInteger;

        #[cfg(feature = "MTLDevice")]
        /// Obtains a reference to the GPU device this pool belongs to.
        #[unsafe(method(device))]
        #[unsafe(method_family = none)]
        fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>;

        /// Queries the optional debug label of this resource view pool.
        #[unsafe(method(label))]
        #[unsafe(method_family = none)]
        fn label(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "MTLTypes")]
        /// Copies a range of resource views from a source view pool to a destination location in this view pool.
        ///
        /// - Parameters:
        /// - sourcePool: resource view pool from which to copy resource views.
        /// - sourceRange: The range in the source resource view pool to copy.
        /// - destinationIndex: The starting index in this destination view pool into which to copy the source range of resource views.
        ///
        /// - Returns: The ``MTLResourceID`` of the resource view corresponding to `destinationIndex` of the copy in this resource view pool.
        ///
        /// # Safety
        ///
        /// - `sourceRange` might not be bounds-checked.
        /// - `destinationIndex` might not be bounds-checked.
        #[unsafe(method(copyResourceViewsFromPool:sourceRange:destinationIndex:))]
        #[unsafe(method_family = none)]
        unsafe fn copyResourceViewsFromPool_sourceRange_destinationIndex(
            &self,
            source_pool: &ProtocolObject<dyn MTLResourceViewPool>,
            source_range: NSRange,
            destination_index: NSUInteger,
        ) -> MTLResourceID;
    }
);
