initial version with updated build system
This commit is contained in:
49
src/node_file_source.hpp
Normal file
49
src/node_file_source.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/storage/file_source.hpp>
|
||||
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace mbgl { namespace util { template <typename T> class AsyncQueue; } }
|
||||
|
||||
namespace node_mbgl {
|
||||
|
||||
class NodeFileSource : public node::ObjectWrap, public mbgl::FileSource {
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Static Node Methods
|
||||
public:
|
||||
static void Init(v8::Handle<v8::Object> target);
|
||||
static NAN_METHOD(New);
|
||||
|
||||
static v8::Persistent<v8::FunctionTemplate> constructorTemplate;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Instance
|
||||
public:
|
||||
NodeFileSource();
|
||||
~NodeFileSource();
|
||||
|
||||
mbgl::Request *request(const mbgl::Resource &resource, uv_loop_t *loop, Callback callback);
|
||||
void request(const mbgl::Resource &resource, Callback callback);
|
||||
void cancel(mbgl::Request *request);
|
||||
|
||||
|
||||
// visiblity?
|
||||
void notify(mbgl::Request *request, const std::shared_ptr<const mbgl::Response> &response);
|
||||
|
||||
private:
|
||||
struct Action;
|
||||
using Queue = mbgl::util::AsyncQueue<Action>;
|
||||
|
||||
void processAdd(mbgl::Request *request);
|
||||
void processCancel(mbgl::Request *request);
|
||||
|
||||
private:
|
||||
std::map<mbgl::Request *, v8::Persistent<v8::Object>> pending;
|
||||
Queue *queue = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user