#ifndef DISKBLOBINDEX_H
#define DISKBLOBINDEX_H

#include "persifs.h"
#include "blobindex.h"
#include "superblob.h"
#include "bplustree.h"


class diskBlobIndex : public blobIndex
{
public:
  static void create(str filename,
                     callback<void, ref<diskBlobIndex> >::ref cb,
                     cbe error);

  virtual void get(blockFingerprint fp,
                   callback<void, blockAddress>::ref cb,
                   cbe error);

  virtual void put(blockFingerprint fp, blockAddress addr,
           callback<void>::ref cb, cbe error);

  virtual ~diskBlobIndex();
  
protected:
  ref<BPlusTree<blockFingerprint, blockAddress> > entries;
  
  diskBlobIndex(ref<BPlusTree<blockFingerprint, blockAddress> > bpt);
  static void create_after_bptreeCreate(
    callback<void, ref<diskBlobIndex> >::ref cb,
    cbe error,
    ref<BPlusTree<blockFingerprint, blockAddress> > bpt);
  
  void get_after_search(blockFingerprint fp,
                        callback<void, blockAddress>::ref cb,
                        cbe error,
                        blockFingerprint k, blockAddress v);
  void get_after_error(blockFingerprint fp,
                       callback<void, blockAddress>::ref cb,
                       cbe error, pStat stat);
};

#endif // DISKBLOBINDEX_H
