ImFusion SDK 4.3
SubPropertyList< T > Class Template Reference

#include <ImFusion/Core/SubPropertyList.h>

The SubPropertyList class represents nested records of Configurable entities. More...

+ Inheritance diagram for SubPropertyList< T >:

Detailed Description

template<typename T>
class ImFusion::SubPropertyList< T >

The SubPropertyList class represents nested records of Configurable entities.

It is very similar to SubProperty, with the addition that you can store multiple Configurable entities for which it also offers functionality to conveniently access them. The SubPropertyList class provides functions like the index operator, for easy access of the nested elements:

struct InnerStruct : public Configurable {
Parameter<int> p_count = {"count", 0, this};
}
struct OuterStruct : public Configurable {
SubPropertyList<InnerStruct> p_innerStructList = {"InnerStructList", {InnerStruct()}, this};
}
OuterStruct o;
o.p_innerStructList[0].p_count = 42;
The Parameter class represents a single parameter of a Configurable entity.
Definition Parameter.h:53

The nested objects are stored as multiple sub-properties inside the given Properties preserving the order and using the name of the SubPropertyList.

The signal signalValueChanged is only emitted whenever the nested objects are changed using setValue(), configure(), or if one of their Configurable::signalParametersChanged was emitted.

Note: In contrast to SubProperty, SubPropertyList currently only supports T being a regular value type implementing Configurable.

Template Parameters
TUnderlying type of the parameter, must be default-constructible, copyable and implement the Configurable interface.
See also
Parameter, SubProperty

Public Types

using Iterator = typename std::vector<T>::iterator
 

Public Member Functions

 SubPropertyList (const std::string &name, const std::vector< T > &init, Configurable *parent=nullptr)
 Creates a SubPropertyList that will be configured under the given name and with the given initial value.
 
 SubPropertyList (const std::string &name, const std::vector< T > &init, Configurable &parent)
 
 SubPropertyList (const SubPropertyList< T > &other)
 
 SubPropertyList (SubPropertyList< T > &&other) noexcept
 
SubPropertyList< T > & operator= (const SubPropertyList< T > &other)
 Assigns the value and attributes from another SubPropertyList instance of the same type and emits signalValueChanged.
 
SubPropertyList< T > & operator= (SubPropertyList< T > &other)
 Assigns the value and attributes from another SubPropertyList instance of the same type and emits signalValueChanged.
 
SubPropertyList< T > & operator= (SubPropertyList< T > &&other) noexcept
 Assigns the value and attributes from another SubPropertyList instance of the same type and emits signalValueChanged.
 
SubPropertyList< T > & operator= (const std::vector< T > &value)
 Assign a new value to this SubPropertyList, emits signalValueChanged.
 
void setValue (const std::vector< T > &value)
 Assign a new value to this SubPropertyList, emits signalValueChanged.
 
SubPropertyList< T > & append (T &&value)
 Append a new value to this SubPropertyList, emits signalValueChanged.
 
void erase (Iterator position)
 Erase an element from the SubPropertyList, emits signalValueChanged.
 
auto begin () const noexcept
 
auto begin () noexcept
 
auto end () const noexcept
 
auto end () noexcept
 
const auto & operator[] (size_t pos) const
 
auto & operator[] (size_t pos)
 
bool empty () const
 
size_t size () const
 
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 ParameterBase
 ParameterBase (const std::string &name)
 
const Configurableparent () const
 Return the parent Configurable instance that this parameter is registered with.
 
virtual const std::stringname () 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 SignalReceiver
 SignalReceiver ()=default
 Default constructor.
 
 SignalReceiver (const SignalReceiver &other)
 Copy constructor, does not copy any existing signal connections from other.
 
SignalReceiveroperator= (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.
 

Protected Attributes

std::vector< T > m_value
 
- Protected Attributes inherited from ParameterBase
Configurablem_parent = nullptr
 
const std::string m_name
 
std::vector< std::stringm_deprecatedNames
 
std::map< std::string, std::stringm_attributes
 

Additional Inherited Members

- Public Attributes inherited from 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 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 SignalReceiver
void disconnectAll ()
 Disconnects all existing connections.
 

Constructor & Destructor Documentation

◆ SubPropertyList()

template<typename T>
SubPropertyList ( const std::string & name,
const std::vector< T > & init,
Configurable * parent = nullptr )

Creates a SubPropertyList that will be configured under the given name and with the given initial value.

If parent != nullptr creates a SubPropertyList that is directly registered to the parent Configurable instance. The parent instance is stored and thus must have a lifetime longer than this object.

Member Function Documentation

◆ operator=() [1/3]

template<typename T>
SubPropertyList< T > & operator= ( const SubPropertyList< T > & other)

Assigns the value and attributes from another SubPropertyList instance of the same type and emits signalValueChanged.

Expects name and deprecated names to be the same and will not change the parent relationship.

◆ operator=() [2/3]

template<typename T>
SubPropertyList< T > & operator= ( SubPropertyList< T > & other)

Assigns the value and attributes from another SubPropertyList instance of the same type and emits signalValueChanged.

Expects name and deprecated names to be the same and will not change the parent relationship.

Note
This implementation is required as otherwise operator=(SubPropertyList<T>&&) will be picked up as non-const assign operator.

◆ operator=() [3/3]

template<typename T>
SubPropertyList< T > & operator= ( SubPropertyList< T > && other)
noexcept

Assigns the value and attributes from another SubPropertyList instance of the same type and emits signalValueChanged.

Expects name and deprecated names to be the same and will not change the parent relationship.

◆ configure()

template<typename T>
void configure ( const Properties * p)
overridevirtual

Configure this parameter/sub property by de-serializing the given Properties.

The behavior of configure() is as follows:

  • Configure will clear and resize the payload to the number of present sub-properties in p, i.e. delete all elements of the payload and append default-constructed T if there are sub-properties present in p. Therefore, T must be default-constructible.
  • Subsequently, the elements in the payload will get configured by calling their configure() method in order with the sub-properties in p. Thus, the order of the sub-properties is preserved.

Implements ParameterBase.

◆ configuration()

template<typename T>
void configuration ( Properties * p) const
overridevirtual

Serialize the current parameter/sub property state into the given Properties object.

Implements ParameterBase.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close