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

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

#include "../include/time.h"
#include "../include/signature.h"
#include "../include/repository.h"

using namespace node;
using namespace v8;

class GitSignature : public ObjectWrap {
public:

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

  git_signature *GetValue();
  git_signature **GetRefValue();

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

private:
  GitSignature(git_signature *raw, bool selfFreeing);
  ~GitSignature();

  static NAN_METHOD(JSNewFunction);

  static NAN_METHOD(Name);
  static NAN_METHOD(Email);
  static NAN_METHOD(When);

  static NAN_METHOD(Default);

  struct DupBaton {
    int error_code;
    const git_error* error;
    git_signature * dest;
    const git_signature * sig;
  };
  class DupWorker : public NanAsyncWorker {
  public:
    DupWorker(
      DupBaton *_baton,
      NanCallback *callback
    ) : NanAsyncWorker(callback)
      , baton(_baton) {};
    ~DupWorker() {};
    void Execute();
    void HandleOKCallback();

  private:
    DupBaton *baton;
  };

  static NAN_METHOD(Dup);

  static NAN_METHOD(Create);

  static NAN_METHOD(Now);
  git_signature *raw;
};

#endif
