ImFusion C++ SDK 4.5.0
ImFusion::SubPropertyList< T > Class Template Reference

#include <ImFusion/Core/SubPropertyList.h>

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

Inheritance diagram for ImFusion::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
using ConstIterator = typename std::vector<T>::const_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.
SubPropertyList< T > & insert (Iterator position, T &&value)
 Inserts a new value into this SubPropertyList before position, emits signalValueChanged.
Iterator erase (Iterator position)
 Erases the element at position.
Iterator erase (ConstIterator position)
Iterator erase (Iterator first, Iterator last)
 Erases the elements in the range [first, last).
Iterator erase (ConstIterator first, ConstIterator last)
void clear ()
 Removes all elements from the container.
auto begin () const noexcept
 Returns an iterator to the first element.
auto begin () noexcept
ConstIterator cbegin () const noexcept
 Returns a const iterator to the first element.
auto end () const noexcept
 Returns an iterator to one past the last element.
auto end () noexcept
ConstIterator cend () const noexcept
 Returns a const iterator to one past the last element.
T & front () noexcept
 Returns a reference to the first element in the container.
const T & front () const noexcept
 Returns a const reference to the first element in the container.
T & back () noexcept
 Returns a reference to the last element in the container.
const T & back () const noexcept
 Returns a const reference to the last element in the container.
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 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::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 ImFusion::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 ImFusion::ParameterBase
Configurable * m_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 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.

Constructor & Destructor Documentation

◆ SubPropertyList()

template<typename T>
ImFusion::SubPropertyList< 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 > & ImFusion::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 > & ImFusion::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 > & ImFusion::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.

◆ erase() [1/2]

template<typename T>
Iterator ImFusion::SubPropertyList< T >::erase ( Iterator position)
inline

Erases the element at position.

This function behaves like std::vector::erase(position). The iterator position must refer to a valid element within this container. Passing an invalid iterator or an iterator from a different container results in undefined behavior (as for standard library containers). Returns an iterator to the element that follows the erased element, or end() if the erased element was the last one. Emits signalValueChanged once.

◆ erase() [2/2]

template<typename T>
Iterator ImFusion::SubPropertyList< T >::erase ( Iterator first,
Iterator last )
inline

Erases the elements in the range [first, last).

This function behaves like std::vector::erase(first, last). The iterators first and last must refer to a valid range within this container. Passing invalid iterators, iterators from a different container, or an invalid range results in undefined behavior (as for standard library containers). Returns an iterator to the element that follows the last removed element, or end() if last == end(). If first == last, no elements are erased, the container is not modified, and first is returned. Emits signalValueChanged once if at least one element is erased.

◆ clear()

template<typename T>
void ImFusion::SubPropertyList< T >::clear ( )

Removes all elements from the container.

This function behaves like std::vector::clear(). After the call, size() == 0 and empty() == true. Emits signalValueChanged once if the container was non-empty.

◆ front() [1/2]

template<typename T>
T & ImFusion::SubPropertyList< T >::front ( )
noexcept

Returns a reference to the first element in the container.

This function behaves like the standard library containers (e.g. std::vector::front()). The container must not be empty. Calling front() on an empty container results in undefined behavior (as with standard library containers). It is the caller's responsibility to ensure the container is non-empty, typically by checking empty() before calling front().

◆ front() [2/2]

template<typename T>
const T & ImFusion::SubPropertyList< T >::front ( ) const
noexcept

Returns a const reference to the first element in the container.

This function behaves like the standard library containers (e.g. std::vector::front()). The container must not be empty. Calling front() on an empty container results in undefined behavior (as with standard library containers). It is the caller's responsibility to ensure the container is non-empty, typically by checking empty() before calling front().

◆ back() [1/2]

template<typename T>
T & ImFusion::SubPropertyList< T >::back ( )
noexcept

Returns a reference to the last element in the container.

This function behaves like the standard library containers (e.g. std::vector::back()). The container must not be empty. Calling back() on an empty container results in undefined behavior (as with standard library containers). It is the caller's responsibility to ensure the container is non-empty, typically by checking empty() before calling back().

◆ back() [2/2]

template<typename T>
const T & ImFusion::SubPropertyList< T >::back ( ) const
noexcept

Returns a const reference to the last element in the container.

This function behaves like the standard library containers (e.g. std::vector::back()). The container must not be empty. Calling back() on an empty container results in undefined behavior (as with standard library containers). It is the caller's responsibility to ensure the container is non-empty, typically by checking empty() before calling back().

◆ configure()

template<typename T>
void ImFusion::SubPropertyList< T >::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 ImFusion::ParameterBase.

◆ configuration()

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

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

Implements ImFusion::ParameterBase.


The documentation for this class was generated from the following file:
  • ImFusion/Core/SubPropertyList.h
Search Tab / S to search, Esc to close