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

#ifndef GITWORKTREE_H
#define GITWORKTREE_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/repository.h"
#include "../include/worktree_add_options.h"
#include "../include/buf.h"
#include "../include/worktree_prune_options.h"
#include "../include/strarray.h"
// Forward declaration.
struct git_worktree {
};

using namespace node;
using namespace v8;

class GitWorktree;

struct GitWorktreeTraits {
  typedef GitWorktree cppClass;
  typedef git_worktree cType;

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

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

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

                                                 

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

    struct AddBaton {
      int error_code;
      const git_error* error;
      git_worktree * out;
      git_repository * repo;
      const char * name;
      const char * path;
      const git_worktree_add_options * opts;
    };
    class AddWorker : public nodegit::AsyncWorker {
      public:
        AddWorker(
            AddBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitWorktree:Add")
          , baton(_baton) {};
        ~AddWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        AddBaton *baton;
    };

    static NAN_METHOD(Add);

    static NAN_METHOD(IsLocked);

    static NAN_METHOD(IsPrunable);

    struct ListBaton {
      int error_code;
      const git_error* error;
      git_strarray * out;
      git_repository * repo;
    };
    class ListWorker : public nodegit::AsyncWorker {
      public:
        ListWorker(
            ListBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitWorktree:List")
          , baton(_baton) {};
        ~ListWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ListBaton *baton;
    };

    static NAN_METHOD(List);

    static NAN_METHOD(Lock);

    struct LookupBaton {
      int error_code;
      const git_error* error;
      git_worktree * out;
      git_repository * repo;
      const char * name;
    };
    class LookupWorker : public nodegit::AsyncWorker {
      public:
        LookupWorker(
            LookupBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitWorktree:Lookup")
          , baton(_baton) {};
        ~LookupWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        LookupBaton *baton;
    };

    static NAN_METHOD(Lookup);

    static NAN_METHOD(Name);

    struct OpenFromRepositoryBaton {
      int error_code;
      const git_error* error;
      git_worktree * out;
      git_repository * repo;
    };
    class OpenFromRepositoryWorker : public nodegit::AsyncWorker {
      public:
        OpenFromRepositoryWorker(
            OpenFromRepositoryBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitWorktree:OpenFromRepository")
          , baton(_baton) {};
        ~OpenFromRepositoryWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        OpenFromRepositoryBaton *baton;
    };

    static NAN_METHOD(OpenFromRepository);

    static NAN_METHOD(Path);

    static NAN_METHOD(Prune);

    static NAN_METHOD(Unlock);

    static NAN_METHOD(Validate);
};

#endif
