// This is a generated file, modify: generate/templates/templates/struct_header.h

// generated from struct_header.h
#ifndef GITFILTER_H
#define GITFILTER_H
#include <nan.h>
#include <string>
#include <utility>

#include "async_baton.h"
#include "async_worker.h"
#include "callback_wrapper.h"
#include "context.h"
#include "reference_counter.h"
#include "nodegit_wrapper.h"
#include "configurable_class_wrapper.h"
#include "v8_helpers.h"

extern "C" {
  #include <git2.h>
  #include <git2/sys/errors.h>
    #include <git2/sys/filter.h>
 }

  #include "../include/filter_source.h"
  #include "../include/buf.h"
 
using namespace node;
using namespace v8;

class GitFilter;
class ConfigurableGitFilter;
 
struct GitFilterTraits {
  typedef GitFilter cppClass;
  typedef git_filter cType;
  typedef ConfigurableGitFilter configurableCppClass;
 
  static const bool isDuplicable = false;
  static void duplicate(git_filter **dest, git_filter *src) {
     Nan::ThrowError("duplicate called on GitFilter which cannot be duplicated");
   }

  static std::string className() { return "GitFilter"; };
  static const bool isSingleton = false;
  static const bool isFreeable = true;
  static void free(git_filter *raw) {
    unsigned long referenceCount = 0;
     if (referenceCount == 0) {
      ::free(raw); // :: to avoid calling this free recursively
    }
   }
};
struct git_filter_extended {
  git_filter raw;
  void* payload;
};
  
class ConfigurableGitFilter : public nodegit::ConfigurableClassWrapper<GitFilterTraits> {
  friend class nodegit::ConfigurableClassWrapper<GitFilterTraits>;

public:
  static v8ConversionResult fromJavascript(nodegit::Context *nodegitContext, v8::Local<v8::Value> input);
  ~ConfigurableGitFilter();

  ConfigurableGitFilter(const ConfigurableGitFilter &) = delete;
  ConfigurableGitFilter(ConfigurableGitFilter &&) = delete;
  ConfigurableGitFilter &operator=(const ConfigurableGitFilter &) = delete;
  ConfigurableGitFilter &operator=(ConfigurableGitFilter &&) = delete;

            static int initialize_cppCallback (
            git_filter * self
          );

        static void initialize_cancelAsync(void *baton);
        static void initialize_async(void *baton);
        static void initialize_promiseCompleted(bool isFulfilled, nodegit::AsyncBaton *_baton, v8::Local<v8::Value> result);
           class InitializeBaton : public nodegit::AsyncBatonWithResult<int> {
          public:
              git_filter * self;
 
            InitializeBaton(const int &defaultResult)
              : nodegit::AsyncBatonWithResult<int>(defaultResult) {
              }
          };
         static ConfigurableGitFilter * initialize_getInstanceFromBaton (
          InitializeBaton *baton);
          static void shutdown_cppCallback (
            git_filter * self
          );

        static void shutdown_cancelAsync(void *baton);
        static void shutdown_async(void *baton);
        static void shutdown_promiseCompleted(bool isFulfilled, nodegit::AsyncBaton *_baton, v8::Local<v8::Value> result);
          class ShutdownBaton : public nodegit::AsyncBatonWithNoResult {
          public:
              git_filter * self;
 
            ShutdownBaton()
              : nodegit::AsyncBatonWithNoResult() {
              }
          };
         static ConfigurableGitFilter * shutdown_getInstanceFromBaton (
          ShutdownBaton *baton);
          static int check_cppCallback (
            git_filter * self
              ,
             void ** payload
              ,
             const git_filter_source * src
              ,
             const char ** attr_values
          );

        static void check_cancelAsync(void *baton);
        static void check_async(void *baton);
        static void check_promiseCompleted(bool isFulfilled, nodegit::AsyncBaton *_baton, v8::Local<v8::Value> result);
           class CheckBaton : public nodegit::AsyncBatonWithResult<int> {
          public:
              git_filter * self;
              void ** payload;
              const git_filter_source * src;
              const char ** attr_values;
 
            CheckBaton(const int &defaultResult)
              : nodegit::AsyncBatonWithResult<int>(defaultResult) {
              }
          };
         static ConfigurableGitFilter * check_getInstanceFromBaton (
          CheckBaton *baton);
          static int apply_cppCallback (
            git_filter * self
              ,
             void ** payload
              ,
             git_buf * to
              ,
             const git_buf * from
              ,
             const git_filter_source * src
          );

        static void apply_cancelAsync(void *baton);
        static void apply_async(void *baton);
        static void apply_promiseCompleted(bool isFulfilled, nodegit::AsyncBaton *_baton, v8::Local<v8::Value> result);
           class ApplyBaton : public nodegit::AsyncBatonWithResult<int> {
          public:
              git_filter * self;
              void ** payload;
              git_buf * to;
              const git_buf * from;
              const git_filter_source * src;
 
            ApplyBaton(const int &defaultResult)
              : nodegit::AsyncBatonWithResult<int>(defaultResult) {
              }
          };
         static ConfigurableGitFilter * apply_getInstanceFromBaton (
          ApplyBaton *baton);
   
private:
  ConfigurableGitFilter(nodegit::Context *nodegitContext);
  ConfigurableGitFilter() = delete;
  Nan::Global<Value> promiseError;

                CallbackWrapper initialize;
             CallbackWrapper shutdown;
             CallbackWrapper check;
             CallbackWrapper apply;
    
};

#endif
