splits objects into separate headers

The binarystore.(c|h)pp now contains BinaryStore, while
binarystore_interface contains BinaryStoreInterface.

The sys_file.hpp contains SysFile, while sys_file_impl.(c|h)pp contains
SysFileImpl.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ic65792a59809e05e186f7710a27ad6bd0e298c94
diff --git a/sys_file_impl.hpp b/sys_file_impl.hpp
new file mode 100644
index 0000000..c74c965
--- /dev/null
+++ b/sys_file_impl.hpp
@@ -0,0 +1,43 @@
+#pragma once
+
+#include "sys.hpp"
+#include "sys_file.hpp"
+
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <string>
+
+namespace binstore
+{
+
+class SysFileImpl : public SysFile
+{
+  public:
+    /**
+     * @brief Constructs sysFile specified by path and offset
+     * @param path The file path
+     * @param offset The byte offset relatively. Reading a sysfile at position 0
+     *     actually reads underlying file at 'offset'
+     * @param sys Syscall operation interface
+     */
+    explicit SysFileImpl(const std::string& path, size_t offset = 0,
+                         const internal::Sys* sys = &internal::sys_impl);
+    ~SysFileImpl();
+    SysFileImpl() = delete;
+    SysFileImpl(const SysFileImpl&) = delete;
+    SysFileImpl& operator=(SysFileImpl) = delete;
+
+    size_t readToBuf(size_t pos, size_t count, char* buf) const override;
+    std::string readAsStr(size_t pos, size_t count) const override;
+    std::string readRemainingAsStr(size_t pos) const override;
+    void writeStr(const std::string& data, size_t pos) override;
+
+  private:
+    int fd_;
+    size_t offset_;
+    void lseek(size_t pos) const;
+    const internal::Sys* sys;
+};
+
+} // namespace binstore