#ifndef GITREFS_H
#define GITREFS_H

#include <nan.h>
#include <string>

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

#include "../include/repository.h"
#include "../include/oid.h"
#include "../include/strarray.h"
#include "../include/object.h"


using namespace node;
using namespace v8;

class GitRefs : public ObjectWrap {
  public:

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

        git_reference *GetValue();

    static Handle<Value> New(void *raw);
    
  private:
        GitRefs(git_reference *raw);
    ~GitRefs();
    
    static NAN_METHOD(New);

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

      private:
        LookupBaton *baton;
    };
        
    static NAN_METHOD(Lookup);
                        
    static NAN_METHOD(Target);
                        
    static NAN_METHOD(Type);
          
        git_reference *raw;
    };

#endif
