#ifndef OBJECT_DB_FILE_H
#define OBJECT_DB_FILE_H

#include "object-db.h"
#include <stdio.h>
#include <fstream>
#include <ifstream>
#include <ofstream>
#include <sstream>
#include <deque>
#include <boost/thread/locks.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/interprocess/sync/sharable_lock.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>

#define _OVERRIDE
#ifdef __GNUC__
#if __GNUC_MAJOR >= 4 && __GNUC_MINOR__ >= 7
  #undef _OVERRIDE
  #define _OVERRIDE override
#endif // __GNUC__ version
#endif // __GNUC__

using namespace std;

// This is a file based ObjectDB implementation
// The assumption is, the Content Objects will be stored sequentially

// To provide random access, we will have a table of "address" for each
// ContentObject at the beginning of the file.
// This also requires another assumption, that is the number of COs must
// be know a priori. This requirement is reasonable for our dropbox-like
// System, as the file we publish is static file and we can easily know
// the number of COs before we store them into ObjectDB.

/* How file looks like:
 * |MAGIC_NUM|capacity|size|pos for each CO ...|1st CO|2nd CO| ... |
 */

class ObjectDBFile
{
public:
  typedef boost::interprocess::file_lock Filelock;
  typedef boost::interprocess::scoped_lock<Filelock> WriteLock;
  typedef boost::interprocess::sharable_lock<Filelock> ReadLock;

  ObjectDBFile(const string &filename);
  virtual ~ObjectDBFile(){}

  // reserve the "address" table for n COs; must reserve before
  // write anything (unless reserved quota has not be consumed yet)
  void
  init(int capacity);

  bool
  initialized() const { return m_initialized; }

  // assume sequential
  virtual void
  append(const Bytes &co) _OVERRIDE;

  // get next CO
  virtual Bytes
  next() _OVERRIDE;

  // size in terms of number of COs
  // This is the lazy form of size, i.e. it returns the size cached in this object
  // but that may not necessarily equal to the actual size kept in file
  // This is enough if the caller knows for sure that no other thread is changing the
  // file or the caller does not care about the new size.
  virtual int
  size() const _OVERRIDE;

  // this returns the actual size (also update the size cache in this object), but it is more costly, and requires file IO
  int
  fSize();

  // the index of the CO to be read
  int
  index();

  // set the pos to be the desired CO
  // return true if success
  bool
  seek(int index);

  // reset pos to be zero
  void
  rewind();

protected:
  // read or write lock should have been grabbed already before the call
  void
  checkInit(const string &msg);

  // read lock should have been grabbed already before the call
  void
  updateSize();

  // read lock should have been grabbed already before the call
  void
  fillDummyCache();

  #define MAGIC_NUM 0xAAAAAAAA

protected:
  string m_filename;
  ifstream m_istream;
  ofstream m_ostream;
  Filelock m_filelock;
  bool m_initialized;
  // capacity in terms of number of COs
  int m_cap;
  int m_size;
  // the index (or seq) of the CO to be read
  int m_index;

  // A dummy Cache that holds the next 10 (or all remaining if less than 10)
  // COs after a next() operation
  // If needed and time allows, we can have more complex cache
  #define CACHE_SIZE 10
  map<int, Bytes> m_dummyCache;
};

void inline
writeInt(ostream &out, const int &x)
{
  out.write((const char *)&x, sizeof(int));
}

void inline
readInt(istream &in, int &x)
{
  in.read((char *)&x, sizeof(int));
}

// write size and then the actual bytes
// operator << overloading is not used to avoid confusion
void
writeBytes(ostream &out, const Bytes &bytes);

// read size and then the actual bytes
void
readBytes(istream &in, Bytes &bytes);

#endif
