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

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

#include "../include/diff.h"
#include "../include/diff_delta.h"
#include "../include/diff_perfdata.h"
#include "../include/repository.h"
#include "../include/tree.h"
#include "../include/diff_options.h"
// Forward declaration.
struct git_diff {
};

using namespace node;
using namespace v8;

class GitDiff : public ObjectWrap {
  public:

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

    git_diff *GetValue();
    git_diff **GetRefValue();

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

  private:
    GitDiff(git_diff *raw, bool selfFreeing);
    ~GitDiff();

    static NAN_METHOD(JSNewFunction);


    static NAN_METHOD(GetDelta);

    struct GetPerfdataBaton {
      int error_code;
      const git_error* error;
      git_diff_perfdata * out;
      const git_diff * diff;
    };
    class GetPerfdataWorker : public NanAsyncWorker {
      public:
        GetPerfdataWorker(
            GetPerfdataBaton *_baton,
            NanCallback *callback
        ) : NanAsyncWorker(callback)
          , baton(_baton) {};
        ~GetPerfdataWorker() {};
        void Execute();
        void HandleOKCallback();

      private:
        GetPerfdataBaton *baton;
    };

    static NAN_METHOD(GetPerfdata);

    static NAN_METHOD(NumDeltas);

    struct TreeToTreeBaton {
      int error_code;
      const git_error* error;
      git_diff * diff;
      git_repository * repo;
      git_tree * old_tree;
      git_tree * new_tree;
      const git_diff_options * opts;
    };
    class TreeToTreeWorker : public NanAsyncWorker {
      public:
        TreeToTreeWorker(
            TreeToTreeBaton *_baton,
            NanCallback *callback
        ) : NanAsyncWorker(callback)
          , baton(_baton) {};
        ~TreeToTreeWorker() {};
        void Execute();
        void HandleOKCallback();

      private:
        TreeToTreeBaton *baton;
    };

    static NAN_METHOD(TreeToTree);
    git_diff *raw;
};

#endif
