package org.lwjgl.util.vma;

import javax.annotation.Nullable;
import org.lwjgl.system.Callback;

public abstract class VmaAllocateDeviceMemoryFunction extends Callback implements VmaAllocateDeviceMemoryFunctionI {
   public static VmaAllocateDeviceMemoryFunction create(long functionPointer) {
      VmaAllocateDeviceMemoryFunctionI instance = (VmaAllocateDeviceMemoryFunctionI)Callback.get(functionPointer);
      return (VmaAllocateDeviceMemoryFunction)(instance instanceof VmaAllocateDeviceMemoryFunction ? (VmaAllocateDeviceMemoryFunction)instance : new Container(functionPointer, instance));
   }

   @Nullable
   public static VmaAllocateDeviceMemoryFunction createSafe(long functionPointer) {
      return functionPointer == 0L ? null : create(functionPointer);
   }

   public static VmaAllocateDeviceMemoryFunction create(VmaAllocateDeviceMemoryFunctionI instance) {
      return (VmaAllocateDeviceMemoryFunction)(instance instanceof VmaAllocateDeviceMemoryFunction ? (VmaAllocateDeviceMemoryFunction)instance : new Container(instance.address(), instance));
   }

   protected VmaAllocateDeviceMemoryFunction() {
      super(CIF);
   }

   VmaAllocateDeviceMemoryFunction(long functionPointer) {
      super(functionPointer);
   }

   private static final class Container extends VmaAllocateDeviceMemoryFunction {
      private final VmaAllocateDeviceMemoryFunctionI delegate;

      Container(long functionPointer, VmaAllocateDeviceMemoryFunctionI delegate) {
         super(functionPointer);
         this.delegate = delegate;
      }

      public void invoke(long allocator, int memoryType, long memory, long size, long pUserData) {
         this.delegate.invoke(allocator, memoryType, memory, size, pUserData);
      }
   }
}
