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

#ifndef GITFILTERLIST_H
#define GITFILTERLIST_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>

#include "async_baton.h"
#include "async_worker.h"
#include "context.h"
#include "lock_master.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"

extern "C" {
#include <git2.h>
}

#include "../include/typedefs.h"

#include "../include/git_buf_converter.h"
#include "../include/filter_registry.h"
#include "../include/buf.h"
#include "../include/blob.h"
#include "../include/repository.h"
// Forward declaration.
struct git_filter_list {
};

using namespace node;
using namespace v8;

class GitFilterList;

struct GitFilterListTraits {
  typedef GitFilterList cppClass;
  typedef git_filter_list cType;

  static const bool isDuplicable = false;
  static void duplicate(git_filter_list **dest, git_filter_list *src) {
     Nan::ThrowError("duplicate called on GitFilterList which cannot be duplicated");
   }

  static std::string className() { return "GitFilterList"; };
  static const bool isSingleton = false;
  static const bool isFreeable = true;
  static void free(git_filter_list *raw) {
    unsigned long referenceCount = 0;
     if (referenceCount == 0) {
      ::git_filter_list_free(raw); // :: to avoid calling this free recursively
    }
   }
};

class GitFilterList : public
  NodeGitWrapper<GitFilterListTraits>
{
    // grant full access to base class
    friend class NodeGitWrapper<GitFilterListTraits>;
   public:
    static void InitializeComponent (v8::Local<v8::Object> target, nodegit::Context *nodegitContext);

                         

  private:
    GitFilterList()
      : NodeGitWrapper<GitFilterListTraits>(
           "A new GitFilterList cannot be instantiated."
       )
    {}
    GitFilterList(git_filter_list *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
      : NodeGitWrapper<GitFilterListTraits>(raw, selfFreeing, owner)
    {}
    ~GitFilterList();

    struct ApplyToBlobBaton {
      int error_code;
      const git_error* error;
      git_buf * out;
      git_filter_list * filters;
      git_blob * blob;
    };
    class ApplyToBlobWorker : public nodegit::AsyncWorker {
      public:
        ApplyToBlobWorker(
            ApplyToBlobBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitFilterList:ApplyToBlob")
          , baton(_baton) {};
        ~ApplyToBlobWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ApplyToBlobBaton *baton;
    };

    static NAN_METHOD(ApplyToBlob);

    struct ApplyToDataBaton {
      int error_code;
      const git_error* error;
      git_buf * out;
      git_filter_list * filters;
      git_buf * in;
    };
    class ApplyToDataWorker : public nodegit::AsyncWorker {
      public:
        ApplyToDataWorker(
            ApplyToDataBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitFilterList:ApplyToData")
          , baton(_baton) {};
        ~ApplyToDataWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ApplyToDataBaton *baton;
    };

    static NAN_METHOD(ApplyToData);

    struct ApplyToFileBaton {
      int error_code;
      const git_error* error;
      git_buf * out;
      git_filter_list * filters;
      git_repository * repo;
      const char * path;
    };
    class ApplyToFileWorker : public nodegit::AsyncWorker {
      public:
        ApplyToFileWorker(
            ApplyToFileBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitFilterList:ApplyToFile")
          , baton(_baton) {};
        ~ApplyToFileWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ApplyToFileBaton *baton;
    };

    static NAN_METHOD(ApplyToFile);

    struct LoadBaton {
      int error_code;
      const git_error* error;
      git_filter_list * filters;
      git_repository * repo;
      git_blob * blob;
      const char * path;
      git_filter_mode_t mode;
      uint32_t flags;
    };
    class LoadWorker : public nodegit::AsyncWorker {
      public:
        LoadWorker(
            LoadBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitFilterList:Load")
          , baton(_baton) {};
        ~LoadWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        LoadBaton *baton;
    };

    static NAN_METHOD(Load);
};

#endif
