DynExp
Highly flexible laboratory automation for dynamically changing experiments.
DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > > Class Template Reference

Parameter for link lists to multiple Object. If LinkType is derived from ObjectLinkBase, then extend TypedParamBase's functionality by providing link instantiation functionality and by overriding AddToDialogChild(). More...

+ Inheritance diagram for DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >:

Public Types

using ObjectType = typename LinkType::ObjectType
 Type of the linked Object. More...
 
using ManagerType = ManagerTypeOfObjectType_t< ObjectType >
 Type of the manager managing the linked Object. More...
 
- Public Types inherited from DynExp::ParamsBase::TypedListParamBase< ParamType >
using UnderlyingType = std::vector< ParamType >
 List type to be used for the parameter. More...
 

Public Member Functions

 ListParam (ParamsBase &Owner, const ManagerType &Manager, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, std::string_view IconResourcePath={}, bool Optional=false, bool NeedsResetToApplyChange=true)
 Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog (UserEditable is set to true). More...
 
const auto & GetManager () const noexcept
 Returns the manager instance containing the Object the link refers to. More...
 
bool ContainsID () const noexcept
 Checks whether at least one item has been assigned to this parameter. Assigned items are not allowed to have the ID 'ItemIDNotSet' (see ValidateValues). More...
 
const auto & GetLinks () const noexcept
 Returns a list of links of type LinkType derived from ObjectLinkBase to the Object this parameter refers to. More...
 
void MakeLinks ()
 Retrives the linked resource using its ID stored in the parameter and establishes a link to the resource. Before using the resource, it has to be locked through the link by the owner of this parameter. This function is also called by ParamsConfigDialog::accept(). More...
 
auto & operator= (const UnderlyingType &NewValues)
 Assigns new values to this parameter. The operator cannot be accessed by Object because this function is not const. More...
 
- Public Member Functions inherited from DynExp::ParamsBase::LinkListParamBase
auto & operator= (const UnderlyingType &NewValues)
 Assigns new values to this parameter. The operator cannot be accessed by Object because this function is not const. More...
 
- Public Member Functions inherited from DynExp::LinkBase
 LinkBase (std::string_view IconResourcePath={}, bool Optional=false)
 Constructs a LinkBase object. More...
 
void EnsureReadyState ()
 Makes sure that the object where this link parameter points to is in a ready state. Only to be called by main thread. Otherwise, RunnableObject::Run() throws Util::InvalidCallException. More...
 
bool IsReady ()
 Returns whether the object where this link parameter points to is in a ready state. More...
 
std::string_view GetLinkTitle () const noexcept
 Returns a reference to this link parameter's title. More...
 
ItemIDListType GetLinkedIDs () const
 Returns a list of all object IDs assigned to this parameter. More...
 
const CommonResourceManagerBaseGetCommonManager () const noexcept
 This function can be used to determine the object type the parameter is expecting by comparing the resource manager's address to resource managers owned by a DynExpCore instance. More...
 
std::string_view GetIconResourcePath () const noexcept
 
bool IsOptional () const noexcept
 
- Public Member Functions inherited from DynExp::ParamsBase::TypedListParamBase< ParamType >
const auto & GetDefaultValue () const noexcept
 Returns this parameter's default value list. Thread-safe since a reference to a const member variable is returned. More...
 
const auto & Get () const noexcept
 Returns the parameter's values. More...
 
auto & operator= (const UnderlyingType &NewValues)
 Assigns new values to this parameter. The operator cannot be accessed by Object because this function is not const. More...
 
- Public Member Functions inherited from DynExp::ParamsBase::ParamBase
 ParamBase (const ParamBase &)=delete
 
ParamBaseoperator= (const ParamBase &)=delete
 
