Initial stuff for sqllite version of object-db. Changing to boost::filesystem
diff --git a/src/object-db.h b/src/object-db.h
index 8c31418..9e824de 100644
--- a/src/object-db.h
+++ b/src/object-db.h
@@ -1,42 +1,51 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ * Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ */
+
#ifndef OBJECT_DB_H
#define OBJECT_DB_H
-#include <boost/exception/all.hpp>
-#include <vector>
+#include <string>
+#include <sqlite3.h>
+#include <ccnx-common.h>
+#include <ccnx-name.h>
+#include <boost/filesystem.hpp>
-using namespace std;
-
-struct ObjectDBException : virtual boost::exception, virtual exception { };
-typedef boost::error_info<struct tag_errmsg, std::string> error_info_str;
-
-inline void throwException(const string &msg) { boost::throw_exception(ObjectDBException() << error_info_str(msg)); }
-
-typedef unsigned char Byte;
-typedef vector<Byte> Bytes;
-
-// OK. This name is a bit miss-leading, but this ObjectDB is really some storage
-// that stores the Ccnx ContentObjects of a file. So unlike a normal database,
-// this DB is per file.
-
-// The assumption is, the ContentObjects will be write to ObjectDB sequentially
-// This guarantees that when read, the Nth ContentObject read has the sequence number N as the last component of its name
-class ObjectDB
+class ObjectDb
{
public:
- virtual ~ObjectDB(){}
+ // database will be create in <folder>/<first-pair-of-hash-bytes>/<rest-of-hash>
+ ObjectDb (const boost::filesystem::path &folder, const std::string &hash);
+ ~ObjectDb ();
- // assume sequential
- virtual void
- append(const Bytes &co) = 0;
+ void
+ saveContentObject (const Ccnx::Name &deviceName, sqlite3_int64 segment, const Ccnx::Bytes &data);
- // get next CO
- virtual Bytes
- next() = 0;
+ Ccnx::BytesPtr
+ fetchSegment (const Ccnx::Name &deviceName, sqlite3_int64 segment);
- // size in terms of number of COs
- virtual int
- size() = 0;
-
+ // sqlite3_int64
+ // getNumberOfSegments (const Ccnx::Name &deviceName);
+
+private:
+ sqlite3 *m_db;
};
-#endif
+#endif // OBJECT_DB_H