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

#ifndef GITINDEXNAMEENTRY_H
#define GITINDEXNAMEENTRY_H
#include <nan.h>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <unordered_set>
#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"
#include "worker_pool.h"

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

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

#include "../include/index.h"

using namespace node;
using namespace v8;

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

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

class GitIndexNameEntry : public
  NodeGitWrapper<GitIndexNameEntryTraits>
{
    // grant full access to base class
    friend class NodeGitWrapper<GitIndexNameEntryTraits>;
   public:
    GitIndexNameEntry(const GitIndexNameEntry &) = delete;
    GitIndexNameEntry(GitIndexNameEntry &&) = delete;
    GitIndexNameEntry &operator=(const GitIndexNameEntry &) = delete;
    GitIndexNameEntry &operator=(GitIndexNameEntry &&) = delete;

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

                 

  private:
    GitIndexNameEntry()
      : NodeGitWrapper<GitIndexNameEntryTraits>(
           "A new GitIndexNameEntry cannot be instantiated."
       )
    {}
    GitIndexNameEntry(git_index_name_entry *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
      : NodeGitWrapper<GitIndexNameEntryTraits>(raw, selfFreeing, owner)
    {}
    ~GitIndexNameEntry();
    static NAN_METHOD(Ancestor);
    static NAN_METHOD(Ours);
    static NAN_METHOD(Theirs);

    struct AddBaton {
      int error_code;
      const git_error* error;
      git_index * index;
      const char * ancestor;
      const char * ours;
      const char * theirs;
     };
    class AddWorker : public nodegit::AsyncWorker {
      public:
        AddWorker(
            AddBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitIndexNameEntry:Add", cleanupHandles)
          , baton(_baton) {};
        AddWorker(const AddWorker &) = delete;
        AddWorker(AddWorker &&) = delete;
        AddWorker &operator=(const AddWorker &) = delete;
        AddWorker &operator=(AddWorker &&) = delete;
        ~AddWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        AddBaton *baton;
    };

    static NAN_METHOD(Add);

    struct ClearBaton {
      int error_code;
      const git_error* error;
      git_index * index;
     };
    class ClearWorker : public nodegit::AsyncWorker {
      public:
        ClearWorker(
            ClearBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitIndexNameEntry:Clear", cleanupHandles)
          , baton(_baton) {};
        ClearWorker(const ClearWorker &) = delete;
        ClearWorker(ClearWorker &&) = delete;
        ClearWorker &operator=(const ClearWorker &) = delete;
        ClearWorker &operator=(ClearWorker &&) = delete;
        ~ClearWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ClearBaton *baton;
    };

    static NAN_METHOD(Clear);

    static NAN_METHOD(Entrycount);

    static NAN_METHOD(GetByIndex);
};

#endif
