#ifndef GITREVWALK_H
#define GITREVWALK_H

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

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

#include "../include/revwalk.h"
#include "../include/repository.h"
#include "../include/oid.h"


using namespace node;
using namespace v8;

class GitRevwalk : public ObjectWrap {
  public:

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

        git_revwalk *GetValue();

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

    
                  
    static NAN_METHOD(CreateRevwalk);
                        
    static NAN_METHOD(Push);
                        
    static NAN_METHOD(Hide);
                        
    struct NextBaton {
      int error_code;
      const git_error* error;
                    git_oid * out;
                            git_revwalk * walk;
                  };
    class NextWorker : public NanAsyncWorker {
      public:
        NextWorker(
            NextBaton *_baton,
            NanCallback *callback
        ) : NanAsyncWorker(callback)
          , baton(_baton) {};
        ~NextWorker() {};
        void Execute();
        void HandleOKCallback();

      private:
        NextBaton *baton;
    };
        
    static NAN_METHOD(Next);
                        
    static NAN_METHOD(Sorting);
                        
    static NAN_METHOD(SimplifyFirstParent);
          
        git_revwalk *raw;
    };

#endif
