// This file is generated. Do not edit. #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { namespace style { static LightObserver nullObserver; Light::Light(Immutable impl_) : impl(std::move(impl_)), observer(&nullObserver) {} Light::Light() : Light(makeMutable()) {} Light::~Light() = default; void Light::setObserver(LightObserver* observer_) { observer = observer_ ? observer_ : &nullObserver; } Mutable Light::mutableImpl() const { return makeMutable(*impl); } using namespace conversion; namespace { enum class Property : uint8_t { Anchor, Color, Intensity, Position, AnchorTransition, ColorTransition, IntensityTransition, PositionTransition, }; template constexpr uint8_t toUint8(T t) noexcept { return uint8_t(mbgl::underlying_type(t)); } MAPBOX_ETERNAL_CONSTEXPR const auto properties = mapbox::eternal::hash_map( {{"anchor", toUint8(Property::Anchor)}, {"color", toUint8(Property::Color)}, {"intensity", toUint8(Property::Intensity)}, {"position", toUint8(Property::Position)}, {"anchor-transition", toUint8(Property::AnchorTransition)}, {"color-transition", toUint8(Property::ColorTransition)}, {"intensity-transition", toUint8(Property::IntensityTransition)}, {"position-transition", toUint8(Property::PositionTransition)}}); } // namespace optional Light::setProperty(const std::string& name, const Convertible& value) { const auto it = properties.find(name.c_str()); if (it == properties.end()) { return Error { "light doesn't support this property" }; } auto property = static_cast(it->second); if (property == Property::Anchor) { Error error; optional> typedValue = convert>(value, error, false, false); if (!typedValue) { return error; } setAnchor(*typedValue); return nullopt; } if (property == Property::Color) { Error error; optional> typedValue = convert>(value, error, false, false); if (!typedValue) { return error; } setColor(*typedValue); return nullopt; } if (property == Property::Intensity) { Error error; optional> typedValue = convert>(value, error, false, false); if (!typedValue) { return error; } setIntensity(*typedValue); return nullopt; } if (property == Property::Position) { Error error; optional> typedValue = convert>(value, error, false, false); if (!typedValue) { return error; } setPosition(*typedValue); return nullopt; } Error error; optional transition = convert(value, error); if (!transition) { return error; } if (property == Property::AnchorTransition) { setAnchorTransition(*transition); return nullopt; } if (property == Property::ColorTransition) { setColorTransition(*transition); return nullopt; } if (property == Property::IntensityTransition) { setIntensityTransition(*transition); return nullopt; } if (property == Property::PositionTransition) { setPositionTransition(*transition); return nullopt; } return Error { "light doesn't support this property" }; } StyleProperty Light::getProperty(const std::string& name) const { const auto it = properties.find(name.c_str()); if (it == properties.end()) { return {}; } switch (static_cast(it->second)) { case Property::Anchor: return makeStyleProperty(getAnchor()); case Property::Color: return makeStyleProperty(getColor()); case Property::Intensity: return makeStyleProperty(getIntensity()); case Property::Position: return makeStyleProperty(getPosition()); case Property::AnchorTransition: return makeStyleProperty(getAnchorTransition()); case Property::ColorTransition: return makeStyleProperty(getColorTransition()); case Property::IntensityTransition: return makeStyleProperty(getIntensityTransition()); case Property::PositionTransition: return makeStyleProperty(getPositionTransition()); } return {}; } LightAnchorType Light::getDefaultAnchor() { return LightAnchor::defaultValue(); } PropertyValue Light::getAnchor() const { return impl->properties.template get().value; } void Light::setAnchor(PropertyValue property) { auto impl_ = mutableImpl(); impl_->properties.template get().value = std::move(property); impl = std::move(impl_); observer->onLightChanged(*this); } void Light::setAnchorTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->properties.template get().options = options; impl = std::move(impl_); observer->onLightChanged(*this); } TransitionOptions Light::getAnchorTransition() const { return impl->properties.template get().options; } Color Light::getDefaultColor() { return LightColor::defaultValue(); } PropertyValue Light::getColor() const { return impl->properties.template get().value; } void Light::setColor(PropertyValue property) { auto impl_ = mutableImpl(); impl_->properties.template get().value = std::move(property); impl = std::move(impl_); observer->onLightChanged(*this); } void Light::setColorTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->properties.template get().options = options; impl = std::move(impl_); observer->onLightChanged(*this); } TransitionOptions Light::getColorTransition() const { return impl->properties.template get().options; } float Light::getDefaultIntensity() { return LightIntensity::defaultValue(); } PropertyValue Light::getIntensity() const { return impl->properties.template get().value; } void Light::setIntensity(PropertyValue property) { auto impl_ = mutableImpl(); impl_->properties.template get().value = std::move(property); impl = std::move(impl_); observer->onLightChanged(*this); } void Light::setIntensityTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->properties.template get().options = options; impl = std::move(impl_); observer->onLightChanged(*this); } TransitionOptions Light::getIntensityTransition() const { return impl->properties.template get().options; } Position Light::getDefaultPosition() { return LightPosition::defaultValue(); } PropertyValue Light::getPosition() const { return impl->properties.template get().value; } void Light::setPosition(PropertyValue property) { auto impl_ = mutableImpl(); impl_->properties.template get().value = std::move(property); impl = std::move(impl_); observer->onLightChanged(*this); } void Light::setPositionTransition(const TransitionOptions& options) { auto impl_ = mutableImpl(); impl_->properties.template get().options = options; impl = std::move(impl_); observer->onLightChanged(*this); } TransitionOptions Light::getPositionTransition() const { return impl->properties.template get().options; } } // namespace style } // namespace mbgl