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

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

#include "../include/submodule.h"
#include "../include/repository.h"
#include "../include/oid.h"
// Forward declaration.
struct git_submodule {
};

using namespace node;
using namespace v8;

class GitSubmodule : public ObjectWrap {
public:

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

  git_submodule *GetValue();
  git_submodule **GetRefValue();

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

private:
  GitSubmodule(git_submodule *raw, bool selfFreeing);
  ~GitSubmodule();

  static NAN_METHOD(JSNewFunction);


  static NAN_METHOD(AddFinalize);

  struct AddSetupBaton {
    int error_code;
    const git_error* error;
    git_submodule * out;
    git_repository * repo;
    const char * url;
    const char * path;
    int use_gitlink;
  };
  class AddSetupWorker : public NanAsyncWorker {
  public:
    AddSetupWorker(
      AddSetupBaton *_baton,
      NanCallback *callback
    ) : NanAsyncWorker(callback)
      , baton(_baton) {};
    ~AddSetupWorker() {};
    void Execute();
    void HandleOKCallback();

  private:
    AddSetupBaton *baton;
  };

  static NAN_METHOD(AddSetup);

  static NAN_METHOD(AddToIndex);

  static NAN_METHOD(Branch);

  static NAN_METHOD(FetchRecurseSubmodules);

  static NAN_METHOD(HeadId);

  static NAN_METHOD(Ignore);

  static NAN_METHOD(IndexId);

  static NAN_METHOD(Init);

  struct LookupBaton {
    int error_code;
    const git_error* error;
    git_submodule * 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(Name);

  static NAN_METHOD(Open);

  static NAN_METHOD(Owner);

  static NAN_METHOD(Path);

  static NAN_METHOD(Reload);

  static NAN_METHOD(ReloadAll);

  static NAN_METHOD(Save);

  static NAN_METHOD(SetFetchRecurseSubmodules);

  static NAN_METHOD(SetIgnore);

  static NAN_METHOD(SetUpdate);

  static NAN_METHOD(SetUrl);

  static NAN_METHOD(Sync);

  static NAN_METHOD(Update);

  static NAN_METHOD(Url);

  static NAN_METHOD(WdId);
  git_submodule *raw;
};

#endif
