7 #include <unordered_map>
23 auto it = this->extensions.find(T::ExtensionName);
24 return it != this->extensions.end();
35 auto it = this->extensions.find(T::ExtensionName);
36 if (it == this->extensions.end()) {
40 return std::any_cast<T>(&it->second);
45 return const_cast<T*
>(std::as_const(*this).getExtension<T>());
73 template <
typename T,
typename... ConstructorArgumentTypes>
74 T&
addExtension(ConstructorArgumentTypes&&... constructorArguments) {
79 std::make_any<T>(std::forward<ConstructorArgumentTypes>(
80 constructorArguments)...))
82 return std::any_cast<T&>(extension);
91 extensions.erase(T::ExtensionName);
A generic implementation of a value in a JSON structure.
std::map< std::string, JsonValue > Object
The type to represent an Object JSON value.
Utility classes for Cesium.
The base class for objects that have extensions and extras.
const T * getExtension() const noexcept
Gets an extension given its static type.
JsonValue::Object extras
Application-specific data.
JsonValue::Object unknownProperties
Unknown properties that exist on this object but do not have any representation in the statically-typ...
T * getExtension() noexcept
Gets an extension given its static type.
T & addExtension(ConstructorArgumentTypes &&... constructorArguments)
Adds a statically-typed extension to this object.
void removeExtension()
Removes a statically-typed extension from this object.
JsonValue * getGenericExtension(const std::string &extensionName) noexcept
Gets a generic extension with the given name as a CesiumUtility::JsonValue.
const JsonValue * getGenericExtension(const std::string &extensionName) const noexcept
Gets a generic extension with the given name as a CesiumUtility::JsonValue.
bool hasExtension() const noexcept
Checks if an extension exists given its static type.
std::unordered_map< std::string, std::any > extensions
The extensions attached to this object.