summaryrefslogtreecommitdiff
path: root/platform/android/src/style/sources/source.hpp
blob: 0785e4d4e08d138d389ff91849cb87d45a827cc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once

#include <mbgl/util/noncopyable.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/style/source.hpp>

#include "../value.hpp"

#include <jni/jni.hpp>

namespace mbgl {
namespace android {

class Source : private mbgl::util::noncopyable {
public:

    static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/sources/Source"; };

    static jni::Class<Source> javaClass;

    static void registerNative(jni::JNIEnv&);

    /*
     * Called when a Java object is created on the c++ side
     */
    Source(mbgl::Map&, mbgl::style::Source&);

    /*
     * Called when a Java object was created from the jvm side
     */
    Source(jni::JNIEnv&, std::unique_ptr<mbgl::style::Source>);

    virtual ~Source();

    virtual jni::jobject* createJavaPeer(jni::JNIEnv&) = 0;

    jni::String getId(jni::JNIEnv&);

    //Release the owned view and return it
    std::unique_ptr<mbgl::style::Source> releaseCoreSource();

protected:
    std::unique_ptr<mbgl::style::Source> ownedSource;
    mbgl::style::Source& source;
    mbgl::Map* map;
};

} //android
} //mbgl