#include "tagged_blockdbc.h"

#define DELIM ":"

tagged_blockdbc::tagged_blockdbc(struct sockaddr_in sin, str fsid) 
{
   this->fsid = fsid;
   bdb = New blockdbc(sin);
}


tagged_blockdbc::~tagged_blockdbc() 
{
   delete bdb;
}


void tagged_blockdbc::put(str type, str key, str value,
                          callback<void, bool>::ref cb) 
{
   bdb->put(make_real_key(type, key), value, cb);
}


void tagged_blockdbc::get(str type, str key,
                          callback<void, bool, str>::ref cb) 
{
   bdb->get(make_real_key(type, key), cb);
}


void tagged_blockdbc::remove(str type, str key,
                             callback<void, bool>::ref cb)
{
   bdb->remove(make_real_key(type, key), cb);
}


void tagged_blockdbc::flush(str type, str key,
                            callback<void>::ref cb)
{
   bdb->flush(make_real_key(type, key), cb);
}


str tagged_blockdbc::make_real_key(str type, str key)
{
   strbuf buf;

   buf << fsid << DELIM;
   buf << type << DELIM;
   buf << key;

   return buf;
}

