sqlite handle: Initial implementation

Note that this commit does not properly implement ChildSelector==1
(rightmost). Currently, this selector just means the max value of
names vector, but it is not right. This is a known issue and is tracked
as part of refs #1433 (http://redmine.named-data.net/issues/1433).

Change-Id: I4d6dfaa5d52a3ab955aefa21d7b330cff7c68be6
diff --git a/storage/storage-handle.hpp b/storage/storage-handle.hpp
new file mode 100644
index 0000000..48359d4
--- /dev/null
+++ b/storage/storage-handle.hpp
@@ -0,0 +1,127 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Regents of the University of California.
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef REPO_STORAGE_STORAGE_HANDLE_HPP
+#define REPO_STORAGE_STORAGE_HANDLE_HPP
+
+#include <string>
+#include <stdexcept>
+
+#include <ndn-cpp-dev/interest.hpp>
+#include <ndn-cpp-dev/name.hpp>
+#include <ndn-cpp-dev/data.hpp>
+#include <ndn-cpp-dev/selectors.hpp>
+#include <ndn-cpp-dev/key-locator.hpp>
+
+#include "storage-method.hpp"
+
+namespace repo {
+
+using ndn::Interest;
+using ndn::Name;
+using ndn::Data;
+using ndn::Selectors;
+using ndn::KeyLocator;
+using ndn::Block;
+using ndn::Exclude;
+
+using std::vector;
+using std::string;
+using boost::noncopyable;
+
+/**   
+ * @brief this class defines handles to read, insert and delete data packets in storage media
+ */
+
+class StorageHandle : noncopyable
+{
+public:
+  class Error : public std::runtime_error
+  {
+  public:
+    explicit
+    Error(const std::string& what)
+      : std::runtime_error(what)
+    {
+    }
+  };
+
+  /**
+   * @brief Create a basic class object the specified storage type
+   */
+  explicit
+  StorageHandle(StorageMethod storageMethod);
+
+  virtual
+  ~StorageHandle();
+
+  /**
+   * @return storage method defined in storage-define.hpp
+   */
+  StorageMethod
+  getStorageMethod() const;
+
+  /**
+   * @brief insert data
+   * @return true on success, false otherwise
+   */
+  virtual bool
+  insertData(const Data& data) = 0;
+
+  /**
+   * @brief delete the data that exactly matches the name
+   * @return true on success, false otherwise
+   * @note It's considered successful if Data doesn't exist.
+   */
+  virtual bool
+  deleteData(const Name& name) = 0;
+
+  /**
+  * @brief find data according to the interest. This interest may contain selectors.
+  * @param[out] data Data matching Interest.
+  * @return true if Data is found, false otherwise
+  */
+  virtual bool
+  readData(const Interest& interest, Data& data) = 0;
+
+  /**
+   * @return if storage media has data packets with this name, return true, else return false
+   */
+  virtual bool
+  hasName(const Name& name) = 0;
+
+  /**
+   * @brief select any data conforms to the selector
+   * @param[out] names Data names matching @p name and @p selectors.
+   * @return true if at least one Data is found, false otherwise
+   */
+  virtual bool
+  readNameAny(const Name& name, const Selectors& selectors, vector<Name>& names) = 0;
+
+private:
+  StorageMethod m_storageMethod;
+};
+
+inline
+StorageHandle::StorageHandle(StorageMethod storageMethod)
+  : m_storageMethod(storageMethod)
+{
+}
+
+inline
+StorageHandle::~StorageHandle()
+{
+}
+
+inline StorageMethod
+StorageHandle::getStorageMethod() const
+{
+  return m_storageMethod;
+}
+
+} // namespace repo
+
+#endif // REPO_STORAGE_STORAGE_HANDLE_HPP