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

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

#include "../include/filter_list.h"
#include "../include/repository.h"
#include "../include/filter.h"

using namespace node;
using namespace v8;

class GitFilter : public ObjectWrap {
  public:

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

    git_filter *GetValue();
    git_filter **GetRefValue();

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

  private:
    GitFilter(git_filter *raw, bool selfFreeing);
    ~GitFilter();

    static NAN_METHOD(JSNewFunction);

    static NAN_METHOD(Version);
    static NAN_METHOD(Attributes);

    static NAN_METHOD(ListLength);

    struct ListNewBaton {
      int error_code;
      const git_error* error;
      git_filter_list * out;
      git_repository * repo;
      git_filter_mode_t mode;
      uint32_t options;
    };
    class ListNewWorker : public NanAsyncWorker {
      public:
        ListNewWorker(
            ListNewBaton *_baton,
            NanCallback *callback
        ) : NanAsyncWorker(callback)
          , baton(_baton) {};
        ~ListNewWorker() {};
        void Execute();
        void HandleOKCallback();

      private:
        ListNewBaton *baton;
    };

    static NAN_METHOD(ListNew);

    static NAN_METHOD(Lookup);

    static NAN_METHOD(Register);

    static NAN_METHOD(Unregister);
    git_filter *raw;
};

#endif
