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

#ifndef GITIGNORE_H
#define GITIGNORE_H
#include <nan.h>
#include <string>
#include <utility>
#include <sstream>

#include "async_baton.h"
#include "async_worker.h"
#include "cleanup_handle.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/repository.h"

using namespace node;
using namespace v8;


class GitIgnore : public
  Nan::ObjectWrap
{
   public:
    GitIgnore(const GitIgnore &) = delete;
    GitIgnore(GitIgnore &&) = delete;
    GitIgnore &operator=(const GitIgnore &) = delete;
    GitIgnore &operator=(GitIgnore &&) = delete;

    static void InitializeComponent (v8::Local<v8::Object> target, nodegit::Context *nodegitContext);

             

  private:

    static NAN_METHOD(AddRule);

    static NAN_METHOD(ClearInternalRules);

    struct PathIsIgnoredBaton {
      int error_code;
      const git_error* error;
      int * ignored;
      git_repository * repo;
      const char * path;
     };
    class PathIsIgnoredWorker : public nodegit::AsyncWorker {
      public:
        PathIsIgnoredWorker(
            PathIsIgnoredBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitIgnore:PathIsIgnored", cleanupHandles)
          , baton(_baton) {};
        PathIsIgnoredWorker(const PathIsIgnoredWorker &) = delete;
        PathIsIgnoredWorker(PathIsIgnoredWorker &&) = delete;
        PathIsIgnoredWorker &operator=(const PathIsIgnoredWorker &) = delete;
        PathIsIgnoredWorker &operator=(PathIsIgnoredWorker &&) = delete;
        ~PathIsIgnoredWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        PathIsIgnoredBaton *baton;
    };

    static NAN_METHOD(PathIsIgnored);
};

#endif
