mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-21 12:29:04 -06:00
Renamed getLua, setLua, getString, and setString methods to add "Value" to the end of the method name
Added documentation for getString/setString methods
This commit is contained in:
@@ -40,12 +40,12 @@ public:
|
||||
NumericalProperty(std::string identifier, std::string guiName, T value,
|
||||
T minimumValue, T maximumValue, T steppingValue);
|
||||
|
||||
bool getLua(lua_State* state) const override;
|
||||
bool setLua(lua_State* state) override;
|
||||
bool getLuaValue(lua_State* state) const override;
|
||||
bool setLuaValue(lua_State* state) override;
|
||||
int typeLua() const override;
|
||||
|
||||
bool getString(std::string& value) const override;
|
||||
bool setString(std::string value) override;
|
||||
bool getStringValue(std::string& value) const override;
|
||||
bool setStringValue(std::string value) override;
|
||||
|
||||
T minValue() const;
|
||||
T maxValue() const;
|
||||
|
||||
@@ -280,7 +280,7 @@ std::string NumericalProperty<T>::className() const {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool NumericalProperty<T>::setLua(lua_State* state)
|
||||
bool NumericalProperty<T>::setLuaValue(lua_State* state)
|
||||
{
|
||||
bool success = false;
|
||||
T value = PropertyDelegate<NumericalProperty<T>>::template fromLuaValue<T>(state, success);
|
||||
@@ -290,7 +290,7 @@ bool NumericalProperty<T>::setLua(lua_State* state)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool NumericalProperty<T>::getLua(lua_State* state) const
|
||||
bool NumericalProperty<T>::getLuaValue(lua_State* state) const
|
||||
{
|
||||
bool success = PropertyDelegate<NumericalProperty<T>>::template toLuaValue<T>(state, TemplateProperty<T>::_value);
|
||||
return success;
|
||||
@@ -302,13 +302,13 @@ int NumericalProperty<T>::typeLua() const {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool NumericalProperty<T>::getString(std::string& value) const {
|
||||
bool NumericalProperty<T>::getStringValue(std::string& value) const {
|
||||
bool success = PropertyDelegate<NumericalProperty<T>>::template toString<T>(value, _value);
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool NumericalProperty<T>::setString(std::string value) {
|
||||
bool NumericalProperty<T>::setStringValue(std::string value) {
|
||||
bool success = false;
|
||||
T thisValue = PropertyDelegate<NumericalProperty<T>>::template fromString<T>(value, success);
|
||||
if (success)
|
||||
|
||||
@@ -45,8 +45,9 @@ class PropertyOwner;
|
||||
* Property. Per PropertyOwner, the <code>identifier</code> needs to be unique and can be
|
||||
* used as a URI. This class is an abstract base class and each subclass (most notable
|
||||
* TemplateProperty) needs to implement the methods Property::className, Property::get,
|
||||
* Property::set, Property::type(), Property::getLua, Property::setLua, and
|
||||
* Property::typeLua to make full use of the infrastructure.
|
||||
* Property::set, Property::type(), Property::getLuaValue, Property::setLuaValue,
|
||||
* Property::getStringValue, Property::setStringValue and Property::typeLua to make full
|
||||
* use of the infrastructure.
|
||||
* The most common types can be implemented by creating a specialized instantiation of
|
||||
* TemplateProperty, which provides default implementations for these methods.
|
||||
*
|
||||
@@ -118,51 +119,69 @@ public:
|
||||
* This method encodes the encapsulated value of this Property at the top of the Lua
|
||||
* stack. The specific details of this serialization is up to the property developer
|
||||
* as long as the rest of the stack is unchanged. The implementation has to be
|
||||
* synchronized with the Property::setLua method. The default implementation is a
|
||||
* synchronized with the Property::setLuaValue method. The default implementation is a
|
||||
* no-op.
|
||||
* \param state The Lua state to which the value will be encoded
|
||||
* \return <code>true</code> if the encoding succeeded, <code>false</code> otherwise
|
||||
*/
|
||||
virtual bool getLua(lua_State* state) const;
|
||||
virtual bool getLuaValue(lua_State* state) const;
|
||||
|
||||
/**
|
||||
* This method sets the value encapsulated by this Property by deserializing the value
|
||||
* on top of the passed Lua stack. The specific details of the deserialization are up
|
||||
* to the Property developer, but they must only depend on the top element of the
|
||||
* stack and must leave all other elements unchanged. The implementation has to be
|
||||
* synchronized with the Property::getLua method. The default implementation is a
|
||||
* synchronized with the Property::getLuaValue method. The default implementation is a
|
||||
* no-op.
|
||||
* \param state The Lua state from which the value will be decoded
|
||||
* \return <code>true</code> if the decoding and setting of the value succeeded,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
virtual bool setLua(lua_State* state);
|
||||
virtual bool setLuaValue(lua_State* state);
|
||||
|
||||
/**
|
||||
* Returns the Lua type that will be put onto the stack in the Property::getLua method
|
||||
* and which will be consumed by the Property::setLua method. The returned value
|
||||
* and which will be consumed by the Property::setLuaValue method. The returned value
|
||||
* can belong to the set of Lua types: <code>LUA_TNONE</code>, <code>LUA_TNIL</code>,
|
||||
* <code>LUA_TBOOLEAN</code>, <code>LUA_TLIGHTUSERDATA</code>,
|
||||
* <code>LUA_TNUMBER</code>, <code>LUA_TSTRING</code>, <code>LUA_TTABLE</code>,
|
||||
* <code>LUA_TFUNCTION</code>, <code>LUA_TUSERDATA</code>, or
|
||||
* <code>LUA_TTHREAD</code>. The default implementation will return
|
||||
* <code>LUA_TNONE</code>.
|
||||
* \return The Lua type that will be consumed or produced by the Property::getLua and
|
||||
* Property::setLua methods.
|
||||
* \return The Lua type that will be consumed or produced by the Property::getLuaValue
|
||||
* and Property::setLuaValue methods.
|
||||
*/
|
||||
virtual int typeLua() const;
|
||||
|
||||
virtual bool getString(std::string& value) const;
|
||||
/**
|
||||
* This method encodes the encapsulated value of this Property as a
|
||||
* <code>std::string</code>. The specific details of this serialization is up to the
|
||||
* property developer. The implementation has to be synchronized with the
|
||||
Property::setStringValue method. The default implementation is a no-op.
|
||||
* \param value The value to which the Property will be encoded
|
||||
* \return <code>true</code> if the encoding succeeded, <code>false</code> otherwise
|
||||
*/
|
||||
virtual bool getStringValue(std::string& value) const;
|
||||
|
||||
virtual bool setString(std::string value);
|
||||
/**
|
||||
* This method sets the value encapsulated by this Property by deserializing the
|
||||
* passed <code>std::string</code>. The specific details of the deserialization are up
|
||||
* to the Property developer. The implementation has to be synchronized with the
|
||||
* Property::getLuaValue method. The default implementation is a no-op.
|
||||
* \param value The value from which the Property will be decoded
|
||||
* \return <code>true</code> if the decoding and setting of the value succeeded,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
virtual bool setStringValue(std::string value);
|
||||
|
||||
/**
|
||||
* This method registers a <code>callback</code> function that will be called every
|
||||
* time if either Property:set or Property::setLua was called with a value that is
|
||||
* different from the previously stored value. The callback can be removed my passing
|
||||
* an empty <code>std::function<void()></code> object.
|
||||
* time if either Property:set or Property::setLuaValue was called with a value that
|
||||
* is different from the previously stored value. The callback can be removed by
|
||||
* passing an empty <code>std::function<void()></code> object.
|
||||
* \param callback The callback function that is called when the encapsulated type has
|
||||
* been successfully changed by either the Property::set or Property::setLua methods.
|
||||
* been successfully changed by either the Property::set or Property::setLuaValue
|
||||
* methods.
|
||||
*/
|
||||
virtual void onChange(std::function<void()> callback);
|
||||
|
||||
@@ -247,9 +266,10 @@ public:
|
||||
/**
|
||||
* This method determines if this Property should be read-only in external
|
||||
* applications. This setting is only a hint and does not need to be followed by GUI
|
||||
* applications and does not have any effect on the Property::set or Property::setLua
|
||||
* methods. The value is stored in the metaData Dictionary with the key:
|
||||
* <code>isReadOnly</code>. The default value is <code>false</code>.
|
||||
* applications and does not have any effect on the Property::set,
|
||||
* Property::setLuaValue, or Property::setStringValue methods. The value is stored in
|
||||
* the metaData Dictionary with the key: <code>isReadOnly</code>. The default value is
|
||||
* <code>false</code>.
|
||||
* \param state <code>true</code> if the Property should be read only,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
* \param state The Lua state onto which the encoded object will be pushed
|
||||
* \return <code>true</code> if the encoding succeeded; <code>false</code> otherwise
|
||||
*/
|
||||
bool getLua(lua_State* state) const override;
|
||||
bool getLuaValue(lua_State* state) const override;
|
||||
|
||||
/**
|
||||
* Sets the value of this TemplateProprty by decoding the object at the top of the Lua
|
||||
@@ -122,14 +122,14 @@ public:
|
||||
* \param state The Lua state from which the value will be decoded
|
||||
* \return <code>true</code> if the decoding succeeded; <code>false</code> otherwise
|
||||
*/
|
||||
bool setLua(lua_State* state) override;
|
||||
bool setLuaValue(lua_State* state) override;
|
||||
|
||||
/// \see Property::typeLua
|
||||
int typeLua() const override;
|
||||
|
||||
bool getString(std::string& value) const override;
|
||||
bool getStringValue(std::string& value) const override;
|
||||
|
||||
bool setString(std::string value) override;
|
||||
bool setStringValue(std::string value) override;
|
||||
|
||||
/**
|
||||
* Returns the description for this TemplateProperty as a Lua script that returns a
|
||||
|
||||
@@ -235,13 +235,13 @@ const std::type_info& TemplateProperty<T>::type() const {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::getLua(lua_State* state) const {
|
||||
bool TemplateProperty<T>::getLuaValue(lua_State* state) const {
|
||||
bool success = PropertyDelegate<TemplateProperty<T>>::template toLuaValue<T>(state, _value);
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::setLua(lua_State* state) {
|
||||
bool TemplateProperty<T>::setLuaValue(lua_State* state) {
|
||||
bool success = false;
|
||||
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromLuaValue<T>(state, success);
|
||||
if (success)
|
||||
@@ -255,13 +255,13 @@ int TemplateProperty<T>::typeLua() const {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::getString(std::string& value) const {
|
||||
bool TemplateProperty<T>::getStringValue(std::string& value) const {
|
||||
bool success = PropertyDelegate<TemplateProperty<T>>::template toString<T>(value, _value);
|
||||
return success;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool TemplateProperty<T>::setString(std::string value) {
|
||||
bool TemplateProperty<T>::setStringValue(std::string value) {
|
||||
bool success = false;
|
||||
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromString<T>(value, success);
|
||||
if (success)
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
* \param state The unused Lua state
|
||||
* \return Returns always <code>true</code>
|
||||
*/
|
||||
bool setLua(lua_State* state);
|
||||
bool setLuaValue(lua_State* state);
|
||||
|
||||
/**
|
||||
* Silently ignores any value that is passed into this function and will trigger the
|
||||
|
||||
@@ -85,13 +85,13 @@ boost::any Property::get() const {
|
||||
return boost::any();
|
||||
}
|
||||
|
||||
bool Property::getLua(lua_State* state) const {
|
||||
bool Property::getLuaValue(lua_State* state) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Property::set(boost::any value) {}
|
||||
|
||||
bool Property::setLua(lua_State* state) {
|
||||
bool Property::setLuaValue(lua_State* state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -103,11 +103,11 @@ int Property::typeLua() const {
|
||||
return LUA_TNIL;
|
||||
}
|
||||
|
||||
bool Property::getString(std::string& value) const {
|
||||
bool Property::getStringValue(std::string& value) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Property::setString(std::string value) {
|
||||
bool Property::setStringValue(std::string value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ std::string TriggerProperty::className() const {
|
||||
return "TriggerProperty";
|
||||
}
|
||||
|
||||
bool TriggerProperty::setLua(lua_State* state) {
|
||||
bool TriggerProperty::setLuaValue(lua_State* state) {
|
||||
notifyListener();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ int property_setValue(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
prop->setLua(L);
|
||||
prop->setLuaValue(L);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ int property_getValue(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
prop->getLua(L);
|
||||
prop->getLuaValue(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user