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

#ifndef GITREFS_H
#define GITREFS_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 "../include/typedefs.h"

#include "../include/repository.h"
#include "../include/oid.h"
#include "../include/strarray.h"
#include "../include/object.h"
// Forward declaration.
struct git_reference {
};

using namespace node;
using namespace v8;

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

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

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

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

                                                                                                                                                       

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

    static NAN_METHOD(Cmp);

    struct CreateBaton {
      int error_code;
      const git_error* error;
      git_reference * out;
      git_repository * repo;
      const char * name;
      const git_oid * id;
      bool idNeedsFree;
      int force;
      const char * log_message;
     };
    class CreateWorker : public nodegit::AsyncWorker {
      public:
        CreateWorker(
            CreateBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:Create", cleanupHandles)
          , baton(_baton) {};
        CreateWorker(const CreateWorker &) = delete;
        CreateWorker(CreateWorker &&) = delete;
        CreateWorker &operator=(const CreateWorker &) = delete;
        CreateWorker &operator=(CreateWorker &&) = delete;
        ~CreateWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        CreateBaton *baton;
    };

    static NAN_METHOD(Create);

    struct CreateMatchingBaton {
      int error_code;
      const git_error* error;
      git_reference * out;
      git_repository * repo;
      const char * name;
      const git_oid * id;
      bool idNeedsFree;
      int force;
      const git_oid * current_id;
      bool current_idNeedsFree;
      const char * log_message;
     };
    class CreateMatchingWorker : public nodegit::AsyncWorker {
      public:
        CreateMatchingWorker(
            CreateMatchingBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:CreateMatching", cleanupHandles)
          , baton(_baton) {};
        CreateMatchingWorker(const CreateMatchingWorker &) = delete;
        CreateMatchingWorker(CreateMatchingWorker &&) = delete;
        CreateMatchingWorker &operator=(const CreateMatchingWorker &) = delete;
        CreateMatchingWorker &operator=(CreateMatchingWorker &&) = delete;
        ~CreateMatchingWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        CreateMatchingBaton *baton;
    };

    static NAN_METHOD(CreateMatching);

    static NAN_METHOD(Delete);

    struct DupBaton {
      int error_code;
      const git_error* error;
      git_reference * dest;
      git_reference * source;
     };
    class DupWorker : public nodegit::AsyncWorker {
      public:
        DupWorker(
            DupBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:Dup", cleanupHandles)
          , baton(_baton) {};
        DupWorker(const DupWorker &) = delete;
        DupWorker(DupWorker &&) = delete;
        DupWorker &operator=(const DupWorker &) = delete;
        DupWorker &operator=(DupWorker &&) = delete;
        ~DupWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        DupBaton *baton;
    };

    static NAN_METHOD(Dup);

    struct DwimBaton {
      int error_code;
      const git_error* error;
      git_reference * out;
      git_repository * repo;
      const char * shorthand;
     };
    class DwimWorker : public nodegit::AsyncWorker {
      public:
        DwimWorker(
            DwimBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:Dwim", cleanupHandles)
          , baton(_baton) {};
        DwimWorker(const DwimWorker &) = delete;
        DwimWorker(DwimWorker &&) = delete;
        DwimWorker &operator=(const DwimWorker &) = delete;
        DwimWorker &operator=(DwimWorker &&) = delete;
        ~DwimWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        DwimBaton *baton;
    };

    static NAN_METHOD(Dwim);

    static NAN_METHOD(EnsureLog);

    static NAN_METHOD(HasLog);

    static NAN_METHOD(IsBranch);

    static NAN_METHOD(IsNote);

    static NAN_METHOD(IsRemote);

    static NAN_METHOD(IsTag);

    static NAN_METHOD(IsValidName);

    struct ListBaton {
      int error_code;
      const git_error* error;
      git_strarray * array;
      git_repository * repo;
     };
    class ListWorker : public nodegit::AsyncWorker {
      public:
        ListWorker(
            ListBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:List", cleanupHandles)
          , baton(_baton) {};
        ListWorker(const ListWorker &) = delete;
        ListWorker(ListWorker &&) = delete;
        ListWorker &operator=(const ListWorker &) = delete;
        ListWorker &operator=(ListWorker &&) = delete;
        ~ListWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ListBaton *baton;
    };

    static NAN_METHOD(List);

    struct LookupBaton {
      int error_code;
      const git_error* error;
      git_reference * out;
      git_repository * repo;
      const char * name;
     };
    class LookupWorker : public nodegit::AsyncWorker {
      public:
        LookupWorker(
            LookupBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:Lookup", cleanupHandles)
          , baton(_baton) {};
        LookupWorker(const LookupWorker &) = delete;
        LookupWorker(LookupWorker &&) = delete;
        LookupWorker &operator=(const LookupWorker &) = delete;
        LookupWorker &operator=(LookupWorker &&) = delete;
        ~LookupWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        LookupBaton *baton;
    };

    static NAN_METHOD(Lookup);

    static NAN_METHOD(Name);

    static NAN_METHOD(NameIsValid);

    struct NameToIdBaton {
      int error_code;
      const git_error* error;
      git_oid * out;
      git_repository * repo;
      const char * name;
     };
    class NameToIdWorker : public nodegit::AsyncWorker {
      public:
        NameToIdWorker(
            NameToIdBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:NameToId", cleanupHandles)
          , baton(_baton) {};
        NameToIdWorker(const NameToIdWorker &) = delete;
        NameToIdWorker(NameToIdWorker &&) = delete;
        NameToIdWorker &operator=(const NameToIdWorker &) = delete;
        NameToIdWorker &operator=(NameToIdWorker &&) = delete;
        ~NameToIdWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        NameToIdBaton *baton;
    };

    static NAN_METHOD(NameToId);

    static NAN_METHOD(NormalizeName);

    static NAN_METHOD(Owner);

    struct PeelBaton {
      int error_code;
      const git_error* error;
      git_object * out;
      const git_reference * ref;
      git_object_t type;
     };
    class PeelWorker : public nodegit::AsyncWorker {
      public:
        PeelWorker(
            PeelBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:Peel", cleanupHandles)
          , baton(_baton) {};
        PeelWorker(const PeelWorker &) = delete;
        PeelWorker(PeelWorker &&) = delete;
        PeelWorker &operator=(const PeelWorker &) = delete;
        PeelWorker &operator=(PeelWorker &&) = delete;
        ~PeelWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        PeelBaton *baton;
    };

    static NAN_METHOD(Peel);

    static NAN_METHOD(Remove);

    struct RenameBaton {
      int error_code;
      const git_error* error;
      git_reference * new_ref;
      git_reference * ref;
      const char * new_name;
      int force;
      const char * log_message;
     };
    class RenameWorker : public nodegit::AsyncWorker {
      public:
        RenameWorker(
            RenameBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:Rename", cleanupHandles)
          , baton(_baton) {};
        RenameWorker(const RenameWorker &) = delete;
        RenameWorker(RenameWorker &&) = delete;
        RenameWorker &operator=(const RenameWorker &) = delete;
        RenameWorker &operator=(RenameWorker &&) = delete;
        ~RenameWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        RenameBaton *baton;
    };

    static NAN_METHOD(Rename);

    struct ResolveBaton {
      int error_code;
      const git_error* error;
      git_reference * out;
      const git_reference * ref;
     };
    class ResolveWorker : public nodegit::AsyncWorker {
      public:
        ResolveWorker(
            ResolveBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:Resolve", cleanupHandles)
          , baton(_baton) {};
        ResolveWorker(const ResolveWorker &) = delete;
        ResolveWorker(ResolveWorker &&) = delete;
        ResolveWorker &operator=(const ResolveWorker &) = delete;
        ResolveWorker &operator=(ResolveWorker &&) = delete;
        ~ResolveWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ResolveBaton *baton;
    };

    static NAN_METHOD(Resolve);

    struct SetTargetBaton {
      int error_code;
      const git_error* error;
      git_reference * out;
      git_reference * ref;
      const git_oid * id;
      bool idNeedsFree;
      const char * log_message;
     };
    class SetTargetWorker : public nodegit::AsyncWorker {
      public:
        SetTargetWorker(
            SetTargetBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:SetTarget", cleanupHandles)
          , baton(_baton) {};
        SetTargetWorker(const SetTargetWorker &) = delete;
        SetTargetWorker(SetTargetWorker &&) = delete;
        SetTargetWorker &operator=(const SetTargetWorker &) = delete;
        SetTargetWorker &operator=(SetTargetWorker &&) = delete;
        ~SetTargetWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        SetTargetBaton *baton;
    };

    static NAN_METHOD(SetTarget);

    static NAN_METHOD(Shorthand);

    struct SymbolicCreateBaton {
      int error_code;
      const git_error* error;
      git_reference * out;
      git_repository * repo;
      const char * name;
      const char * target;
      int force;
      const char * log_message;
     };
    class SymbolicCreateWorker : public nodegit::AsyncWorker {
      public:
        SymbolicCreateWorker(
            SymbolicCreateBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:SymbolicCreate", cleanupHandles)
          , baton(_baton) {};
        SymbolicCreateWorker(const SymbolicCreateWorker &) = delete;
        SymbolicCreateWorker(SymbolicCreateWorker &&) = delete;
        SymbolicCreateWorker &operator=(const SymbolicCreateWorker &) = delete;
        SymbolicCreateWorker &operator=(SymbolicCreateWorker &&) = delete;
        ~SymbolicCreateWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        SymbolicCreateBaton *baton;
    };

    static NAN_METHOD(SymbolicCreate);

    struct SymbolicCreateMatchingBaton {
      int error_code;
      const git_error* error;
      git_reference * out;
      git_repository * repo;
      const char * name;
      const char * target;
      int force;
      const char * current_value;
      const char * log_message;
     };
    class SymbolicCreateMatchingWorker : public nodegit::AsyncWorker {
      public:
        SymbolicCreateMatchingWorker(
            SymbolicCreateMatchingBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:SymbolicCreateMatching", cleanupHandles)
          , baton(_baton) {};
        SymbolicCreateMatchingWorker(const SymbolicCreateMatchingWorker &) = delete;
        SymbolicCreateMatchingWorker(SymbolicCreateMatchingWorker &&) = delete;
        SymbolicCreateMatchingWorker &operator=(const SymbolicCreateMatchingWorker &) = delete;
        SymbolicCreateMatchingWorker &operator=(SymbolicCreateMatchingWorker &&) = delete;
        ~SymbolicCreateMatchingWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        SymbolicCreateMatchingBaton *baton;
    };

    static NAN_METHOD(SymbolicCreateMatching);

    struct SymbolicSetTargetBaton {
      int error_code;
      const git_error* error;
      git_reference * out;
      git_reference * ref;
      const char * target;
      const char * log_message;
     };
    class SymbolicSetTargetWorker : public nodegit::AsyncWorker {
      public:
        SymbolicSetTargetWorker(
            SymbolicSetTargetBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRefs:SymbolicSetTarget", cleanupHandles)
          , baton(_baton) {};
        SymbolicSetTargetWorker(const SymbolicSetTargetWorker &) = delete;
        SymbolicSetTargetWorker(SymbolicSetTargetWorker &&) = delete;
        SymbolicSetTargetWorker &operator=(const SymbolicSetTargetWorker &) = delete;
        SymbolicSetTargetWorker &operator=(SymbolicSetTargetWorker &&) = delete;
        ~SymbolicSetTargetWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        SymbolicSetTargetBaton *baton;
    };

    static NAN_METHOD(SymbolicSetTarget);

    static NAN_METHOD(SymbolicTarget);

    static NAN_METHOD(Target);

    static NAN_METHOD(TargetPeel);

    static NAN_METHOD(Type);
};

#endif
