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

#ifndef GITCOMMIT_H
#define GITCOMMIT_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/oid.h"
#include "../include/signature.h"
#include "../include/tree.h"
#include "../include/mailmap.h"
#include "../include/repository.h"
#include "../include/buf.h"
// Forward declaration.
struct git_commit {
};

using namespace node;
using namespace v8;

class GitCommit;

struct GitCommitTraits {
  typedef GitCommit cppClass;
  typedef git_commit cType;

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

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

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

                                                                                                                                                     

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

    struct AmendBaton {
      int error_code;
      const git_error* error;
      git_oid * id;
      const git_commit * commit_to_amend;
      const char * update_ref;
      const git_signature * author;
      const git_signature * committer;
      const char * message_encoding;
      const char * message;
      const git_tree * tree;
    };
    class AmendWorker : public nodegit::AsyncWorker {
      public:
        AmendWorker(
            AmendBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:Amend")
          , baton(_baton) {};
        ~AmendWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        AmendBaton *baton;
    };

    static NAN_METHOD(Amend);

    static NAN_METHOD(Author);

    struct AuthorWithMailmapBaton {
      int error_code;
      const git_error* error;
      git_signature * out;
      const git_commit * commit;
      const git_mailmap * mailmap;
    };
    class AuthorWithMailmapWorker : public nodegit::AsyncWorker {
      public:
        AuthorWithMailmapWorker(
            AuthorWithMailmapBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:AuthorWithMailmap")
          , baton(_baton) {};
        ~AuthorWithMailmapWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        AuthorWithMailmapBaton *baton;
    };

    static NAN_METHOD(AuthorWithMailmap);

    static NAN_METHOD(Body);

    static NAN_METHOD(Committer);

    struct CommitterWithMailmapBaton {
      int error_code;
      const git_error* error;
      git_signature * out;
      const git_commit * commit;
      const git_mailmap * mailmap;
    };
    class CommitterWithMailmapWorker : public nodegit::AsyncWorker {
      public:
        CommitterWithMailmapWorker(
            CommitterWithMailmapBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:CommitterWithMailmap")
          , baton(_baton) {};
        ~CommitterWithMailmapWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        CommitterWithMailmapBaton *baton;
    };

    static NAN_METHOD(CommitterWithMailmap);

    struct CreateBaton {
      int error_code;
      const git_error* error;
      git_oid * id;
      git_repository * repo;
      const char * update_ref;
      const git_signature * author;
      const git_signature * committer;
      const char * message_encoding;
      const char * message;
      const git_tree * tree;
      size_t parent_count;
      const git_commit ** parents;
    };
    class CreateWorker : public nodegit::AsyncWorker {
      public:
        CreateWorker(
            CreateBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:Create")
          , baton(_baton) {};
        ~CreateWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        CreateBaton *baton;
    };

    static NAN_METHOD(Create);

    struct CreateBufferBaton {
      int error_code;
      const git_error* error;
      git_buf * out;
      git_repository * repo;
      const git_signature * author;
      const git_signature * committer;
      const char * message_encoding;
      const char * message;
      const git_tree * tree;
      size_t parent_count;
      const git_commit ** parents;
    };
    class CreateBufferWorker : public nodegit::AsyncWorker {
      public:
        CreateBufferWorker(
            CreateBufferBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:CreateBuffer")
          , baton(_baton) {};
        ~CreateBufferWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        CreateBufferBaton *baton;
    };

    static NAN_METHOD(CreateBuffer);

    static NAN_METHOD(CreateV);

    struct CreateWithSignatureBaton {
      int error_code;
      const git_error* error;
      git_oid * out;
      git_repository * repo;
      const char * commit_content;
      const char * signature;
      const char * signature_field;
    };
    class CreateWithSignatureWorker : public nodegit::AsyncWorker {
      public:
        CreateWithSignatureWorker(
            CreateWithSignatureBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:CreateWithSignature")
          , baton(_baton) {};
        ~CreateWithSignatureWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        CreateWithSignatureBaton *baton;
    };

