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

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

#include "../include/refdb.h"
#include "../include/repository.h"
// Forward declaration.
struct git_refdb {
};

using namespace node;
using namespace v8;

class GitRefdb : public ObjectWrap {
  public:

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

    git_refdb *GetValue();
    git_refdb **GetRefValue();

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

  private:
    GitRefdb(git_refdb *raw, bool selfFreeing);
    ~GitRefdb();

    static NAN_METHOD(JSNewFunction);


    static NAN_METHOD(Compress);

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

      private:
        OpenBaton *baton;
    };

    static NAN_METHOD(Open);
    git_refdb *raw;
};

#endif
