mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-03 09:20:26 -05:00
Update ghoul repository
Adapt to the change from ghoul::any to std::any
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*****************************************************************************************
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
@@ -328,7 +328,7 @@ bool NumericalProperty<T>::setStringValue(std::string value) {
|
||||
value, success
|
||||
);
|
||||
if (success)
|
||||
TemplateProperty<T>::set(ghoul::any(std::move(thisValue)));
|
||||
TemplateProperty<T>::set(std::any(std::move(thisValue)));
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*****************************************************************************************
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <openspace/properties/propertydelegate.h>
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
|
||||
#include <any>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
@@ -113,11 +115,11 @@ public:
|
||||
/**
|
||||
* This method returns the encapsulated value of the Property to the caller. The type
|
||||
* that is returned is determined by the type function and is up to the developer of
|
||||
* the derived class. The default implementation returns an empty ghoul::any object.
|
||||
* \return The value that is encapsulated by this Property, or an empty ghoul::any
|
||||
* the derived class. The default implementation returns an empty std::any object.
|
||||
* \return The value that is encapsulated by this Property, or an empty std::any
|
||||
* object if the method was not overritten.
|
||||
*/
|
||||
virtual ghoul::any get() const;
|
||||
virtual std::any get() const;
|
||||
|
||||
/**
|
||||
* Sets the value encapsulated by this Property to the <code>value</code> passed to
|
||||
@@ -127,7 +129,7 @@ public:
|
||||
* implementation of this method ignores the input.
|
||||
* \param value The new value that should be stored in this Property
|
||||
*/
|
||||
virtual void set(ghoul::any value);
|
||||
virtual void set(std::any value);
|
||||
|
||||
/**
|
||||
* This method returns the type that is requested by this Property for the set method.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*****************************************************************************************
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
@@ -85,21 +85,21 @@ public:
|
||||
virtual std::string className() const override;
|
||||
|
||||
/**
|
||||
* Returns the stored value packed into a ghoul::any object.
|
||||
* \return The stored value packed into a ghoul::any object
|
||||
* Returns the stored value packed into a std::any object.
|
||||
* \return The stored value packed into a std::any object
|
||||
*/
|
||||
virtual ghoul::any get() const override;
|
||||
virtual std::any get() const override;
|
||||
|
||||
/**
|
||||
* Sets the value fro the provided ghoul::any object. If the types between
|
||||
* Sets the value from the provided std::any object. If the types between
|
||||
* <code>T</code> and <code>value</code> disagree, an error is logged and the stored
|
||||
* value remains unchanged.
|
||||
*/
|
||||
virtual void set(ghoul::any value) override;
|
||||
virtual void set(std::any value) override;
|
||||
|
||||
/**
|
||||
* Returns the <code>std::type_info</code> describing the template parameter
|
||||
* <code>T</code>. It can be used to test against a ghoul::any value before trying to
|
||||
* <code>T</code>. It can be used to test against a std::any value before trying to
|
||||
* assign it.
|
||||
* \return The type info object describing the template parameter <code>T</code>
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*****************************************************************************************
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
@@ -214,20 +214,20 @@ std::ostream& operator<<(std::ostream& os, const TemplateProperty<T>& obj) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
ghoul::any TemplateProperty<T>::get() const {
|
||||
return ghoul::any(_value);
|
||||
std::any TemplateProperty<T>::get() const {
|
||||
return std::any(_value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TemplateProperty<T>::set(ghoul::any value) {
|
||||
void TemplateProperty<T>::set(std::any value) {
|
||||
try {
|
||||
T v = ghoul::any_cast<T>(std::move(value));
|
||||
T v = std::any_cast<T>(std::move(value));
|
||||
if (v != _value) {
|
||||
_value = std::move(v);
|
||||
notifyListener();
|
||||
}
|
||||
}
|
||||
catch (ghoul::bad_any_cast&) {
|
||||
catch (std::bad_any_cast&) {
|
||||
LERRORC("TemplateProperty", "Illegal cast from '" << value.type().name()
|
||||
<< "' to '" << typeid(T).name() << "'");
|
||||
}
|
||||
@@ -240,16 +240,23 @@ const std::type_info& TemplateProperty<T>::type() const {
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::getLuaValue(lua_State* state) const {
|
||||
bool success = PropertyDelegate<TemplateProperty<T>>::template toLuaValue<T>(state, _value);
|
||||
bool success = PropertyDelegate<TemplateProperty<T>>::template toLuaValue<T>(
|
||||
state,
|
||||
_value
|
||||
);
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::setLuaValue(lua_State* state) {
|
||||
bool success = false;
|
||||
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromLuaValue<T>(state, success);
|
||||
if (success)
|
||||
set(ghoul::any(thisValue));
|
||||
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromLuaValue<T>(
|
||||
state,
|
||||
success
|
||||
);
|
||||
if (success) {
|
||||
set(std::any(thisValue));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -260,16 +267,23 @@ int TemplateProperty<T>::typeLua() const {
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::getStringValue(std::string& value) const {
|
||||
bool success = PropertyDelegate<TemplateProperty<T>>::template toString<T>(value, _value);
|
||||
bool success = PropertyDelegate<TemplateProperty<T>>::template toString<T>(
|
||||
value,
|
||||
_value
|
||||
);
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::setStringValue(std::string value) {
|
||||
bool success = false;
|
||||
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromString<T>(value, success);
|
||||
if (success)
|
||||
set(ghoul::any(thisValue));
|
||||
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromString<T>(
|
||||
value,
|
||||
success
|
||||
);
|
||||
if (success) {
|
||||
set(std::any(thisValue));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*****************************************************************************************
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
* listeners regardless of the value
|
||||
* \param value The ignored value
|
||||
*/
|
||||
void set(ghoul::any value);
|
||||
void set(std::any value);
|
||||
};
|
||||
|
||||
} // namespace properties
|
||||
|
||||
Reference in New Issue
Block a user