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

#ifndef GITSTATUS_H
#define GITSTATUS_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 <git2/sys/diff.h>
}

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

#include "../include/status_list.h"
#include "../include/status_entry.h"
#include "../include/repository.h"
#include "../include/status_options.h"

using namespace node;
using namespace v8;


class GitStatus : public
  Nan::ObjectWrap
{
   public:
    static void InitializeComponent (v8::Local<v8::Object> target, nodegit::Context *nodegitContext);

              static int Foreach_callback_cppCallback (
      const char * path
      ,
       unsigned int status_flags
      ,
       void * payload
      );

    static void Foreach_callback_cancelAsync(void *baton);
    static void Foreach_callback_async(void *baton);
    static void Foreach_callback_promiseCompleted(bool isFulfilled, nodegit::AsyncBaton *_baton, v8::Local<v8::Value> result);
    class Foreach_CallbackBaton : public nodegit::AsyncBatonWithResult<int> {
    public:
      const char * path;
      unsigned int status_flags;
      void * payload;
 
      Foreach_CallbackBaton(const int &defaultResult)
        : nodegit::AsyncBatonWithResult<int>(defaultResult) {
        }
    };
          static int ForeachExt_callback_cppCallback (
      const char * path
      ,
       unsigned int status_flags
      ,
       void * payload
      );

    static void ForeachExt_callback_cancelAsync(void *baton);
    static void ForeachExt_callback_async(void *baton);
    static void ForeachExt_callback_promiseCompleted(bool isFulfilled, nodegit::AsyncBaton *_baton, v8::Local<v8::Value> result);
    class ForeachExt_CallbackBaton : public nodegit::AsyncBatonWithResult<int> {
    public:
      const char * path;
      unsigned int status_flags;
      void * payload;
 
      ForeachExt_CallbackBaton(const int &defaultResult)
        : nodegit::AsyncBatonWithResult<int>(defaultResult) {
        }
    };
          

  private:

    static NAN_METHOD(Byindex);

    struct FileBaton {
      int error_code;
      const git_error* error;
      unsigned int * status_flags;
      git_repository * repo;
      const char * path;
    };
    class FileWorker : public nodegit::AsyncWorker {
      public:
        FileWorker(
            FileBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitStatus:File")
          , baton(_baton) {};
        ~FileWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        FileBaton *baton;
    };

    static NAN_METHOD(File);

    struct ForeachBaton {
      int error_code;
      const git_error* error;
      git_repository * repo;
      git_status_cb callback;
      void * payload;
    };
    class ForeachWorker : public nodegit::AsyncWorker {
      public:
        ForeachWorker(
            ForeachBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitStatus:Foreach")
          , baton(_baton) {};
        ~ForeachWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ForeachBaton *baton;
    };

    static NAN_METHOD(Foreach);

    struct ForeachExtBaton {
      int error_code;
      const git_error* error;
      git_repository * repo;
      const git_status_options * opts;
      git_status_cb callback;
      void * payload;
    };
    class ForeachExtWorker : public nodegit::AsyncWorker {
      public:
        ForeachExtWorker(
            ForeachExtBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitStatus:ForeachExt")
          , baton(_baton) {};
        ~ForeachExtWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ForeachExtBaton *baton;
    };

    static NAN_METHOD(ForeachExt);

    static NAN_METHOD(ShouldIgnore);

    struct Foreach_globalPayload {
      Nan::Callback * callback;

      Foreach_globalPayload() {
        callback = NULL;
      }

      ~Foreach_globalPayload() {
        if (callback != NULL) {
          delete callback;
        }
      }
    };

    struct ForeachExt_globalPayload {
      Nan::Callback * callback;

      ForeachExt_globalPayload() {
        callback = NULL;
      }

      ~ForeachExt_globalPayload() {
        if (callback != NULL) {
          delete callback;
        }
      }
    };
};

#endif