QDomElement ToXMLNode (QDomDocument &Document) const
 Converts this parameter to a Qt dom element (describing an XML node containing this parameter's name and value). More...
 
void FromXMLNode (const QDomElement &XMLElement)
 Restores this parameter's value from the given Qt dom element (describing an XML node) More...
 
bool Validate ()
 Checks whether a valid value is assigned to this parameter. This function is not const since it is also intended to reset the parameter if it is invalid. More...
 
void Reset ()
 Resets this parameter to its default value. More...
 
bool IsUserEditable () const noexcept
 Returns ParamBase::UserEditable. More...
 
std::string_view GetParamName () const noexcept
 Returns ParamBase::ParamName. More...
 
std::string_view GetParamTitle () const noexcept
 Returns ParamBase::ParamTitle. More...
 
std::string_view GetParamDescription () const noexcept
 Returns ParamBase::ParamDescription. More...
 
bool GetNeedsResetToApplyChange () const noexcept
 Returns ParamBase::NeedsResetToApplyChange. More...
 

Private Member Functions

virtual const CommonResourceManagerBaseGetCommonManagerChild () const noexcept override
 This function can be used to determine the object type the parameter is expecting by comparing the resource manager's address to resource managers owned by a DynExpCore instance. More...
 
virtual void FromXMLNodeChild (const QDomElement &XMLElement) override
 Restores this parameter's value from the given Qt dom element (describing an XML node) More...
 
virtual void AddToDialogChild (ParamsConfigDialog &Dialog) override final
 Appends this parameter to a settings dialog making it configurable by the user. More...
 
bool ValidateValues (const typename LinkListParamBase::UnderlyingType &NewValues) const override
 Ensures that list entries do not have the ItemIDNotSet value. More...
 
void EnsureReadyStateChild () override final
 Thread-safe since only main thread is allowed to change parameters and to call this funtion. More...
 
bool IsReadyChild () override final
 Returns whether the object where this link parameter points to is in a ready state. More...
 

Private Attributes

const ManagerTypeManager
 Reference to the manager instance containing the Object the link refers to. Managers live longer than their managed Objects which own the Params. More...
 
std::vector< LinkType > Links
 List of links of type LinkType derived from ObjectLinkBase referring to the linked Object. The links can be locked to access the underlying resources in a thread-safe way. More...
 

Additional Inherited Members

- Public Attributes inherited from DynExp::ParamsBase::ParamBase
ParamsBaseOnlyType ParamsBaseOnly
 Provides the class ParamsBase access to some private members of class ParamBase. More...
 
- Protected Member Functions inherited from DynExp::ParamsBase::LinkListParamBase
 LinkListParamBase (ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, std::string_view IconResourcePath={}, bool Optional=false)
 Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog (UserEditable is set to true). More...
 
- Protected Member Functions inherited from DynExp::LinkBase
virtual ~LinkBase ()
 
template<typename ResourceManagerType >
auto ShareResource (const ResourceManagerType &Manager, ItemIDType ID)
 Returns a shared_ptr pointing to the resource with the given ID contained in the given resource manager Manager. The returned pointer points to a non-const instance of class Object. Throws an exception of type Util::NotFoundException if the resource is not found. More...
 
template<typename ObjectType >
auto MakeObjectIDsWithLabels (const ManagerTypeOfObjectType_t< ObjectType > &Manager) const
 Finds all resources managed by the given resource manager matching type ObjectTpye and returns a list of information about these objects. More...
 
- Protected Member Functions inherited from DynExp::ParamsBase::TypedListParamBase< ParamType >
 TypedListParamBase (ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, UnderlyingType DefaultValues={})
 Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog (UserEditable is set to true). More...
 
 TypedListParamBase (ParamsBase &Owner, std::string ParamName, UnderlyingType DefaultValues={})
 Base constructor of any parameter to be used if a parameter should not be displayed in a settings dialog (UserEditable is set to false). More...
 
virtual void ToXMLNodeChild (QDomDocument &Document, QDomElement &XMLElement) const override
 Converts this parameter to a Qt dom element (describing an XML node containing this parameter's name and value). More...
 
- Protected Member Functions inherited from DynExp::ParamsBase::ParamBase
 ParamBase (ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange)
 Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog (UserEditable is set to true). More...
 
 ParamBase (ParamsBase &Owner, std::string ParamName)
 Base constructor of any parameter to be used if a parameter should not be displayed in a settings dialog (UserEditable is set to false). More...
 
virtual ~ParamBase ()=0
 
const auto & GetOwner () const noexcept
 Returns the ParamsBase instance owning this ParamBase instance. More...
 
auto & GetOwner () noexcept
 Returns the ParamsBase instance owning this ParamBase instance. More...
 

Detailed Description

template<typename LinkType>
class DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >

Parameter for link lists to multiple Object. If LinkType is derived from ObjectLinkBase, then extend TypedParamBase's functionality by providing link instantiation functionality and by overriding AddToDialogChild().

Template Parameters
LinkTypeType derived from ObjectLinkBase (usually ObjectLink< ObjectT > instantiated with a type ObjectT derived from Object).

Definition at line 1429 of file Object.h.

Member Typedef Documentation

◆ ManagerType

template<typename LinkType >
using DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::ManagerType = ManagerTypeOfObjectType_t<ObjectType>

Type of the manager managing the linked Object.

Definition at line 1433 of file Object.h.

◆ ObjectType

template<typename LinkType >
using DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::ObjectType = typename LinkType::ObjectType

Type of the linked Object.

Definition at line 1432 of file Object.h.

Constructor & Destructor Documentation

◆ ListParam()

template<typename LinkType >
DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::ListParam ( ParamsBase Owner,
const ManagerType Manager,
std::string  ParamName,
std::string_view  ParamTitle,
std::string_view  ParamDescription,
std::string_view  IconResourcePath = {},
bool  Optional = false,
bool  NeedsResetToApplyChange = true 
)
inline

Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog (UserEditable is set to true).

Parameters
OwnerParamsBase instance owning this parameter.
ParamNameName of the parameter to be used in the XML config file. std::string to allow for auto-generated names.
ParamTitleTitle of the parameter to be displayed in settings dialogs. A static string literal with a constant address is expected.
ParamDescriptionDetailed description of the parameter to be displayed in settings dialogs. A static string literal with a constant address is expected.
NeedsResetToApplyChangeIndicated whether the object this parameter belongs to needs to be reset to apply changes if this parameter's value has changed.
DefaultValueDefault value to assign to the constructed parameter

Constructs a LinkBase object.

Parameters
IconResourcePathQt resource path describing an icon being displayed along with this parameter in user interface dialogs.
OptionalDetermines whether this parameter is optional. Optional parameters do not have to point to valid object IDs.

No further constructor since LinkParamBase parameters must be editable by the user.

Parameters
ManagerReference to the manager instance containing the Object the link refers to

Definition at line 1440 of file Object.h.

Member Function Documentation

◆ AddToDialogChild()

template<typename LinkType >
virtual void DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::AddToDialogChild ( ParamsConfigDialog Dialog)
inlinefinaloverrideprivatevirtual

Appends this parameter to a settings dialog making it configurable by the user.

Parameters
DialogReference to the settings dialog to append the parameter to

Implements DynExp::ParamsBase::ParamBase.

Definition at line 1505 of file Object.h.

◆ ContainsID()

template<typename LinkType >
bool DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::ContainsID ( ) const
inlinenoexcept

Checks whether at least one item has been assigned to this parameter. Assigned items are not allowed to have the ID 'ItemIDNotSet' (see ValidateValues).

Returns
Returns true if there is at least one ID assigned, false otherwise.

Definition at line 1462 of file Object.h.

◆ EnsureReadyStateChild()

template<typename LinkType >
void DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::EnsureReadyStateChild ( )
inlinefinaloverrideprivatevirtual

Thread-safe since only main thread is allowed to change parameters and to call this funtion.

Implements DynExp::LinkBase.

Definition at line 1530 of file Object.h.

◆ FromXMLNodeChild()

template<typename LinkType >
virtual void DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::FromXMLNodeChild ( const QDomElement &  XMLElement)
inlineoverrideprivatevirtual

Restores this parameter's value from the given Qt dom element (describing an XML node)

Parameters
XMLElementQt dom element containing information about this parameter.

Reimplemented from DynExp::ParamsBase::TypedListParamBase< ParamType >.

Definition at line 1499 of file Object.h.

◆ GetCommonManagerChild()

template<typename LinkType >
virtual const CommonResourceManagerBase* DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::GetCommonManagerChild ( ) const
inlineoverrideprivatevirtualnoexcept

This function can be used to determine the object type the parameter is expecting by comparing the resource manager's address to resource managers owned by a DynExpCore instance.

Returns
Returns the address of the resource manager managing resources to be possibly linked to this parameter.

Implements DynExp::LinkBase.

Definition at line 1497 of file Object.h.

◆ GetLinks()

template<typename LinkType >
const auto& DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::GetLinks ( ) const
inlinenoexcept

Returns a list of links of type LinkType derived from ObjectLinkBase to the Object this parameter refers to.

Returns
Returns const vector<...>& in order to prohibit foreign classes to change ObjectLinks.

Definition at line 1469 of file Object.h.

◆ GetManager()

template<typename LinkType >
const auto& DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::GetManager ( ) const
inlinenoexcept

Returns the manager instance containing the Object the link refers to.

Returns
Reference to manager instance

Definition at line 1455 of file Object.h.

◆ IsReadyChild()

template<typename LinkType >
bool DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::IsReadyChild ( )
inlinefinaloverrideprivatevirtual

Returns whether the object where this link parameter points to is in a ready state.

Returns
Returns true if it is in a ready state, false otherwise.

Implements DynExp::LinkBase.

Definition at line 1543 of file Object.h.

◆ MakeLinks()

template<typename LinkType >
void DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::MakeLinks ( )
inline

Retrives the linked resource using its ID stored in the parameter and establishes a link to the resource. Before using the resource, it has to be locked through the link by the owner of this parameter. This function is also called by ParamsConfigDialog::accept().

Exceptions
Util::InvalidStateExceptionis thrown if Manager returns a resource of a type not matching ObjectType.

Definition at line 1478 of file Object.h.

◆ operator=()

template<typename LinkType >
auto& DynExp::ParamsBase::TypedListParamBase< ParamType >::operator=
inline

Assigns new values to this parameter. The operator cannot be accessed by Object because this function is not const.

Parameters
NewValuesNew values to assign
Returns
Reference to this parameter
Exceptions
Util::InvalidArgExceptionis thrown if the values to assign to the parameter are not considered valid as determined by a call to ParamBase::Validate().

Definition at line 1414 of file Object.h.

◆ ValidateValues()

template<typename LinkType >
bool DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::ValidateValues ( const typename LinkListParamBase::UnderlyingType NewValues) const
inlineoverrideprivate

Ensures that list entries do not have the ItemIDNotSet value.

Parameters
NewValuesValues to be validated before the assignment
Returns
Returns true if NewValues is considered valid, false otherwise.

Definition at line 1518 of file Object.h.

Member Data Documentation

◆ Links

template<typename LinkType >
std::vector<LinkType> DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::Links
private

List of links of type LinkType derived from ObjectLinkBase referring to the linked Object. The links can be locked to access the underlying resources in a thread-safe way.

Definition at line 1580 of file Object.h.

◆ Manager

template<typename LinkType >
const ManagerType& DynExp::ParamsBase::ListParam< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::Manager
private

Reference to the manager instance containing the Object the link refers to. Managers live longer than their managed Objects which own the Params.

Definition at line 1574 of file Object.h.


The documentation for this class was generated from the following file: