![]() |
ImFusion C++ SDK 4.5.0
|
#include <ImFusion/Core/PolymorphicSubProperty.h>
This class extends SubProperty to represent a nested record of a polymorphic Configurable entity. More...
This class extends SubProperty to represent a nested record of a polymorphic Configurable entity.
In contrast to a regular SubProperty (modeling value semantics for the nested entities), this class enables you to model polymorphic semantics where the template type of PolymorphicSubProperty defines a base interface but you can also store, serialize and deserialize derived classes. Therefore, you must meet the following requirements:
Example usage:
The signal signalValueChanged is only emitted whenever the nested object is changed using setValue(), configure(), or if its Configurable::signalParametersChanged was emitted.
By convention, public SubProperties members use the p_ prefix for the variable name (instead of the common m_ prefix) in order to make their semantics easier to identify in code.
| T | Underlying element type that will be wrapped in a std::unique_ptr. T must implement std::string id() const and std::unique_ptr<T> clone() const methods. |
Public Types | |
| using | CreateFromId = std::function<std::unique_ptr<T>(const std::string&)> |
| using | Base = SubProperty<std::unique_ptr<T>> |
Public Member Functions | |
| template<typename U> | |
| PolymorphicSubProperty (const std::string &name, U &&value, Configurable &parent, CreateFromId createFromId) | |
| Creates a PolymorphicSubProperty. | |
| PolymorphicSubProperty (const PolymorphicSubProperty &other) | |
| PolymorphicSubProperty (PolymorphicSubProperty &&)=default | |
| PolymorphicSubProperty & | operator= (const PolymorphicSubProperty &other) |
| PolymorphicSubProperty & | operator= (PolymorphicSubProperty &&)=default |
| void | configure (const Properties *p) override |
| Configure this parameter/sub property by de-serializing the given Properties. | |
| void | configuration (Properties *p) const override |
| Serialize the current parameter/sub property state into the given Properties object. | |
| SubProperty< T > & | operator= (const SubProperty< T > &other) |
| Assigns the value and attributes from another SubProperty instance of the same type and emits signalValueChanged. | |
| SubProperty< T > & | operator= (SubProperty< T > &&other) |
| Assigns the value and attributes from another SubProperty instance of the same type and emits signalValueChanged. | |
| SubProperty< T > & | operator= (U &&value) |
| Assign a new value to this SubProperty, emits signalValueChanged. | |
| void | setValue (U &&value) |
| Assign a new value to this SubProperty, emits signalValueChanged. | |
| const T & | value () const |
| Access the underlying value. | |
| T & | value () |
| Public Member Functions inherited from ImFusion::SubProperty< std::unique_ptr< T > > | |
| SubProperty (const std::string &name, U &&value) | |
| Creates a SubProperty that will be configured under the given name and with the given initial value. | |
| SubProperty (const std::string &name, U &&value, Configurable *parent) | |
| Create a SubProperty that is directly registered to the parent Configurable instance. | |
| SubProperty (const std::string &name, U &&value, Configurable &parent) | |
| SubProperty (const SubProperty< T > &other) | |
| SubProperty (SubProperty< T > &&other) | |
| SubProperty< T > & | operator= (const SubProperty< T > &other) |
| Assigns the value and attributes from another SubProperty instance of the same type and emits signalValueChanged. | |
| SubProperty< T > & | operator= (SubProperty< T > &&other) |
| Assigns the value and attributes from another SubProperty instance of the same type and emits signalValueChanged. | |
| SubProperty< T > & | operator= (U &&value) |
| Assign a new value to this SubProperty, emits signalValueChanged. | |
| void | setValue (U &&value) |
| Assign a new value to this SubProperty, emits signalValueChanged. | |
| const T & | value () const |
| Access the underlying value. | |
| T & | value () |
| const T * | operator-> () const |
| Access the underlying value. | |
| T * | operator-> () |
| void | configure (const Properties *p) override |
| Configure this parameter/sub property by de-serializing the given Properties. | |
| void | configuration (Properties *p) const override |
| Serialize the current parameter/sub property state into the given Properties object. | |
| Public Member Functions inherited from ImFusion::ParameterBase | |
| ParameterBase (const std::string &name) | |
| const Configurable * | parent () const |
| Return the parent Configurable instance that this parameter is registered with. | |
| virtual const std::string & | name () const |
| Returns parameter name, can only be set during construction. | |
| void | setAttribute (const std::string &key, const std::string &value) |
| Add the given attribute key-value pair to the set of parameter attributes. | |
| void | removeAttribute (const std::string &key) |
| Remove the attribute with the given key. | |
| const std::map< std::string, std::string > & | attributes () const |
| Get the attribute map. | |
| void | setLabel (const std::string &label) |
| Sets an optional label for the Parameter if displayed in the UI. | |
| void | addDeprecatedName (const std::string &deprecatedName) |
| Adds an optional alternative parameter name that should be used for param lookup for during configure() in case de-serialization from m_name was not successful. | |
| const std::vector< std::string > & | deprecatedNames () const |
| Returns the list of deprecated parameter names that should be used for param lookup (see addDeprecatedName()). | |
| Public Member Functions inherited from ImFusion::SignalReceiver | |
| SignalReceiver ()=default | |
| Default constructor. | |
| SignalReceiver (const SignalReceiver &other) | |
| Copy constructor, does not copy any existing signal connections from other. | |
| SignalReceiver & | operator= (SignalReceiver rhs) |
| Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs. | |
| virtual | ~SignalReceiver () |
| Virtual destructor disconnects from all connected signals. | |
Additional Inherited Members | |
| Public Attributes inherited from ImFusion::ParameterBase | |
| Signal | signalValueChanged |
| Signal gets emitted when the underlying value of the Parameter/SubProperty has changed (either through setValue() or configure()). | |
| Protected Member Functions inherited from ImFusion::ParameterBase | |
| void | setParentFromCopy (const ParameterBase &other) |
| Helper function to be called from a copy/move ctor in order to correctly set the parent relation ship to the new parent Configurable. | |
| Protected Member Functions inherited from ImFusion::SignalReceiver | |
| void | disconnectAll () |
| Disconnects all existing connections. | |
| Protected Attributes inherited from ImFusion::SubProperty< std::unique_ptr< T > > | |
| T | m_value |
| Protected Attributes inherited from ImFusion::ParameterBase | |
| Configurable * | m_parent = nullptr |
| const std::string | m_name |
| std::vector< std::string > | m_deprecatedNames |
| std::map< std::string, std::string > | m_attributes |
| ImFusion::PolymorphicSubProperty< T >::PolymorphicSubProperty | ( | const std::string & | name, |
| U && | value, | ||
| Configurable & | parent, | ||
| CreateFromId | createFromId ) |
Creates a PolymorphicSubProperty.
| name | The name under which this property will be serialized |
| value | Initial value for the property |
| parent | Parent Configurable instance for registration |
| createFromId | Factory function that creates objects from id strings. Note: The id <nullptr> is handled automatically by the system and should not be handled by this factory function. |
|
overridevirtual |
Configure this parameter/sub property by de-serializing the given Properties.
Implements ImFusion::ParameterBase.
|
overridevirtual |
Serialize the current parameter/sub property state into the given Properties object.
Implements ImFusion::ParameterBase.
| SubProperty< T > & ImFusion::SubProperty< T >::operator= | ( | const SubProperty< T > & | other | ) |
Assigns the value and attributes from another SubProperty instance of the same type and emits signalValueChanged.
Expects name and deprecated names to be the same and will not change the parent relationship. Use *this = other.value() if you want to assign only the value from other
| SubProperty< T > & ImFusion::SubProperty< T >::operator= | ( | SubProperty< T > && | other | ) |
Assigns the value and attributes from another SubProperty instance of the same type and emits signalValueChanged.
Expects name and deprecated names to be the same and will not change the parent relationship. Use *this = other.value() if you want to assign only the value from other