diff --git a/bridging/android/java/io/openmobilemaps/mapscore/shared/map/IndexedLayerInterface.kt b/bridging/android/java/io/openmobilemaps/mapscore/shared/map/IndexedLayerInterface.kt new file mode 100644 index 000000000..faa46faad --- /dev/null +++ b/bridging/android/java/io/openmobilemaps/mapscore/shared/map/IndexedLayerInterface.kt @@ -0,0 +1,42 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file was generated by Djinni from core.djinni + +package io.openmobilemaps.mapscore.shared.map + +import com.snapchat.djinni.NativeObjectManager +import java.util.concurrent.atomic.AtomicBoolean + +abstract class IndexedLayerInterface { + + abstract fun getLayerInterface(): LayerInterface + + abstract fun getIndex(): Int + + private class CppProxy : IndexedLayerInterface { + private val nativeRef: Long + private val destroyed: AtomicBoolean = AtomicBoolean(false) + + private constructor(nativeRef: Long) { + if (nativeRef == 0L) error("nativeRef is zero") + this.nativeRef = nativeRef + NativeObjectManager.register(this, nativeRef) + } + + companion object { + @JvmStatic + external fun nativeDestroy(nativeRef: Long) + } + + override fun getLayerInterface(): LayerInterface { + assert(!this.destroyed.get()) { error("trying to use a destroyed object") } + return native_getLayerInterface(this.nativeRef) + } + private external fun native_getLayerInterface(_nativeRef: Long): LayerInterface + + override fun getIndex(): Int { + assert(!this.destroyed.get()) { error("trying to use a destroyed object") } + return native_getIndex(this.nativeRef) + } + private external fun native_getIndex(_nativeRef: Long): Int + } +} diff --git a/bridging/android/java/io/openmobilemaps/mapscore/shared/map/MapInterface.kt b/bridging/android/java/io/openmobilemaps/mapscore/shared/map/MapInterface.kt index 42ea04f13..3b42106de 100644 --- a/bridging/android/java/io/openmobilemaps/mapscore/shared/map/MapInterface.kt +++ b/bridging/android/java/io/openmobilemaps/mapscore/shared/map/MapInterface.kt @@ -40,6 +40,8 @@ abstract class MapInterface { abstract fun getLayers(): ArrayList + abstract fun getLayersIndexed(): ArrayList + abstract fun addLayer(layer: LayerInterface) abstract fun insertLayerAt(layer: LayerInterface, atIndex: Int) @@ -162,6 +164,12 @@ abstract class MapInterface { } private external fun native_getLayers(_nativeRef: Long): ArrayList + override fun getLayersIndexed(): ArrayList { + assert(!this.destroyed.get()) { error("trying to use a destroyed object") } + return native_getLayersIndexed(this.nativeRef) + } + private external fun native_getLayersIndexed(_nativeRef: Long): ArrayList + override fun addLayer(layer: LayerInterface) { assert(!this.destroyed.get()) { error("trying to use a destroyed object") } native_addLayer(this.nativeRef, layer) diff --git a/bridging/android/jni/map/NativeIndexedLayerInterface.cpp b/bridging/android/jni/map/NativeIndexedLayerInterface.cpp new file mode 100644 index 000000000..ce9d509e5 --- /dev/null +++ b/bridging/android/jni/map/NativeIndexedLayerInterface.cpp @@ -0,0 +1,60 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file was generated by Djinni from core.djinni + +#include "NativeIndexedLayerInterface.h" // my header +#include "Marshal.hpp" +#include "NativeLayerInterface.h" + +namespace djinni_generated { + +NativeIndexedLayerInterface::NativeIndexedLayerInterface() : ::djinni::JniInterface<::IndexedLayerInterface, NativeIndexedLayerInterface>("io/openmobilemaps/mapscore/shared/map/IndexedLayerInterface$CppProxy") {} + +NativeIndexedLayerInterface::~NativeIndexedLayerInterface() = default; + +NativeIndexedLayerInterface::JavaProxy::JavaProxy(JniType j) : Handle(::djinni::jniGetThreadEnv(), j) { } + +NativeIndexedLayerInterface::JavaProxy::~JavaProxy() = default; + +/*not-null*/ std::shared_ptr<::LayerInterface> NativeIndexedLayerInterface::JavaProxy::getLayerInterface() { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeIndexedLayerInterface>::get(); + auto jret = jniEnv->CallObjectMethod(Handle::get().get(), data.method_getLayerInterface); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni_generated::NativeLayerInterface::toCpp(jniEnv, jret); +} +int32_t NativeIndexedLayerInterface::JavaProxy::getIndex() { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeIndexedLayerInterface>::get(); + auto jret = jniEnv->CallIntMethod(Handle::get().get(), data.method_getIndex); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni::I32::toCpp(jniEnv, jret); +} + +CJNIEXPORT void JNICALL Java_io_openmobilemaps_mapscore_shared_map_IndexedLayerInterface_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + delete reinterpret_cast<::djinni::CppProxyHandle<::IndexedLayerInterface>*>(nativeRef); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, ) +} + +CJNIEXPORT jobject JNICALL Java_io_openmobilemaps_mapscore_shared_map_IndexedLayerInterface_00024CppProxy_native_1getLayerInterface(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + const auto& ref = ::djinni::objectFromHandleAddress<::IndexedLayerInterface>(nativeRef); + auto r = ref->getLayerInterface(); + return ::djinni::release(::djinni_generated::NativeLayerInterface::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +CJNIEXPORT jint JNICALL Java_io_openmobilemaps_mapscore_shared_map_IndexedLayerInterface_00024CppProxy_native_1getIndex(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + const auto& ref = ::djinni::objectFromHandleAddress<::IndexedLayerInterface>(nativeRef); + auto r = ref->getIndex(); + return ::djinni::release(::djinni::I32::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + +} // namespace djinni_generated diff --git a/bridging/android/jni/map/NativeIndexedLayerInterface.h b/bridging/android/jni/map/NativeIndexedLayerInterface.h new file mode 100644 index 000000000..6b80ab886 --- /dev/null +++ b/bridging/android/jni/map/NativeIndexedLayerInterface.h @@ -0,0 +1,48 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file was generated by Djinni from core.djinni + +#pragma once + +#include "IndexedLayerInterface.h" +#include "djinni_support.hpp" + +namespace djinni_generated { + +class NativeIndexedLayerInterface final : ::djinni::JniInterface<::IndexedLayerInterface, NativeIndexedLayerInterface> { +public: + using CppType = std::shared_ptr<::IndexedLayerInterface>; + using CppOptType = std::shared_ptr<::IndexedLayerInterface>; + using JniType = jobject; + + using Boxed = NativeIndexedLayerInterface; + + ~NativeIndexedLayerInterface(); + + static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass::get()._fromJava(jniEnv, j); } + static ::djinni::LocalRef fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass::get()._toJava(jniEnv, c)}; } + static ::djinni::LocalRef fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); } + +private: + NativeIndexedLayerInterface(); + friend ::djinni::JniClass; + friend ::djinni::JniInterface<::IndexedLayerInterface, NativeIndexedLayerInterface>; + + class JavaProxy final : ::djinni::JavaProxyHandle, public ::IndexedLayerInterface + { + public: + JavaProxy(JniType j); + ~JavaProxy(); + + /*not-null*/ std::shared_ptr<::LayerInterface> getLayerInterface() override; + int32_t getIndex() override; + + private: + friend ::djinni::JniInterface<::IndexedLayerInterface, ::djinni_generated::NativeIndexedLayerInterface>; + }; + + const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("io/openmobilemaps/mapscore/shared/map/IndexedLayerInterface") }; + const jmethodID method_getLayerInterface { ::djinni::jniGetMethodID(clazz.get(), "getLayerInterface", "()Lio/openmobilemaps/mapscore/shared/map/LayerInterface;") }; + const jmethodID method_getIndex { ::djinni::jniGetMethodID(clazz.get(), "getIndex", "()I") }; +}; + +} // namespace djinni_generated diff --git a/bridging/android/jni/map/NativeMapInterface.cpp b/bridging/android/jni/map/NativeMapInterface.cpp index 9a66d7a36..070876666 100644 --- a/bridging/android/jni/map/NativeMapInterface.cpp +++ b/bridging/android/jni/map/NativeMapInterface.cpp @@ -6,6 +6,7 @@ #include "NativeColor.h" #include "NativeCoordinateConversionHelperInterface.h" #include "NativeGraphicsObjectFactoryInterface.h" +#include "NativeIndexedLayerInterface.h" #include "NativeLayerInterface.h" #include "NativeMapCallbackInterface.h" #include "NativeMapCamera2dInterface.h" @@ -159,6 +160,15 @@ CJNIEXPORT jobject JNICALL Java_io_openmobilemaps_mapscore_shared_map_MapInterfa } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) } +CJNIEXPORT jobject JNICALL Java_io_openmobilemaps_mapscore_shared_map_MapInterface_00024CppProxy_native_1getLayersIndexed(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef) +{ + try { + const auto& ref = ::djinni::objectFromHandleAddress<::MapInterface>(nativeRef); + auto r = ref->getLayersIndexed(); + return ::djinni::release(::djinni::List<::djinni_generated::NativeIndexedLayerInterface>::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + CJNIEXPORT void JNICALL Java_io_openmobilemaps_mapscore_shared_map_MapInterface_00024CppProxy_native_1addLayer(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_layer) { try { diff --git a/bridging/ios/MCIndexedLayerInterface+Private.h b/bridging/ios/MCIndexedLayerInterface+Private.h new file mode 100644 index 000000000..4812659a5 --- /dev/null +++ b/bridging/ios/MCIndexedLayerInterface+Private.h @@ -0,0 +1,33 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file was generated by Djinni from core.djinni +#ifdef __cplusplus + +#include "IndexedLayerInterface.h" +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@protocol MCIndexedLayerInterface; + +namespace djinni_generated { + +class IndexedLayerInterface +{ +public: + using CppType = std::shared_ptr<::IndexedLayerInterface>; + using CppOptType = std::shared_ptr<::IndexedLayerInterface>; + using ObjcType = id; + + using Boxed = IndexedLayerInterface; + + static CppType toCpp(ObjcType objc); + static ObjcType fromCppOpt(const CppOptType& cpp); + static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); } + +private: + class ObjcProxy; +}; + +} // namespace djinni_generated + +#endif diff --git a/bridging/ios/MCIndexedLayerInterface+Private.mm b/bridging/ios/MCIndexedLayerInterface+Private.mm new file mode 100644 index 000000000..d9367f0e3 --- /dev/null +++ b/bridging/ios/MCIndexedLayerInterface+Private.mm @@ -0,0 +1,102 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file was generated by Djinni from core.djinni + +#import "MCIndexedLayerInterface+Private.h" +#import "MCIndexedLayerInterface.h" +#import "DJICppWrapperCache+Private.h" +#import "DJIError.h" +#import "DJIMarshal+Private.h" +#import "DJIObjcWrapperCache+Private.h" +#import "MCLayerInterface+Private.h" +#include +#include +#include + +static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file"); + +@interface MCIndexedLayerInterfaceCppProxy : NSObject + +- (id)initWithCpp:(const std::shared_ptr<::IndexedLayerInterface>&)cppRef; + +@end + +@implementation MCIndexedLayerInterfaceCppProxy { + ::djinni::CppProxyCache::Handle> _cppRefHandle; +} + +- (id)initWithCpp:(const std::shared_ptr<::IndexedLayerInterface>&)cppRef +{ + if (self = [super init]) { + _cppRefHandle.assign(cppRef); + } + return self; +} + +- (nullable id)getLayerInterface { + try { + auto objcpp_result_ = _cppRefHandle.get()->getLayerInterface(); + return ::djinni_generated::LayerInterface::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +- (int32_t)getIndex { + try { + auto objcpp_result_ = _cppRefHandle.get()->getIndex(); + return ::djinni::I32::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + +namespace djinni_generated { + +class IndexedLayerInterface::ObjcProxy final +: public ::IndexedLayerInterface +, private ::djinni::ObjcProxyBase +{ + friend class ::djinni_generated::IndexedLayerInterface; +public: + using ObjcProxyBase::ObjcProxyBase; + /*not-null*/ std::shared_ptr<::LayerInterface> getLayerInterface() override + { + @autoreleasepool { + auto objcpp_result_ = [djinni_private_get_proxied_objc_object() getLayerInterface]; + return ::djinni_generated::LayerInterface::toCpp(objcpp_result_); + } + } + int32_t getIndex() override + { + @autoreleasepool { + auto objcpp_result_ = [djinni_private_get_proxied_objc_object() getIndex]; + return ::djinni::I32::toCpp(objcpp_result_); + } + } +}; + +} // namespace djinni_generated + +namespace djinni_generated { + +auto IndexedLayerInterface::toCpp(ObjcType objc) -> CppType +{ + if (!objc) { + return nullptr; + } + if ([(id)objc isKindOfClass:[MCIndexedLayerInterfaceCppProxy class]]) { + return ((MCIndexedLayerInterfaceCppProxy*)objc)->_cppRefHandle.get(); + } + return ::djinni::get_objc_proxy(objc); +} + +auto IndexedLayerInterface::fromCppOpt(const CppOptType& cpp) -> ObjcType +{ + if (!cpp) { + return nil; + } + if (auto cppPtr = dynamic_cast(cpp.get())) { + return cppPtr->djinni_private_get_proxied_objc_object(); + } + return ::djinni::get_cpp_proxy(cpp); +} + +} // namespace djinni_generated + +@end diff --git a/bridging/ios/MCIndexedLayerInterface.h b/bridging/ios/MCIndexedLayerInterface.h new file mode 100644 index 000000000..44e08336e --- /dev/null +++ b/bridging/ios/MCIndexedLayerInterface.h @@ -0,0 +1,14 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file was generated by Djinni from core.djinni + +#import +@protocol MCLayerInterface; + + +@protocol MCIndexedLayerInterface + +- (nullable id)getLayerInterface; + +- (int32_t)getIndex; + +@end diff --git a/bridging/ios/MCMapInterface+Private.mm b/bridging/ios/MCMapInterface+Private.mm index c2f8b55ab..240f84763 100644 --- a/bridging/ios/MCMapInterface+Private.mm +++ b/bridging/ios/MCMapInterface+Private.mm @@ -9,6 +9,7 @@ #import "MCColor+Private.h" #import "MCCoordinateConversionHelperInterface+Private.h" #import "MCGraphicsObjectFactoryInterface+Private.h" +#import "MCIndexedLayerInterface+Private.h" #import "MCLayerInterface+Private.h" #import "MCMapCallbackInterface+Private.h" #import "MCMapCamera2dInterface+Private.h" @@ -151,6 +152,13 @@ - (void)setTouchHandler:(nullable id)touchHandler { } DJINNI_TRANSLATE_EXCEPTIONS() } +- (nonnull NSArray> *)getLayersIndexed { + try { + auto objcpp_result_ = _cppRefHandle.get()->getLayersIndexed(); + return ::djinni::List<::djinni_generated::IndexedLayerInterface>::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + - (void)addLayer:(nullable id)layer { try { _cppRefHandle.get()->addLayer(::djinni_generated::LayerInterface::toCpp(layer)); diff --git a/bridging/ios/MCMapInterface.h b/bridging/ios/MCMapInterface.h index d684cc750..befd7ea03 100644 --- a/bridging/ios/MCMapInterface.h +++ b/bridging/ios/MCMapInterface.h @@ -14,6 +14,7 @@ #import @class MCMapCamera2dInterface; @class MCMapInterface; +@protocol MCIndexedLayerInterface; @protocol MCLayerInterface; @protocol MCMapCallbackInterface; @protocol MCMapReadyCallbackInterface; @@ -55,6 +56,8 @@ - (nonnull NSArray> *)getLayers; +- (nonnull NSArray> *)getLayersIndexed; + - (void)addLayer:(nullable id)layer; - (void)insertLayerAt:(nullable id)layer diff --git a/djinni/map/core.djinni b/djinni/map/core.djinni index 64fa3601d..f91091fa3 100644 --- a/djinni/map/core.djinni +++ b/djinni/map/core.djinni @@ -39,6 +39,7 @@ map_interface = interface +c { get_touch_handler() : touch_handler_interface; get_layers(): list; + get_layers_indexed(): list; add_layer(layer: layer_interface); insert_layer_at(layer: layer_interface, at_index: i32); @@ -67,6 +68,11 @@ map_interface = interface +c { force_reload(); } +indexed_layer_interface = interface +c +j +o { + get_layer_interface() : layer_interface; + get_index() : i32; +} + map_callback_interface = interface +c +j +o { invalidate(); on_map_resumed(); diff --git a/djinni/yaml/indexed_layer.yaml b/djinni/yaml/indexed_layer.yaml new file mode 100644 index 000000000..62ecb4a05 --- /dev/null +++ b/djinni/yaml/indexed_layer.yaml @@ -0,0 +1,39 @@ +# AUTOGENERATED FILE - DO NOT MODIFY! +# This file was generated by Djinni from core.djinni +name: indexed_layer +typedef: 'interface +c' +params: [] +prefix: "" +cpp: + typename: '::IndexedLayer' + header: '"IndexedLayer.h"' + byValue: false +objc: + typename: 'MCIndexedLayer' + pointer: true + hash: '%s.hash' + boxed: 'MCIndexedLayer' + header: '"MCIndexedLayer.h"' +objcpp: + translator: '::djinni_generated::IndexedLayer' + header: '"MCIndexedLayer+Private.h"' +java: + reference: true + typename: 'io.openmobilemaps.mapscore.shared.map.IndexedLayer' + writeToParcel: '%s.writeToParcel(out, flags)' + generic: true + readFromParcel: 'new %s(in)' + hash: '%s.hashCode()' + boxed: 'io.openmobilemaps.mapscore.shared.map.IndexedLayer' +jni: + translator: '::djinni_generated::NativeIndexedLayer' + header: '"NativeIndexedLayer.h"' + typename: jobject + typeSignature: 'Lio/openmobilemaps/mapscore/shared/map/IndexedLayer;' +wasm: + translator: '::djinni_generated::NativeIndexedLayer' + header: '"NativeIndexedLayer.h"' + typename: em::val +ts: + typename: IndexedLayer + module: './module' diff --git a/djinni/yaml/indexed_layer_interface.yaml b/djinni/yaml/indexed_layer_interface.yaml new file mode 100644 index 000000000..5b4355deb --- /dev/null +++ b/djinni/yaml/indexed_layer_interface.yaml @@ -0,0 +1,39 @@ +# AUTOGENERATED FILE - DO NOT MODIFY! +# This file was generated by Djinni from core.djinni +name: indexed_layer_interface +typedef: 'interface +c +o +j' +params: [] +prefix: "" +cpp: + typename: '::IndexedLayerInterface' + header: '"IndexedLayerInterface.h"' + byValue: false +objc: + typename: 'MCIndexedLayerInterface' + pointer: true + hash: '%s.hash' + boxed: 'MCIndexedLayerInterface' + header: '"MCIndexedLayerInterface.h"' +objcpp: + translator: '::djinni_generated::IndexedLayerInterface' + header: '"MCIndexedLayerInterface+Private.h"' +java: + reference: true + typename: 'io.openmobilemaps.mapscore.shared.map.IndexedLayerInterface' + writeToParcel: '%s.writeToParcel(out, flags)' + generic: true + readFromParcel: 'new %s(in)' + hash: '%s.hashCode()' + boxed: 'io.openmobilemaps.mapscore.shared.map.IndexedLayerInterface' +jni: + translator: '::djinni_generated::NativeIndexedLayerInterface' + header: '"NativeIndexedLayerInterface.h"' + typename: jobject + typeSignature: 'Lio/openmobilemaps/mapscore/shared/map/IndexedLayerInterface;' +wasm: + translator: '::djinni_generated::NativeIndexedLayerInterface' + header: '"NativeIndexedLayerInterface.h"' + typename: em::val +ts: + typename: IndexedLayerInterface + module: './module' diff --git a/shared/public/IndexedLayerInterface.h b/shared/public/IndexedLayerInterface.h new file mode 100644 index 000000000..29289634b --- /dev/null +++ b/shared/public/IndexedLayerInterface.h @@ -0,0 +1,18 @@ +// AUTOGENERATED FILE - DO NOT MODIFY! +// This file was generated by Djinni from core.djinni + +#pragma once + +#include +#include + +class LayerInterface; + +class IndexedLayerInterface { +public: + virtual ~IndexedLayerInterface() = default; + + virtual /*not-null*/ std::shared_ptr getLayerInterface() = 0; + + virtual int32_t getIndex() = 0; +}; diff --git a/shared/public/MapInterface.h b/shared/public/MapInterface.h index 44cfe19ce..616683630 100644 --- a/shared/public/MapInterface.h +++ b/shared/public/MapInterface.h @@ -17,6 +17,7 @@ #include #include +class IndexedLayerInterface; class LayerInterface; class MapCallbackInterface; class MapCamera2dInterface; @@ -55,6 +56,8 @@ class MapInterface { virtual std::vector> getLayers() = 0; + virtual std::vector> getLayersIndexed() = 0; + virtual void addLayer(const /*not-null*/ std::shared_ptr & layer) = 0; virtual void insertLayerAt(const /*not-null*/ std::shared_ptr & layer, int32_t atIndex) = 0; diff --git a/shared/src/map/MapScene.cpp b/shared/src/map/MapScene.cpp index 8884ee65a..e6c607fe2 100644 --- a/shared/src/map/MapScene.cpp +++ b/shared/src/map/MapScene.cpp @@ -18,6 +18,7 @@ #include "MapCamera2dInterface.h" #include "MapReadyCallbackInterface.h" #include "TouchInterface.h" +#include "IndexedLayer.h" #include "Logger.h" #include @@ -94,6 +95,14 @@ std::vector> MapScene::getLayers() { return layersList; }; +std::vector> MapScene::getLayersIndexed() { + std::vector> layersList; + for (const auto &l : layers) { + layersList.emplace_back(std::make_shared(l.first, l.second)); + } + return layersList; +} + void MapScene::addLayer(const std::shared_ptr<::LayerInterface> &layer) { removeLayer(layer); { @@ -473,4 +482,4 @@ void MapScene::forceReload() { void MapScene::requestGraphicsTaskExecution() { invalidate(); -} +} \ No newline at end of file diff --git a/shared/src/map/MapScene.h b/shared/src/map/MapScene.h index e3cca6d3c..752bc795a 100644 --- a/shared/src/map/MapScene.h +++ b/shared/src/map/MapScene.h @@ -47,6 +47,8 @@ class MapScene : public MapInterface, public SceneCallbackInterface, public Sche virtual std::vector> getLayers() override; + std::vector> getLayersIndexed() override; + virtual void addLayer(const std::shared_ptr<::LayerInterface> &layer) override; virtual void insertLayerAt(const std::shared_ptr &layer, int32_t atIndex) override; diff --git a/shared/src/map/layers/IndexedLayer.cpp b/shared/src/map/layers/IndexedLayer.cpp new file mode 100644 index 000000000..36c0bb621 --- /dev/null +++ b/shared/src/map/layers/IndexedLayer.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021 Ubique Innovation AG + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * SPDX-License-Identifier: MPL-2.0 + */ + +#include "IndexedLayer.h" + +IndexedLayer::IndexedLayer(int32_t index, const std::shared_ptr &layerInterface) : index(index), + layerInterface(layerInterface) {} + +std::shared_ptr IndexedLayer::getLayerInterface() { + return layerInterface; +} + +int32_t IndexedLayer::getIndex() { + return index; +} diff --git a/shared/src/map/layers/IndexedLayer.h b/shared/src/map/layers/IndexedLayer.h new file mode 100644 index 000000000..86ad4a483 --- /dev/null +++ b/shared/src/map/layers/IndexedLayer.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2021 Ubique Innovation AG + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * SPDX-License-Identifier: MPL-2.0 + */ + +#pragma once + +#include "IndexedLayerInterface.h" + +class IndexedLayer : public IndexedLayerInterface { +public: + IndexedLayer(int32_t index, const std::shared_ptr &layerInterface); + + std::shared_ptr getLayerInterface() override; + + int32_t getIndex() override; + +private: + int32_t index; + std::shared_ptr layerInterface; +};