Instead of transforming between return value and callback, pass the wrapped callback on to the invoked function as the last argument. This eliminates the need for multiple invokeWithArgument overloads and permits invoked functions to be asynchronous.
42 lines
921 B
C++
42 lines
921 B
C++
#ifndef MBGL_STORAGE_DEFAULT_SQLITE_CACHE_IMPL
|
|
#define MBGL_STORAGE_DEFAULT_SQLITE_CACHE_IMPL
|
|
|
|
#include <mbgl/storage/sqlite_cache.hpp>
|
|
|
|
typedef struct uv_loop_s uv_loop_t;
|
|
|
|
namespace mapbox {
|
|
namespace sqlite {
|
|
class Database;
|
|
class Statement;
|
|
}
|
|
}
|
|
|
|
namespace mbgl {
|
|
|
|
class SQLiteCache::Impl {
|
|
public:
|
|
Impl(uv_loop_t*, const std::string &path = ":memory:");
|
|
~Impl();
|
|
|
|
void get(const Resource&, Callback);
|
|
void put(const Resource& resource, std::shared_ptr<const Response> response);
|
|
void refresh(const Resource& resource, int64_t expires);
|
|
|
|
private:
|
|
void createDatabase();
|
|
void createSchema();
|
|
|
|
const std::string path;
|
|
std::unique_ptr<::mapbox::sqlite::Database> db;
|
|
std::unique_ptr<::mapbox::sqlite::Statement> getStmt;
|
|
std::unique_ptr<::mapbox::sqlite::Statement> putStmt;
|
|
std::unique_ptr<::mapbox::sqlite::Statement> refreshStmt;
|
|
bool schema = false;
|
|
};
|
|
|
|
|
|
}
|
|
|
|
#endif
|