package org.lwjgl.util.vma;

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

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

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

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

   protected VmaFreeDeviceMemoryFunction() {
      super(CIF);
   }

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

   private static final class Container extends VmaFreeDeviceMemoryFunction {
      private final VmaFreeDeviceMemoryFunctionI delegate;

      Container(long functionPointer, VmaFreeDeviceMemoryFunctionI 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);
      }
   }
}
