Arbiter  0.0.0
driver.hpp
1 #pragma once
2 
3 #include <iostream>
4 #include <map>
5 #include <memory>
6 #include <string>
7 #include <vector>
8 
9 #ifdef ARBITER_CUSTOM_NAMESPACE
10 namespace ARBITER_CUSTOM_NAMESPACE
11 {
12 #endif
13 
14 namespace arbiter
15 {
16 
17 class HttpPool;
18 
34 class Driver
35 {
36 public:
37  virtual ~Driver() { }
38 
47  virtual std::string type() const = 0;
48 
50  std::string get(std::string path) const;
51 
53  std::unique_ptr<std::string> tryGet(std::string path) const;
54 
56  std::vector<char> getBinary(std::string path) const;
57 
59  std::unique_ptr<std::vector<char>> tryGetBinary(std::string path) const;
60 
68  virtual void put(std::string path, const std::vector<char>& data) const = 0;
69 
73  virtual bool isRemote() const { return true; }
74 
76  virtual std::unique_ptr<std::size_t> tryGetSize(std::string path) const = 0;
77 
79  std::size_t getSize(std::string path) const;
80 
82  void put(std::string path, const std::string& data) const;
83 
88  std::vector<std::string> resolve(
89  std::string path,
90  bool verbose = false) const;
91 
92 protected:
109  virtual std::vector<std::string> glob(std::string path, bool verbose) const;
110 
115  virtual bool get(std::string path, std::vector<char>& data) const = 0;
116 };
117 
118 typedef std::map<std::string, std::unique_ptr<Driver>> DriverMap;
119 
120 } // namespace arbiter
121 
122 #ifdef ARBITER_CUSTOM_NAMESPACE
123 }
124 #endif
125 
Base class for interacting with a storage type.
Definition: driver.hpp:34
virtual bool isRemote() const
Definition: driver.hpp:73
Definition: arbiter.cpp:16