#pragma once #include using namespace mbgl; using namespace mbgl::style; /** * An implementation of style::Observer that forwards all methods to dynamically-settable lambdas. */ class StubStyleObserver : public style::Observer { public: void onGlyphsLoaded(const FontStack& fontStack, const GlyphRange& glyphRange) override { if (glyphsLoaded) glyphsLoaded(fontStack, glyphRange); } void onGlyphsError(const FontStack& fontStack, const GlyphRange& glyphRange, std::exception_ptr error) override { if (glyphsError) glyphsError(fontStack, glyphRange, error); } void onSpriteLoaded() override { if (spriteLoaded) spriteLoaded(); } void onSpriteError(std::exception_ptr error) override { if (spriteError) spriteError(error); } void onSourceLoaded(Source& source) override { if (sourceLoaded) sourceLoaded(source); } void onSourceAttributionChanged(Source& source, const std::string& attribution) override { if (sourceAttributionChanged) sourceAttributionChanged(source, attribution); } void onSourceError(Source& source, std::exception_ptr error) override { if (sourceError) sourceError(source, error); } void onTileChanged(Source& source, const OverscaledTileID& tileID) override { if (tileChanged) tileChanged(source, tileID); }; void onTileError(Source& source, const OverscaledTileID& tileID, std::exception_ptr error) override { if (tileError) tileError(source, tileID, error); } void onResourceError(std::exception_ptr error) override { if (resourceError) resourceError(error); }; std::function glyphsLoaded; std::function glyphsError; std::function spriteLoaded; std::function spriteError; std::function sourceLoaded; std::function sourceAttributionChanged; std::function sourceError; std::function tileChanged; std::function tileError; std::function resourceError; };