untabify to make merge easier

This commit is contained in:
Michael Nilsson
2016-04-20 15:21:30 -04:00
parent 07dfafeddb
commit c72536fbbc
269 changed files with 11414 additions and 11414 deletions
@@ -35,35 +35,35 @@ class NumericalProperty : public TemplateProperty<T> {
public:
NumericalProperty(std::string identifier, std::string guiName);
NumericalProperty(std::string identifier, std::string guiName, T value);
NumericalProperty(std::string identifier, std::string guiName, T value,
T minimumValue, T maximumValue);
NumericalProperty(std::string identifier, std::string guiName, T value,
T minimumValue, T maximumValue);
NumericalProperty(std::string identifier, std::string guiName, T value,
T minimumValue, T maximumValue, T steppingValue);
bool getLuaValue(lua_State* state) const override;
bool setLuaValue(lua_State* state) override;
int typeLua() const override;
bool getLuaValue(lua_State* state) const override;
bool setLuaValue(lua_State* state) override;
int typeLua() const override;
bool getStringValue(std::string& value) const override;
bool setStringValue(std::string value) override;
T minValue() const;
T maxValue() const;
T minValue() const;
T maxValue() const;
virtual std::string className() const override;
using TemplateProperty<T>::operator=;
protected:
static const std::string MinimumValueKey;
static const std::string MaximumValueKey;
static const std::string SteppingValueKey;
static const std::string MinimumValueKey;
static const std::string MaximumValueKey;
static const std::string SteppingValueKey;
std::string generateAdditionalDescription() const;
std::string generateAdditionalDescription() const;
T _minimumValue;
T _maximumValue;
T _stepping;
T _stepping;
};
} // namespace properties
@@ -48,9 +48,9 @@ namespace properties {
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>(); \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>(); \
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>(); \
\
template <> \
template <> \
@@ -104,41 +104,41 @@ namespace properties {
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() \
{ \
return #CLASS_NAME; \
} \
} \
\
template <> \
std::string PropertyDelegate<NumericalProperty<TYPE>>::className() \
{ \
return PropertyDelegate<TemplateProperty<TYPE>>::className(); \
} \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>() \
{ \
return DEFAULT_VALUE; \
} \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>() \
{ \
return DEFAULT_MIN_VALUE; \
} \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>() \
{ \
return DEFAULT_MAX_VALUE; \
} \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>() \
{ \
return DEFAULT_STEPPING; \
} \
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>() \
{ \
return DEFAULT_STEPPING; \
} \
\
template <> \
template <> \
@@ -146,7 +146,7 @@ namespace properties {
bool& success) \
{ \
return FROM_LUA_LAMBDA_EXPRESSION(state, success); \
} \
} \
\
template <> \
template <> \
@@ -155,7 +155,7 @@ namespace properties {
{ \
return PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(state, \
success); \
} \
} \
\
template <> \
template <> \
@@ -235,33 +235,33 @@ const std::string NumericalProperty<T>::SteppingValueKey = "SteppingValue";
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier, std::string guiName)
: NumericalProperty<T>(
std::move(identifier), std::move(guiName),
PropertyDelegate<NumericalProperty<T>>::template defaultValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>()
)
std::move(identifier), std::move(guiName),
PropertyDelegate<NumericalProperty<T>>::template defaultValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>()
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier,
std::string guiName, T value)
: NumericalProperty<T>(
std::move(identifier), std::move(guiName), std::move(value),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>()
)
std::move(identifier), std::move(guiName), std::move(value),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>()
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(std::string identifier, std::string guiName,
T value, T minimumValue, T maximumValue)
: NumericalProperty<T>(
std::move(identifier) , std::move(guiName), std::move(value),
std::move(minimumValue), std::move(maximumValue),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>()
)
T value, T minimumValue, T maximumValue)
: NumericalProperty<T>(
std::move(identifier) , std::move(guiName), std::move(value),
std::move(minimumValue), std::move(maximumValue),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>()
)
{}
template <typename T>
@@ -271,7 +271,7 @@ NumericalProperty<T>::NumericalProperty(std::string identifier,
: TemplateProperty<T>(std::move(identifier), std::move(guiName), std::move(value))
, _minimumValue(std::move(minimumValue))
, _maximumValue(std::move(maximumValue))
, _stepping(std::move(steppingValue))
, _stepping(std::move(steppingValue))
{}
template <typename T>
@@ -282,23 +282,23 @@ std::string NumericalProperty<T>::className() const {
template <typename T>
bool NumericalProperty<T>::setLuaValue(lua_State* state)
{
bool success = false;
T value = PropertyDelegate<NumericalProperty<T>>::template fromLuaValue<T>(state, success);
if (success)
TemplateProperty<T>::setValue(value);
return success;
bool success = false;
T value = PropertyDelegate<NumericalProperty<T>>::template fromLuaValue<T>(state, success);
if (success)
TemplateProperty<T>::setValue(value);
return success;
}
template <typename T>
bool NumericalProperty<T>::getLuaValue(lua_State* state) const
{
bool success = PropertyDelegate<NumericalProperty<T>>::template toLuaValue<T>(state, TemplateProperty<T>::_value);
return success;
bool success = PropertyDelegate<NumericalProperty<T>>::template toLuaValue<T>(state, TemplateProperty<T>::_value);
return success;
}
template <typename T>
int NumericalProperty<T>::typeLua() const {
return PropertyDelegate<NumericalProperty<T>>::typeLua();
return PropertyDelegate<NumericalProperty<T>>::typeLua();
}
template <typename T>
@@ -318,21 +318,21 @@ bool NumericalProperty<T>::setStringValue(std::string value) {
template <typename T>
T NumericalProperty<T>::minValue() const {
return _minimumValue;
return _minimumValue;
}
template <typename T>
T NumericalProperty<T>::maxValue() const {
return _maximumValue;
return _maximumValue;
}
template <typename T>
std::string NumericalProperty<T>::generateAdditionalDescription() const {
std::string result;
result += MinimumValueKey + " = " + std::to_string(_minimumValue) + ",";
result += MaximumValueKey + " = " + std::to_string(_maximumValue) + ",";
result += SteppingValueKey + " = " + std::to_string(_stepping);
return result;
std::string result;
result += MinimumValueKey + " = " + std::to_string(_minimumValue) + ",";
result += MaximumValueKey + " = " + std::to_string(_maximumValue) + ",";
result += SteppingValueKey + " = " + std::to_string(_stepping);
return result;
}
} // namespace properties
+43 -43
View File
@@ -41,58 +41,58 @@ namespace properties {
*/
class OptionProperty : public IntProperty {
public:
/**
* The struct storing a single option consisting of an integer <code>value</code> and
* a <code>string</code> description.
*/
struct Option {
int value;
std::string description;
};
/**
* The struct storing a single option consisting of an integer <code>value</code> and
* a <code>string</code> description.
*/
struct Option {
int value;
std::string description;
};
/**
* The constructor delegating the <code>identifier</code> and the <code>guiName</code>
* to its super class.
* \param identifier A unique identifier for this property
* \param guiName The GUI name that should be used to represent this property
*/
OptionProperty(std::string identifier, std::string guiName);
/**
* The constructor delegating the <code>identifier</code> and the <code>guiName</code>
* to its super class.
* \param identifier A unique identifier for this property
* \param guiName The GUI name that should be used to represent this property
*/
OptionProperty(std::string identifier, std::string guiName);
/**
* Returns the name of the class for reflection purposes.
* \return The name of this class for reflection purposes
*/
std::string className() const override;
using IntProperty::operator=;
/**
* Returns the name of the class for reflection purposes.
* \return The name of this class for reflection purposes
*/
std::string className() const override;
using IntProperty::operator=;
/**
* Adds the passed option to the list of available options. The <code>value</code> of
* the <code>option</code> must not have been registered previously, or a warning will
* be logged.
* \param value The option that will be added to the list of available options
/**
* Adds the passed option to the list of available options. The <code>value</code> of
* the <code>option</code> must not have been registered previously, or a warning will
* be logged.
* \param value The option that will be added to the list of available options
* \param desc The description of the value that will be added
*/
void addOption(int value, std::string desc);
*/
void addOption(int value, std::string desc);
/**
* Returns the list of available options.
* /return The list of available options
*/
const std::vector<Option>& options() const;
/**
* Returns the list of available options.
* /return The list of available options
*/
const std::vector<Option>& options() const;
/**
* The overritten TemplateProperty::setValue method that checks if the provided value
* represents a valid Option
* \param value The value of the Option that should be set
*/
void setValue(int value) override;
/**
* The overritten TemplateProperty::setValue method that checks if the provided value
* represents a valid Option
* \param value The value of the Option that should be set
*/
void setValue(int value) override;
private:
static const std::string OptionsKey;
std::string generateAdditionalDescription() const;
static const std::string OptionsKey;
std::string generateAdditionalDescription() const;
/// The list of options which have been registered with this OptionProperty
std::vector<Option> _options;
/// The list of options which have been registered with this OptionProperty
std::vector<Option> _options;
};
} // namespace properties
+233 -233
View File
@@ -62,239 +62,239 @@ class PropertyOwner;
*/
class Property {
public:
/**
* The constructor for the property. The <code>identifier</code> needs to be unique
* for each PropertyOwner. The <code>guiName</code> will be stored in the metaData
* to be accessed by the GUI elements using the <code>guiName</code> key. The default
* visibility settings is <code>true</code>, whereas the default read-only state is
* <code>false</code>.
* \param identifier A unique identifier for this property. It has to be unique to the
* PropertyOwner and cannot contain any <code>.</code>s
* \param guiName The human-readable GUI name for this Property
*/
/**
* The constructor for the property. The <code>identifier</code> needs to be unique
* for each PropertyOwner. The <code>guiName</code> will be stored in the metaData
* to be accessed by the GUI elements using the <code>guiName</code> key. The default
* visibility settings is <code>true</code>, whereas the default read-only state is
* <code>false</code>.
* \param identifier A unique identifier for this property. It has to be unique to the
* PropertyOwner and cannot contain any <code>.</code>s
* \param guiName The human-readable GUI name for this Property
*/
Property(std::string identifier, std::string guiName);
/**
* The destructor taking care of deallocating all unused memory. This method will not
* remove the Property from the PropertyOwner.
*/
/**
* The destructor taking care of deallocating all unused memory. This method will not
* remove the Property from the PropertyOwner.
*/
virtual ~Property();
/**
* This method returns the class name of the Property. The method is used by the
* TemplateFactory to create new instances of Propertys. The returned value is almost
* always identical to the C++ class name of the derived class.
* \return The class name of the Property
*/
/**
* This method returns the class name of the Property. The method is used by the
* TemplateFactory to create new instances of Propertys. The returned value is almost
* always identical to the C++ class name of the derived class.
* \return The class name of the Property
*/
virtual std::string className() const = 0;
/**
* 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
* object if the method was not overritten.
*/
/**
* 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
* object if the method was not overritten.
*/
virtual ghoul::any get() const;
/**
* Sets the value encapsulated by this Property to the <code>value</code> passed to
* this function. It is the caller's responsibility to ensure that the type contained
* in <code>value</code> is compatible with the concrete subclass of the Property. The
* method Property::type will return the desired type for the Property. The default
* implementation of this method ignores the input.
* \param value The new value that should be stored in this Property
*/
/**
* Sets the value encapsulated by this Property to the <code>value</code> passed to
* this function. It is the caller's responsibility to ensure that the type contained
* in <code>value</code> is compatible with the concrete subclass of the Property. The
* method Property::type will return the desired type for the Property. The default
* 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);
/**
* This method returns the type that is requested by this Property for the set method.
* The default implementation returns the type of <code>void</code>.
* \return The type that is requested by this Property's Property::set method
*/
/**
* This method returns the type that is requested by this Property for the set method.
* The default implementation returns the type of <code>void</code>.
* \return The type that is requested by this Property's Property::set method
*/
virtual const std::type_info& type() const;
/**
* 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::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 getLuaValue(lua_State* state) const;
/**
* 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::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 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::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 setLuaValue(lua_State* state);
/**
* 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::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 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::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::getLuaValue
/**
* Returns the Lua type that will be put onto the stack in the Property::getLua method
* 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::getLuaValue
* and Property::setLuaValue methods.
*/
virtual int typeLua() const;
*/
virtual int typeLua() const;
/**
* This method encodes the encapsulated value of this Property as a
/**
* 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
*/
* \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;
/**
* This method sets the value encapsulated by this Property by deserializing the
/**
* 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
* 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
*/
* \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::setLuaValue was called with a value that
/**
* This method registers a <code>callback</code> function that will be called every
* 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::setLuaValue
* \param callback The callback function that is called when the encapsulated type has
* been successfully changed by either the Property::set or Property::setLuaValue
* methods.
*/
*/
virtual void onChange(std::function<void()> callback);
/**
* This method returns the unique identifier of this Property.
* \return The unique identifier of this Property
*/
/**
* This method returns the unique identifier of this Property.
* \return The unique identifier of this Property
*/
const std::string& identifier() const;
/**
* Returns the fully qualified name for this Property that uniquely identifies this
* Property within OpenSpace. It consists of the <code>identifier</code> preceded by
* all levels of PropertyOwner%s separated with <code>.</code>; for example:
* <code>owner1.owner2.identifier</code>.
* \return The fully qualified identifier for this Property
*/
std::string fullyQualifiedIdentifier() const;
/**
* Returns the fully qualified name for this Property that uniquely identifies this
* Property within OpenSpace. It consists of the <code>identifier</code> preceded by
* all levels of PropertyOwner%s separated with <code>.</code>; for example:
* <code>owner1.owner2.identifier</code>.
* \return The fully qualified identifier for this Property
*/
std::string fullyQualifiedIdentifier() const;
/**
* Returns the PropertyOwner of this Property or <code>nullptr</code>, if it does not
* have an owner.
*\ return The Property of this Property
*/
/**
* Returns the PropertyOwner of this Property or <code>nullptr</code>, if it does not
* have an owner.
*\ return The Property of this Property
*/
PropertyOwner* owner() const;
/**
* Assigned the Property to a new PropertyOwner. This method does not inform the
* PropertyOwner of this action.
* \param owner The new PropertyOwner for this Property
*/
/**
* Assigned the Property to a new PropertyOwner. This method does not inform the
* PropertyOwner of this action.
* \param owner The new PropertyOwner for this Property
*/
void setPropertyOwner(PropertyOwner* owner);
/**
* Returns the human-readable GUI name for this Property that has been set in the
* constructor. This method returns the same value as accessing the metaData object
* and requesting the <code>std::string</code> stored for the <code>guiName</code>
* key.
* \return The human-readable GUI name for this Property
*/
std::string guiName() const;
/**
* Returns the human-readable GUI name for this Property that has been set in the
* constructor. This method returns the same value as accessing the metaData object
* and requesting the <code>std::string</code> stored for the <code>guiName</code>
* key.
* \return The human-readable GUI name for this Property
*/
std::string guiName() const;
/**
* Returns the description for this Property that contains all necessary information
* required for creating a GUI representation. The format of the description is a
* valid Lua table, i.e., it is surrounded by a pair of <code>{</code> and
* <code>}</code> with key,value pairs between. Each value can either be a number, a
* string, a bool, or another table. The general values set by this base function
* are: <code>Identifier</code>, <code>Name</code>, <code>Type</code>. All other
* values are specific to the type and are added in a specific subclass, which require
* the subclass to call this method first.
* \return The descriptive text for the Property that can be used for constructing a
* GUI representation
*/
virtual std::string description() const;
/**
* Returns the description for this Property that contains all necessary information
* required for creating a GUI representation. The format of the description is a
* valid Lua table, i.e., it is surrounded by a pair of <code>{</code> and
* <code>}</code> with key,value pairs between. Each value can either be a number, a
* string, a bool, or another table. The general values set by this base function
* are: <code>Identifier</code>, <code>Name</code>, <code>Type</code>. All other
* values are specific to the type and are added in a specific subclass, which require
* the subclass to call this method first.
* \return The descriptive text for the Property that can be used for constructing a
* GUI representation
*/
virtual std::string description() const;
/**
* Sets the identifier of the group that this Property belongs to. Property groups can
* be used, for example, by GUI application to visually group different properties,
* but it has no impact on the Property itself. The default value for the groupID is
* <code>""</code>.
* \param groupId The group id that this property should belong to
*/
/**
* Sets the identifier of the group that this Property belongs to. Property groups can
* be used, for example, by GUI application to visually group different properties,
* but it has no impact on the Property itself. The default value for the groupID is
* <code>""</code>.
* \param groupId The group id that this property should belong to
*/
void setGroupIdentifier(std::string groupId);
/**
* Returns the group idenfier that this Property belongs to, or <code>""</code> if it
* belongs to no group.
* \return The group identifier that this Property belongs to
*/
/**
* Returns the group idenfier that this Property belongs to, or <code>""</code> if it
* belongs to no group.
* \return The group identifier that this Property belongs to
*/
std::string groupIdentifier() const;
/**
* Determines a hint if this Property should be visible, or hidden. Each application
* accessing the properties is free to ignore this hint. It is stored in the metaData
* Dictionary with the key: <code>isVisible</code>. The default value is
* <code>true</code>.
* \param state <code>true</code> if the Property should be visible,
* <code>false</code> otherwise.
*/
/**
* Determines a hint if this Property should be visible, or hidden. Each application
* accessing the properties is free to ignore this hint. It is stored in the metaData
* Dictionary with the key: <code>isVisible</code>. The default value is
* <code>true</code>.
* \param state <code>true</code> if the Property should be visible,
* <code>false</code> otherwise.
*/
void setVisible(bool state);
/**
* 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,
/**
* 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,
* 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
*/
void setReadOnly(bool state);
* \param state <code>true</code> if the Property should be read only,
* <code>false</code> otherwise
*/
void setReadOnly(bool state);
/**
* This method allows the developer to give hints to the GUI about different
* representations for the GUI. The same Property (for example Vec4Property) can be
* used in different ways, each requiring a different input method. These values are
* stored in the metaData object using the <code>views.</code> prefix in front of the
* <code>option</code> parameter. See Property::ViewOptions for a default list of
* possible options. As these are only hints, the GUI is free to ignore any suggestion
* by the developer.
* \param option The view option that should be modified
* \param value Determines if the view option should be active (<code>true</code>) or
* deactivated (<code>false</code>)
*/
/**
* This method allows the developer to give hints to the GUI about different
* representations for the GUI. The same Property (for example Vec4Property) can be
* used in different ways, each requiring a different input method. These values are
* stored in the metaData object using the <code>views.</code> prefix in front of the
* <code>option</code> parameter. See Property::ViewOptions for a default list of
* possible options. As these are only hints, the GUI is free to ignore any suggestion
* by the developer.
* \param option The view option that should be modified
* \param value Determines if the view option should be active (<code>true</code>) or
* deactivated (<code>false</code>)
*/
void setViewOption(std::string option, bool value = true);
/**
* Default view options that can be used in the Property::setViewOption method. The
* values are: Property::ViewOptions::Color = <code>color</code>,
* Property::ViewOptions::LightPosition = <code>lightPosition</code>,
* Property::ViewOptions::PowerScaledScalar = <code>powerScaledScalar</code>, and
* Property::ViewOptions::PowerScaledCoordinate = <code>powerScaledCoordinate</code>.
*/
/**
* Default view options that can be used in the Property::setViewOption method. The
* values are: Property::ViewOptions::Color = <code>color</code>,
* Property::ViewOptions::LightPosition = <code>lightPosition</code>,
* Property::ViewOptions::PowerScaledScalar = <code>powerScaledScalar</code>, and
* Property::ViewOptions::PowerScaledCoordinate = <code>powerScaledCoordinate</code>.
*/
struct ViewOptions {
static const std::string Color;
static const std::string LightPosition;
@@ -302,68 +302,68 @@ public:
static const std::string PowerScaledCoordinate;
};
/**
* Returns the metaData that contains all information for external applications to
* correctly display information about the Property. No information that is stored in
* this Dictionary is necessary for the programmatic use of the Property.
* \return The Dictionary containing all meta data information about this Property
*/
/**
* Returns the metaData that contains all information for external applications to
* correctly display information about the Property. No information that is stored in
* this Dictionary is necessary for the programmatic use of the Property.
* \return The Dictionary containing all meta data information about this Property
*/
const ghoul::Dictionary& metaData() const;
protected:
static const std::string IdentifierKey;
static const std::string NameKey;
static const std::string TypeKey;
static const std::string MetaDataKey;
static const std::string IdentifierKey;
static const std::string NameKey;
static const std::string TypeKey;
static const std::string MetaDataKey;
/**
* Creates the information that is general to every Property and adds the
* <code>Identifier</code>, <code>Name</code>, <code>Type</code>, and
* <code>MetaData</code> keys and their values. The meta data is handles by the
* generateMetaDataDescription method, which has to be overloaded if a concrete base
* class wants to add meta data that is not curated by the Property class
* \return The base description common to all Property classes
*/
std::string generateBaseDescription() const;
/**
* Creates the information that is general to every Property and adds the
* <code>Identifier</code>, <code>Name</code>, <code>Type</code>, and
* <code>MetaData</code> keys and their values. The meta data is handles by the
* generateMetaDataDescription method, which has to be overloaded if a concrete base
* class wants to add meta data that is not curated by the Property class
* \return The base description common to all Property classes
*/
std::string generateBaseDescription() const;
/**
* Creates the information for the <code>MetaData</code> key-part of the Lua
* description for the Property. The result can be included as one key-value pair in
* the description text generated by subclasses. Only the metadata curated by the
* Property class is used in this method.
* \return The metadata information text for the property
*/
virtual std::string generateMetaDataDescription() const;
/**
* Creates the information for the <code>MetaData</code> key-part of the Lua
* description for the Property. The result can be included as one key-value pair in
* the description text generated by subclasses. Only the metadata curated by the
* Property class is used in this method.
* \return The metadata information text for the property
*/
virtual std::string generateMetaDataDescription() const;
/**
* Creates the information that is specific to each subclass of Property%s. If a
* subclass needs to add additional information into the description, it has to
* override this method and return the string containing all of the additional
* information. The base implementation of the #description method will return the Lua
* script:
* <code>return { generateBaseDescription(), generateMetaDataDescription(),</code>
* <code>generateAdditionalDescription()}</code>, which #generateMetaDataDescription
* and this method being the override points to customize the behavior.
* \return The information specific to each subclass of Property
*/
virtual std::string generateAdditionalDescription() const;
/**
* Creates the information that is specific to each subclass of Property%s. If a
* subclass needs to add additional information into the description, it has to
* override this method and return the string containing all of the additional
* information. The base implementation of the #description method will return the Lua
* script:
* <code>return { generateBaseDescription(), generateMetaDataDescription(),</code>
* <code>generateAdditionalDescription()}</code>, which #generateMetaDataDescription
* and this method being the override points to customize the behavior.
* \return The information specific to each subclass of Property
*/
virtual std::string generateAdditionalDescription() const;
/**
* This method must be called by all subclasses whenever the encapsulated value has
* changed and a potential listener has to be informed.
*/
void notifyListener();
/**
* This method must be called by all subclasses whenever the encapsulated value has
* changed and a potential listener has to be informed.
*/
void notifyListener();
/// The PropetyOwner this Property belongs to, or <code>nullptr</code>
/// The PropetyOwner this Property belongs to, or <code>nullptr</code>
PropertyOwner* _owner;
/// The identifier for this Property
/// The identifier for this Property
std::string _identifier;
/// The Dictionary containing all meta data necessary for external applications
/// The Dictionary containing all meta data necessary for external applications
ghoul::Dictionary _metaData;
/// The callback function that will be invoked whenever the encapsulated value changes
/// The callback function that will be invoked whenever the encapsulated value changes
std::function<void()> _onChangeCallback;
};
+88 -88
View File
@@ -47,108 +47,108 @@ namespace properties {
template <typename T>
class PropertyDelegate {
public:
/**
* This method returns the class name for the class <code>T</code>. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \return The class name for the class <code>T</code>
*/
/**
* This method returns the class name for the class <code>T</code>. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \return The class name for the class <code>T</code>
*/
static std::string className();
/**
* This method will return the preferred default value for the class <code>T</code>.
* The default implementation will lead to a compile-time error if the class method is
* not specialized.
* \return The default value that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
/**
* This method will return the preferred default value for the class <code>T</code>.
* The default implementation will lead to a compile-time error if the class method is
* not specialized.
* \return The default value that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static U defaultValue();
/**
* This method will return the preferred default minimum value for the class
* <code>T</code>. The default implementation will lead to a compile-time error if the
* class method is not specialized. This method is not used in TemplateProperty, but
* only NumericalProperty, so the TemplateProperty does not require this method to be
* specialized.
* \return The default minimum value that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
*/
/**
* This method will return the preferred default minimum value for the class
* <code>T</code>. The default implementation will lead to a compile-time error if the
* class method is not specialized. This method is not used in TemplateProperty, but
* only NumericalProperty, so the TemplateProperty does not require this method to be
* specialized.
* \return The default minimum value that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
*/
template <typename U>
static U defaultMinimumValue();
/**
* This method will return the preferred default maximum value for the class
* <code>T</code>. The default implementation will lead to a compile-time error if the
* class method is not specialized. This method is not used in TemplateProperty, but
* only NumericalProperty, so the TemplateProperty does not require this method to be
* specialized.
* \return The default maximum value that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
*/
/**
* This method will return the preferred default maximum value for the class
* <code>T</code>. The default implementation will lead to a compile-time error if the
* class method is not specialized. This method is not used in TemplateProperty, but
* only NumericalProperty, so the TemplateProperty does not require this method to be
* specialized.
* \return The default maximum value that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
*/
template <typename U>
static U defaultMaximumValue();
/**
* The method returns the default stepping value for the class <code>T</code> used in
* GUI elements. The default implementation will lead to a compile-time error if the
* class method is not specialized. This method is not used in TemplateProperty, but
* only NumericalProperty, so the TemplateProperty does not require this method to be
* specialized.
* \return The default stepping that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
*/
template <typename U>
static U defaultSteppingValue();
/**
* The method returns the default stepping value for the class <code>T</code> used in
* GUI elements. The default implementation will lead to a compile-time error if the
* class method is not specialized. This method is not used in TemplateProperty, but
* only NumericalProperty, so the TemplateProperty does not require this method to be
* specialized.
* \return The default stepping that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
*/
template <typename U>
static U defaultSteppingValue();
/**
* This method converts the top value from the Lua stack into a value of type
* <code>U</code> and reports the <code>success</code> back to the caller. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \param state The Lua state from which the value is retrieved
* \param success Will be <code>true</code> if the conversion succeeded;
* <code>false</code> otherwise
* \return The value that was created by converting the top value from the stack
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static U fromLuaValue(lua_State* state, bool& success);
/**
* This method converts the top value from the Lua stack into a value of type
* <code>U</code> and reports the <code>success</code> back to the caller. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \param state The Lua state from which the value is retrieved
* \param success Will be <code>true</code> if the conversion succeeded;
* <code>false</code> otherwise
* \return The value that was created by converting the top value from the stack
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static U fromLuaValue(lua_State* state, bool& success);
/**
* This method converts the passed <code>value</code>, encodes it and places it on the
* top value of the Lua stack and returns the success back to the caller. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \param state The Lua state from which the value is retrieved
* \param value The value that will be converted into a Lua object
* \return <code>true</code> if the conversion succeeded; <code>false</code> otherwise
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static bool toLuaValue(lua_State* state, U value);
/**
* This method converts the passed <code>value</code>, encodes it and places it on the
* top value of the Lua stack and returns the success back to the caller. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \param state The Lua state from which the value is retrieved
* \param value The value that will be converted into a Lua object
* \return <code>true</code> if the conversion succeeded; <code>false</code> otherwise
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static bool toLuaValue(lua_State* state, U value);
/**
* Returns the Lua type that will be put onto the stack in the
* PropertyDelegate::toLuaValue method and which will be consumed by the
* PropertyDelegate::fromLuaValue 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>. The default implementation will lead to a compile-time
* error if the class method is not specialized.
* \return The Lua type that will be consumed or produced by the
* PropertyDelegate::toLuaValue and PropertyDelegate::fromLuaValue methods.
*/
static int typeLua();
/**
* Returns the Lua type that will be put onto the stack in the
* PropertyDelegate::toLuaValue method and which will be consumed by the
* PropertyDelegate::fromLuaValue 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>. The default implementation will lead to a compile-time
* error if the class method is not specialized.
* \return The Lua type that will be consumed or produced by the
* PropertyDelegate::toLuaValue and PropertyDelegate::fromLuaValue methods.
*/
static int typeLua();
template <typename U>
static U fromString(std::string value, bool& success);
@@ -30,14 +30,14 @@ namespace properties {
template <typename T>
std::string PropertyDelegate<T>::className() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::className specialization");
"Unimplemented PropertyDelegate::className specialization");
}
template <typename T>
template <typename U>
U PropertyDelegate<T>::defaultValue() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::defaultValue specialization");
"Unimplemented PropertyDelegate::defaultValue specialization");
}
template <typename T>
@@ -57,28 +57,28 @@ U PropertyDelegate<T>::defaultMaximumValue() {
template <typename T>
template <typename U>
U PropertyDelegate<T>::defaultSteppingValue() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::defaultSteppingValue specialization");
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::defaultSteppingValue specialization");
}
template <typename T>
template <typename U>
U PropertyDelegate<T>::fromLuaValue(lua_State* state, bool& success) {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::fromLuaValue specialization");
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::fromLuaValue specialization");
}
template <typename T>
template <typename U>
bool PropertyDelegate<T>::toLuaValue(lua_State* state, U value) {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::toLuaValue specialization");
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::toLuaValue specialization");
}
template <typename T>
int PropertyDelegate<T>::typeLua() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::luaType specialization");
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::luaType specialization");
}
template <typename T>
+119 -119
View File
@@ -49,173 +49,173 @@ namespace properties {
*/
class PropertyOwner {
public:
/// The separator that is used while accessing the properties and/or sub-owners
/// The separator that is used while accessing the properties and/or sub-owners
static const char URISeparator = '.';
/// The constructor initializing the PropertyOwner's name to <code>""</code>
/// The constructor initializing the PropertyOwner's name to <code>""</code>
PropertyOwner();
/**
* The destructor will remove all Propertys and PropertyOwners it owns along with
* itself.
*/
/**
* The destructor will remove all Propertys and PropertyOwners it owns along with
* itself.
*/
virtual ~PropertyOwner();
/**
* Sets the name for this PropertyOwner. If the PropertyOwner does not have an owner
* itself, the name must be globally unique. If the PropertyOwner has an owner, the
* name must be unique to the owner (including the owner's properties). No uniqueness
* check will be preformed here, but rather in the PropertyOwner::addProperty and
* PropertyOwner::addPropertySubOwner methods).
* \param name The name of this PropertyOwner. It may not contain any <code>.</code>s
*/
/**
* Sets the name for this PropertyOwner. If the PropertyOwner does not have an owner
* itself, the name must be globally unique. If the PropertyOwner has an owner, the
* name must be unique to the owner (including the owner's properties). No uniqueness
* check will be preformed here, but rather in the PropertyOwner::addProperty and
* PropertyOwner::addPropertySubOwner methods).
* \param name The name of this PropertyOwner. It may not contain any <code>.</code>s
*/
void setName(std::string name);
/**
* Returns the name of this PropertyOwner.
* \return The name of this PropertyOwner
*/
/**
* Returns the name of this PropertyOwner.
* \return The name of this PropertyOwner
*/
const std::string& name() const;
/**
* Returns a list of all Propertys directly owned by this PropertyOwner. This list not
* include Propertys owned by other sub-owners.
* \return A list of all Propertys directly owned by this PropertyOwner
*/
/**
* Returns a list of all Propertys directly owned by this PropertyOwner. This list not
* include Propertys owned by other sub-owners.
* \return A list of all Propertys directly owned by this PropertyOwner
*/
const std::vector<Property*>& properties() const;
/**
* Returns a list of all Propertys directly or indirectly owned by this PropertyOwner.
* \return A list of all Propertys directly or indirectly owned by this PropertyOwner
*/
std::vector<Property*> propertiesRecursive() const;
/**
* Returns a list of all Propertys directly or indirectly owned by this PropertyOwner.
* \return A list of all Propertys directly or indirectly owned by this PropertyOwner
*/
std::vector<Property*> propertiesRecursive() const;
/**
* Retrieves a Property identified by <code>URI</code> from this PropertyOwner. If
* <code>id</code> does not contain a <code>.</code> the identifier must refer to a
* Property directly owned by this PropertyOwner. If the identifier contains one or
* more <code>.</code>, the first part of the name will be recursively extracted and
* used as a name for a sub-owner and only the last part of the identifier is
* referring to a Property owned by PropertyOwner named by the second-but-last name.
* \param URI The identifier of the Property that should be extracted
* \return If the Property cannot be found, <code>nullptr</code> is returned,
* otherwise the pointer to the Property is returned
*/
/**
* Retrieves a Property identified by <code>URI</code> from this PropertyOwner. If
* <code>id</code> does not contain a <code>.</code> the identifier must refer to a
* Property directly owned by this PropertyOwner. If the identifier contains one or
* more <code>.</code>, the first part of the name will be recursively extracted and
* used as a name for a sub-owner and only the last part of the identifier is
* referring to a Property owned by PropertyOwner named by the second-but-last name.
* \param URI The identifier of the Property that should be extracted
* \return If the Property cannot be found, <code>nullptr</code> is returned,
* otherwise the pointer to the Property is returned
*/
Property* property(const std::string& URI) const;
/**
* This method checks if a Property with the provided <code>URI</code> exists in this
* PropertyOwner (or any sub-owner). If the identifier contains one or more
* <code>.</code>, the first part of the name will be recursively extracted and is
* used as a name for a sub-owner and only the last part of the identifier is
* referring to a Property owned by PropertyOwner named by the second-but-last name.
* \return <code>true</code> if the <code>URI</code> refers to a Property;
* <code>false</code> otherwise.
*/
/**
* This method checks if a Property with the provided <code>URI</code> exists in this
* PropertyOwner (or any sub-owner). If the identifier contains one or more
* <code>.</code>, the first part of the name will be recursively extracted and is
* used as a name for a sub-owner and only the last part of the identifier is
* referring to a Property owned by PropertyOwner named by the second-but-last name.
* \return <code>true</code> if the <code>URI</code> refers to a Property;
* <code>false</code> otherwise.
*/
bool hasProperty(const std::string& URI) const;
void setPropertyOwner(PropertyOwner* owner) { _owner = owner; }
PropertyOwner* owner() const { return _owner; }
PropertyOwner* owner() const { return _owner; }
/**
* Returns a list of all sub-owners this PropertyOwner has. Each name of a sub-owner
* has to be unique with respect to other sub-owners as well as Property's owned by
* this PropertyOwner.
* \return A list of all sub-owners this PropertyOwner has
*/
/**
* Returns a list of all sub-owners this PropertyOwner has. Each name of a sub-owner
* has to be unique with respect to other sub-owners as well as Property's owned by
* this PropertyOwner.
* \return A list of all sub-owners this PropertyOwner has
*/
const std::vector<PropertyOwner*>& propertySubOwners() const;
/**
* This method returns the direct sub-owner of this PropertyOwner with the provided
* <code>name</code>. This means that <code>name</code> cannot contain any
* <code>.</code> as this character is not allowed in PropertyOwner names. If the
* <code>name</code> does not name a valid sub-owner of this PropertyOwner, a
* <code>nullptr</code> will be returned.
* \param name The name of the sub-owner that should be returned
* \return The PropertyOwner with the given <code>name</code>, or <code>nullptr</code>
*/
/**
* This method returns the direct sub-owner of this PropertyOwner with the provided
* <code>name</code>. This means that <code>name</code> cannot contain any
* <code>.</code> as this character is not allowed in PropertyOwner names. If the
* <code>name</code> does not name a valid sub-owner of this PropertyOwner, a
* <code>nullptr</code> will be returned.
* \param name The name of the sub-owner that should be returned
* \return The PropertyOwner with the given <code>name</code>, or <code>nullptr</code>
*/
PropertyOwner* propertySubOwner(const std::string& name) const;
/**
* Returns <code>true</code> if this PropertyOwner owns a sub-owner with the provided
* <code>name</code>; returns <code>false</code> otherwise.
* \param name The name of the sub-owner that should be looked up
* \return <code>true</code> if this PropertyOwner owns a sub-owner with the provided
* <code>name</code>; returns <code>false</code> otherwise
*/
/**
* Returns <code>true</code> if this PropertyOwner owns a sub-owner with the provided
* <code>name</code>; returns <code>false</code> otherwise.
* \param name The name of the sub-owner that should be looked up
* \return <code>true</code> if this PropertyOwner owns a sub-owner with the provided
* <code>name</code>; returns <code>false</code> otherwise
*/
bool hasPropertySubOwner(const std::string& name) const;
/**
* This method converts a provided <code>groupID</code>, used by the Propertys, into a
* human-readable <code>name</code> which can be used by some external application.
* \param groupID The group identifier whose human-readable name should be set
* \param name The human-readable name for the group identifier
*/
/**
* This method converts a provided <code>groupID</code>, used by the Propertys, into a
* human-readable <code>name</code> which can be used by some external application.
* \param groupID The group identifier whose human-readable name should be set
* \param name The human-readable name for the group identifier
*/
void setPropertyGroupName(std::string groupID, std::string name);
/**
* Returns the human-readable name for the <code>groupID</code> for the Propertys of
* this PropertyOwner.
* \param groupID The group identifier whose human-readable name should be returned
* \return The human readable name for the Propertys identified by
* <code>groupID</code>
*/
/**
* Returns the human-readable name for the <code>groupID</code> for the Propertys of
* this PropertyOwner.
* \param groupID The group identifier whose human-readable name should be returned
* \return The human readable name for the Propertys identified by
* <code>groupID</code>
*/
const std::string& propertyGroupName(const std::string& groupID) const;
/**
* Assigns the Property <code>prop</code> to this PropertyOwner. This method will
* check if the name of the Property is unique amongst Propertys and sub-owners in
* this PropertyOwner. This method will also inform the Property about the change in
* ownership by calling the Property::setPropertyOwner method.
* \param prop The Property whose ownership is changed.
*/
/**
* Assigns the Property <code>prop</code> to this PropertyOwner. This method will
* check if the name of the Property is unique amongst Propertys and sub-owners in
* this PropertyOwner. This method will also inform the Property about the change in
* ownership by calling the Property::setPropertyOwner method.
* \param prop The Property whose ownership is changed.
*/
void addProperty(Property* prop);
/// \see Property::addProperty(Property*)
/// \see Property::addProperty(Property*)
void addProperty(Property& prop);
/**
* Adds the provided PropertyOwner to the list of sub-owners for this PropertyOwner.
* This means that the name of the <code>owner</code> has to be unique amonst the
* direct Property's as well as other PropertyOwner's that this PropertyOwner owns.
* This uniqueness will be tested in this method.
* \param owner The owner that should be assigned to this PropertyOwner
*/
/**
* Adds the provided PropertyOwner to the list of sub-owners for this PropertyOwner.
* This means that the name of the <code>owner</code> has to be unique amonst the
* direct Property's as well as other PropertyOwner's that this PropertyOwner owns.
* This uniqueness will be tested in this method.
* \param owner The owner that should be assigned to this PropertyOwner
*/
void addPropertySubOwner(PropertyOwner* owner);
/// \see PropertyOwner::addPropertySubOwner(PropertyOwner*)
/// \see PropertyOwner::addPropertySubOwner(PropertyOwner*)
void addPropertySubOwner(PropertyOwner& owner);
/**
* Removes the Property from this PropertyOwner. Notifies the Property about this
* change by calling the Property::setPropertyOwner method with a <code>nullptr</code>
* as parameter.
* \param prop The Property that should be removed from this PropertyOwner
*/
/**
* Removes the Property from this PropertyOwner. Notifies the Property about this
* change by calling the Property::setPropertyOwner method with a <code>nullptr</code>
* as parameter.
* \param prop The Property that should be removed from this PropertyOwner
*/
void removeProperty(Property* prop);
/// \see PropertyOwner::removeProperty(Property*)
/// \see PropertyOwner::removeProperty(Property*)
void removeProperty(Property& prop);
/**
* Removes the sub-owner from this PropertyOwner.
* \param owner The PropertyOwner that should be removed
*/
/**
* Removes the sub-owner from this PropertyOwner.
* \param owner The PropertyOwner that should be removed
*/
void removePropertySubOwner(PropertyOwner* owner);
/// \see PropertyOwner::removePropertySubOwner(PropertyOwner*)
/// \see PropertyOwner::removePropertySubOwner(PropertyOwner*)
void removePropertySubOwner(PropertyOwner& owner);
private:
/// The name of this PropertyOwner
/// The name of this PropertyOwner
std::string _name;
/// The owner of this PropertyOwner
PropertyOwner* _owner;
/// A list of all registered Property's
/// The owner of this PropertyOwner
PropertyOwner* _owner;
/// A list of all registered Property's
std::vector<Property*> _properties;
/// A list of all sub-owners
/// A list of all sub-owners
std::vector<PropertyOwner*> _subOwners;
/// The associations between group identifiers of Property's and human-readable names
/// The associations between group identifiers of Property's and human-readable names
std::map<std::string, std::string> _groupNames;
};
@@ -34,23 +34,23 @@ namespace properties {
class SelectionProperty : public TemplateProperty<std::vector<int>> {
public:
struct Option {
int value;
std::string description;
};
struct Option {
int value;
std::string description;
};
SelectionProperty(std::string identifier, std::string guiName);
void addOption(Option option);
const std::vector<Option>& options() const;
SelectionProperty(std::string identifier, std::string guiName);
void addOption(Option option);
const std::vector<Option>& options() const;
private:
static const std::string OptionsKey;
std::string generateAdditionalDescription() const;
static const std::string OptionsKey;
std::string generateAdditionalDescription() const;
/// The list of options which have been registered with this OptionProperty
std::vector<Option> _options;
std::vector<int> _values;
/// The list of options which have been registered with this OptionProperty
std::vector<Option> _options;
std::vector<int> _values;
};
template <>
+95 -95
View File
@@ -52,135 +52,135 @@ namespace properties {
template <typename T>
class TemplateProperty : public Property {
public:
typedef T ValueType;
typedef T ValueType;
/**
* The constructor initializing the TemplateProperty with the provided
* <code>identifier</code> and human-readable <code>guiName</code>. The default value
* for the stored type <code>T</code> is retrieved using the PropertyDelegate's
* PropertyDelegate::defaultValue method, which must be specialized for new types or
* a compile-error will occur.
* \param identifier The identifier that is used for this TemplateProperty
* \param guiName The human-readable GUI name for this TemplateProperty
*/
/**
* The constructor initializing the TemplateProperty with the provided
* <code>identifier</code> and human-readable <code>guiName</code>. The default value
* for the stored type <code>T</code> is retrieved using the PropertyDelegate's
* PropertyDelegate::defaultValue method, which must be specialized for new types or
* a compile-error will occur.
* \param identifier The identifier that is used for this TemplateProperty
* \param guiName The human-readable GUI name for this TemplateProperty
*/
TemplateProperty(std::string identifier, std::string guiName);
/**
* The constructor initializing the TemplateProperty with the provided
* <code>identifier</code>, human-readable <code>guiName</code> and provided
* <code>value</code>.
*/
/**
* The constructor initializing the TemplateProperty with the provided
* <code>identifier</code>, human-readable <code>guiName</code> and provided
* <code>value</code>.
*/
TemplateProperty(std::string identifier, std::string guiName, T value);
/**
* Returns the class name for this TemplateProperty. The default implementation makes
* a call to the PropertyDelegate::className method with the template parameter
* <code>T</code> as argument. For this to work, that method needs to be specialized
* to return the correct class name for the new template parameter T, or a
* compile-time error will occur.
* \return The class name for the TemplateProperty
*/
/**
* Returns the class name for this TemplateProperty. The default implementation makes
* a call to the PropertyDelegate::className method with the template parameter
* <code>T</code> as argument. For this to work, that method needs to be specialized
* to return the correct class name for the new template parameter T, or a
* compile-time error will occur.
* \return The class name for the TemplateProperty
*/
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 ghoul::any object.
* \return The stored value packed into a ghoul::any object
*/
virtual ghoul::any get() const override;
/**
* Sets the value fro the provided ghoul::any object. If the types between
/**
* Sets the value fro the provided ghoul::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;
/**
* 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
/**
* 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
* assign it.
* \return The type info object describing the template parameter <code>T</code>
*/
* \return The type info object describing the template parameter <code>T</code>
*/
virtual const std::type_info& type() const override;
/**
* This method encodes the stored value into a Lua object and pushes that object onto
* the stack. The encoding is performed by calling PropertyDelegate::toLuaValue with
* the template parameter <code>T</code> as an argument. This method has to be
* specialized for each new type, or a compile-time error will occur.
* \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 getLuaValue(lua_State* state) const override;
/**
* This method encodes the stored value into a Lua object and pushes that object onto
* the stack. The encoding is performed by calling PropertyDelegate::toLuaValue with
* the template parameter <code>T</code> as an argument. This method has to be
* specialized for each new type, or a compile-time error will occur.
* \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 getLuaValue(lua_State* state) const override;
/**
* Sets the value of this TemplateProprty by decoding the object at the top of the Lua
* stack and, if successful, assigning it using the Property::set method. The decoding
* is performed by calling the PropertyDelegate::fromLuaValue with the template
* parameter <code>T</code> as argument. If the decoding is successful, the new value
* is set, otherwise it remains unchanged.
* \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 setLuaValue(lua_State* state) override;
/**
* Sets the value of this TemplateProprty by decoding the object at the top of the Lua
* stack and, if successful, assigning it using the Property::set method. The decoding
* is performed by calling the PropertyDelegate::fromLuaValue with the template
* parameter <code>T</code> as argument. If the decoding is successful, the new value
* is set, otherwise it remains unchanged.
* \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 setLuaValue(lua_State* state) override;
/// \see Property::typeLua
int typeLua() const override;
/// \see Property::typeLua
int typeLua() const override;
bool getStringValue(std::string& value) const override;
bool setStringValue(std::string value) override;
/**
* Returns the description for this TemplateProperty as a Lua script that returns a
* table on execution
* \return The description for this TemplateProperty
*/
//virtual std::string description() override;
/**
* Returns the description for this TemplateProperty as a Lua script that returns a
* table on execution
* \return The description for this TemplateProperty
*/
//virtual std::string description() override;
/**
* This operator allows the TemplateProperty to be used almost transparently as if it
* was of the type <code>T</code>. It makes assignments such as
* <code>T v = property;</code> possible by allowing implicit casts (even though,
* internally, not casts are performed. This method is next to zero overhead).
* \return The internal representation of the Property
*/
/**
* This operator allows the TemplateProperty to be used almost transparently as if it
* was of the type <code>T</code>. It makes assignments such as
* <code>T v = property;</code> possible by allowing implicit casts (even though,
* internally, not casts are performed. This method is next to zero overhead).
* \return The internal representation of the Property
*/
operator T();
/**
* This operator allows the TemplateProperty to be used almost transparently as if it
* was of the type <code>T</code>. It makes assignments such as
* <code>T v = property;</code> possible by allowing implicit casts (even though,
* internally, not casts are performed. This method is next to zero overhead).
* \return The internal representation of the Property
*/
operator T() const;
/**
* This operator allows the TemplateProperty to be used almost transparently as if it
* was of the type <code>T</code>. It makes assignments such as
* <code>T v = property;</code> possible by allowing implicit casts (even though,
* internally, not casts are performed. This method is next to zero overhead).
* \return The internal representation of the Property
*/
operator T() const;
/**
* The assignment operator allows the TemplateProperty's value to be set without using
* the TemplateProperty::set method. It will be done internally by thos method and it
* allows assignments such as <code>prop = T(1)</code>.
* \param val The value that should be set.
*/
/**
* The assignment operator allows the TemplateProperty's value to be set without using
* the TemplateProperty::set method. It will be done internally by thos method and it
* allows assignments such as <code>prop = T(1)</code>.
* \param val The value that should be set.
*/
TemplateProperty<T>& operator=(T val);
/**
* These method sets the stored value to the provided value <code>val</code>,
* moving it into place. This move only happens if the provided value <code>val</code>
* is different from the stored value, which needs an operator== to exist for the type
* <code>T</code>. If the value are different, the listeners are notified.
* \param val The new value for this TemplateProperty
*/
/**
* These method sets the stored value to the provided value <code>val</code>,
* moving it into place. This move only happens if the provided value <code>val</code>
* is different from the stored value, which needs an operator== to exist for the type
* <code>T</code>. If the value are different, the listeners are notified.
* \param val The new value for this TemplateProperty
*/
virtual void setValue(T val);
/**
* Returns the currently stored value.
* \return The currently stored value
*/
/**
* Returns the currently stored value.
* \return The currently stored value
*/
T value() const;
protected:
/// The value that this TemplateProperty currently stores
/// The value that this TemplateProperty currently stores
T _value;
};
@@ -29,7 +29,7 @@ namespace properties {
// The following macros can be used to quickly generate the necessary PropertyDelegate
// specializations required by the TemplateProperty class. Use the
// REGISTER_TEMPLATEPROPERTY_HEADER macro in the header file and the
// REGISTER_TEMPLATEPROPERTY_HEADER macro in the header file and the
// REGISTER_TEMPLATEPROPERTY_SOURCE macro in the source file of your new specialization of
// a TemplateProperty
@@ -77,13 +77,13 @@ namespace properties {
// DEFAULT_VALUE = The value (as type T) which should be used as a default value
// FROM_LUA_LAMBDA_EXPRESSION = A lambda expression receiving a lua_State* as the first
// parameter, a bool& as the second parameter and returning
// a value T. It is used by the fromLua method of
// TemplateProperty. The lambda expression must extract the
// stored value from the lua_State, return the value and
// report success in the second argument
// a value T. It is used by the fromLua method of
// TemplateProperty. The lambda expression must extract the
// stored value from the lua_State, return the value and
// report success in the second argument
// TO_LUA_LAMBDA_EXPRESSION = A lambda expression receiving a lua_State*, a value T and
// returning a bool. The lambda expression must encode the
// value T onto the lua_State stack and return the success
// value T onto the lua_State stack and return the success
// LUA_TYPE = The Lua type that will be produced/consumed by the previous
// Lambda expressions
#define REGISTER_TEMPLATEPROPERTY_SOURCE(CLASS_NAME, TYPE, DEFAULT_VALUE, \
@@ -170,7 +170,7 @@ std::string TemplateProperty<T>::className() const {
//template <typename T>
//std::string TemplateProperty<T>::description() {
// return
// return
//}
template <typename T>
@@ -180,7 +180,7 @@ TemplateProperty<T>::operator T() {
template <typename T>
TemplateProperty<T>::operator T() const {
return _value;
return _value;
}
template <typename T>
@@ -198,11 +198,11 @@ T openspace::properties::TemplateProperty<T>::value() const
template <typename T>
void openspace::properties::TemplateProperty<T>::setValue(T val)
{
const bool changed = (val != _value);
if (changed) {
_value = std::move(val);
notifyListener();
}
const bool changed = (val != _value);
if (changed) {
_value = std::move(val);
notifyListener();
}
}
template <typename T>
@@ -220,14 +220,14 @@ template <typename T>
void TemplateProperty<T>::set(ghoul::any value) {
try {
T v = ghoul::any_cast<T>(std::move(value));
if (v != _value) {
_value = std::move(v);
notifyListener();
}
if (v != _value) {
_value = std::move(v);
notifyListener();
}
}
catch (ghoul::bad_any_cast&) {
LERRORC("TemplateProperty", "Illegal cast from '" << value.type().name()
<< "' to '" << typeid(T).name() << "'");
<< "' to '" << typeid(T).name() << "'");
}
}
@@ -244,16 +244,16 @@ bool TemplateProperty<T>::getLuaValue(lua_State* state) const {
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));
return success;
bool success = false;
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromLuaValue<T>(state, success);
if (success)
set(ghoul::any(thisValue));
return success;
}
template <typename T>
int TemplateProperty<T>::typeLua() const {
return PropertyDelegate<TemplateProperty<T>>::typeLua();
return PropertyDelegate<TemplateProperty<T>>::typeLua();
}
template <typename T>
+25 -25
View File
@@ -36,34 +36,34 @@ namespace properties {
*/
class TriggerProperty : public Property {
public:
/**
* Initializes the TriggerProperty by delegating the <code>identifier</code> and
* <code>guiName</code> to the Property constructor.
* \param identifier The unique identifier used for this Property
* \param guiName The human-readable name of this Property
*/
TriggerProperty(std::string identifier, std::string guiName);
/**
* Initializes the TriggerProperty by delegating the <code>identifier</code> and
* <code>guiName</code> to the Property constructor.
* \param identifier The unique identifier used for this Property
* \param guiName The human-readable name of this Property
*/
TriggerProperty(std::string identifier, std::string guiName);
/**
* Returns the class name <code>TriggerProperty</code>.
* \return The class name <code>TriggerProperty</code>
*/
std::string className() const;
/**
* Returns the class name <code>TriggerProperty</code>.
* \return The class name <code>TriggerProperty</code>
*/
std::string className() const;
/**
* Accepts only the <code>LUA_TNIL</code> type and will notify all the listeners
* that the event has been triggered.
* \param state The unused Lua state
* \return Returns always <code>true</code>
*/
bool setLuaValue(lua_State* state);
/**
* Accepts only the <code>LUA_TNIL</code> type and will notify all the listeners
* that the event has been triggered.
* \param state The unused Lua state
* \return Returns always <code>true</code>
*/
bool setLuaValue(lua_State* state);
/**
* Silently ignores any value that is passed into this function and will trigger the
* listeners regardless of the value
* \param value The ignored value
*/
void set(ghoul::any value);
/**
* Silently ignores any value that is passed into this function and will trigger the
* listeners regardless of the value
* \param value The ignored value
*/
void set(ghoul::any value);
};
} // namespace properties