extend file_handler to support reads

Problem: the upcomming version handler will need to read from files.
Currently file hander (image handler) does not support reads.

Solution: Add read support by providing an optional mode parameter.

Tests added:
FileHanderTest added to
- Test out open for reads
- Test out reading out bytes and verifying size and content
- Test out trying to read beyond EOF
- Test out offset reads that go beyond EOF

Tested:
Existing unit tests pass
New unit tests for reading all pass

Signed-off-by: Jason Ling <jasonling@google.com>
Change-Id: Ie416a6b4b452d8d04fa158bd55989d07a891896f
diff --git a/bmc/image_handler.hpp b/bmc/image_handler.hpp
index c024ec9..4d5b475 100644
--- a/bmc/image_handler.hpp
+++ b/bmc/image_handler.hpp
@@ -3,6 +3,7 @@
 #include <cstdint>
 #include <fstream>
 #include <memory>
+#include <optional>
 #include <string>
 #include <vector>
 
@@ -23,7 +24,8 @@
      * @param[in] path - the path passed to the handler (the blob_id).
      * @return bool - returns true on success.
      */
-    virtual bool open(const std::string& path) = 0;
+    virtual bool open(const std::string& path,
+                      std::ios_base::openmode mode) = 0;
 
     /**
      * close the image.
@@ -39,6 +41,17 @@
      */
     virtual bool write(std::uint32_t offset,
                        const std::vector<std::uint8_t>& data) = 0;
+    /**
+     * read data from a file.
+     *
+     * @param[in] offset - 0-based offset into the file.
+     * @param[in] size - the number of bytes
+     * @return std::optional<std::vector<std::uint8_t>> - returns std::nullopt
+     * on failure otherwise returns a vector filled with the bytes read.
+     *
+     */
+    virtual std::optional<std::vector<std::uint8_t>>
+        read(std::uint32_t offset, std::uint32_t size) = 0;
 
     /**
      * return the size of the file (if that notion makes sense).