    static NAN_METHOD(CreateWithSignature);

    struct DupBaton {
      int error_code;
      const git_error* error;
      git_commit * out;
      git_commit * source;
    };
    class DupWorker : public nodegit::AsyncWorker {
      public:
        DupWorker(
            DupBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:Dup")
          , baton(_baton) {};
        ~DupWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        DupBaton *baton;
    };

    static NAN_METHOD(Dup);

    struct ExtractSignatureBaton {
      int error_code;
      const git_error* error;
      git_buf signature;
      git_buf signed_data;
      git_repository * repo;
      git_oid * commit_id;
      bool commit_idNeedsFree;
      char * field;
    };
    class ExtractSignatureWorker : public nodegit::AsyncWorker {
      public:
        ExtractSignatureWorker(
            ExtractSignatureBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:ExtractSignature")
          , baton(_baton) {};
        ~ExtractSignatureWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ExtractSignatureBaton *baton;
    };

    static NAN_METHOD(ExtractSignature);

    struct HeaderFieldBaton {
      int error_code;
      const git_error* error;
      git_buf * out;
      const git_commit * commit;
      const char * field;
    };
    class HeaderFieldWorker : public nodegit::AsyncWorker {
      public:
        HeaderFieldWorker(
            HeaderFieldBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:HeaderField")
          , baton(_baton) {};
        ~HeaderFieldWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        HeaderFieldBaton *baton;
    };

    static NAN_METHOD(HeaderField);

    static NAN_METHOD(Id);

    struct LookupBaton {
      int error_code;
      const git_error* error;
      git_commit * commit;
      git_repository * repo;
      const git_oid * id;
      bool idNeedsFree;
    };
    class LookupWorker : public nodegit::AsyncWorker {
      public:
        LookupWorker(
            LookupBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:Lookup")
          , baton(_baton) {};
        ~LookupWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        LookupBaton *baton;
    };

    static NAN_METHOD(Lookup);

    struct LookupPrefixBaton {
      int error_code;
      const git_error* error;
      git_commit * commit;
      git_repository * repo;
      const git_oid * id;
      bool idNeedsFree;
      size_t len;
    };
    class LookupPrefixWorker : public nodegit::AsyncWorker {
      public:
        LookupPrefixWorker(
            LookupPrefixBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:LookupPrefix")
          , baton(_baton) {};
        ~LookupPrefixWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        LookupPrefixBaton *baton;
    };

    static NAN_METHOD(LookupPrefix);

    static NAN_METHOD(Message);

    static NAN_METHOD(MessageEncoding);

    static NAN_METHOD(MessageRaw);

    struct NthGenAncestorBaton {
      int error_code;
      const git_error* error;
      git_commit * ancestor;
      const git_commit * commit;
      unsigned int n;
    };
    class NthGenAncestorWorker : public nodegit::AsyncWorker {
      public:
        NthGenAncestorWorker(
            NthGenAncestorBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:NthGenAncestor")
          , baton(_baton) {};
        ~NthGenAncestorWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        NthGenAncestorBaton *baton;
    };

    static NAN_METHOD(NthGenAncestor);

    static NAN_METHOD(Owner);

    struct ParentBaton {
      int error_code;
      const git_error* error;
      git_commit * out;
      const git_commit * commit;
      unsigned int n;
    };
    class ParentWorker : public nodegit::AsyncWorker {
      public:
        ParentWorker(
            ParentBaton *_baton,
            Nan::Callback *callback
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitCommit:Parent")
          , baton(_baton) {};
        ~ParentWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ParentBaton *baton;
    };

    static NAN_METHOD(Parent);

    static NAN_METHOD(ParentId);

    static NAN_METHOD(Parentcount);

    static NAN_METHOD(RawHeader);

    static NAN_METHOD(Summary);

    static NAN_METHOD(Time);

    static NAN_METHOD(TimeOffset);

    static NAN_METHOD(Tree);

    static NAN_METHOD(TreeId);
};

#endif
