#ifndef GITNOTE_H
#define GITNOTE_H
// generated from class_header.h
#include <nan.h>
#include <string>

extern "C" {
#include <git2.h>
}

#include "../include/oid.h"
#include "../include/repository.h"
#include "../include/signature.h"
#include "../include/note.h"
#include "../include/note_iterator.h"
// Forward declaration.
struct git_note {
};

using namespace node;
using namespace v8;

class GitNote : public ObjectWrap {
public:

  static Persistent<Function> constructor_template;
  static void InitializeComponent (Handle<v8::Object> target);

  git_note *GetValue();
  git_note **GetRefValue();

  static Handle<Value> New(void *raw, bool selfFreeing);
  bool selfFreeing;

private:
  GitNote(git_note *raw, bool selfFreeing);
  ~GitNote();

  static NAN_METHOD(JSNewFunction);


  struct CreateBaton {
    int error_code;
    const git_error* error;
    git_oid * out;
    git_repository * repo;
    const git_signature * author;
    const git_signature * committer;
    const char * notes_ref;
    const git_oid * oid;
    bool oidNeedsFree;
    const char * note;
    int force;
  };
  class CreateWorker : public NanAsyncWorker {
  public:
    CreateWorker(
      CreateBaton *_baton,
      NanCallback *callback
    ) : NanAsyncWorker(callback)
      , baton(_baton) {};
    ~CreateWorker() {};
    void Execute();
    void HandleOKCallback();

  private:
    CreateBaton *baton;
  };

  static NAN_METHOD(Create);

  struct DefaultRefBaton {
    int error_code;
    const git_error* error;
    const char * out;
    git_repository * repo;
  };
  class DefaultRefWorker : public NanAsyncWorker {
  public:
    DefaultRefWorker(
      DefaultRefBaton *_baton,
      NanCallback *callback
    ) : NanAsyncWorker(callback)
      , baton(_baton) {};
    ~DefaultRefWorker() {};
    void Execute();
    void HandleOKCallback();

  private:
    DefaultRefBaton *baton;
  };

  static NAN_METHOD(DefaultRef);

  static NAN_METHOD(Id);

  static NAN_METHOD(IteratorFree);

  struct IteratorNewBaton {
    int error_code;
    const git_error* error;
    git_note_iterator * out;
    git_repository * repo;
    const char * notes_ref;
  };
  class IteratorNewWorker : public NanAsyncWorker {
  public:
    IteratorNewWorker(
      IteratorNewBaton *_baton,
      NanCallback *callback
    ) : NanAsyncWorker(callback)
      , baton(_baton) {};
    ~IteratorNewWorker() {};
    void Execute();
    void HandleOKCallback();

  private:
    IteratorNewBaton *baton;
  };

  static NAN_METHOD(IteratorNew);

  static NAN_METHOD(Message);

  static NAN_METHOD(Next);

  struct ReadBaton {
    int error_code;
    const git_error* error;
    git_note * out;
    git_repository * repo;
    const char * notes_ref;
    const git_oid * oid;
    bool oidNeedsFree;
  };
  class ReadWorker : public NanAsyncWorker {
  public:
    ReadWorker(
      ReadBaton *_baton,
      NanCallback *callback
    ) : NanAsyncWorker(callback)
      , baton(_baton) {};
    ~ReadWorker() {};
    void Execute();
    void HandleOKCallback();

  private:
    ReadBaton *baton;
  };

  static NAN_METHOD(Read);

  static NAN_METHOD(Remove);
  git_note *raw;
};

#endif
