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

Parameter for links to a single 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::Param< 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::TypedParamBase< ParamType >
using UnderlyingType = ParamType
 

Public Member Functions

 Param (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 an item has been assigned to this parameter. More...
 
const LinkType & GetLink () const noexcept
 Returns the link of type LinkType derived from ObjectLinkBase to the Object the parameter refers to. More...
 
void MakeLink ()
 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...
 
const ParamType & operator= (const ParamType &NewValue)
 Assigns a new value to this parameter. The operator cannot be accessed by Object because this function is not const. More...
 
- Public Member Functions inherited from DynExp::ParamsBase::LinkParamBase
const ParamType & operator= (const ParamType &NewValue)
 Assigns a new value 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::TypedParamBase< ParamType >
ParamType GetDefaultValue () const noexcept
 Returns this parameter's default value. Thread-safe since a const member variable is returned. More...
 
 operator ParamType () const noexcept
 Converts the parameter implicitly to its underlying type returning its current value. More...
 
const ParamType & Get () const noexcept
 Returns the parameter's value. More...
 
const ParamType & operator= (const ParamType &NewValue)
 Assigns a new value 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...
 
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...
 
LinkType Link
 Link of type LinkType derived from ObjectLinkBase referring to the linked Object. The link can be locked to access the underlying resource 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::LinkParamBase
 LinkParamBase (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::TypedParamBase< ParamType >
 TypedParamBase (ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, ParamType DefaultValue=ParamType())
 Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog (UserEditable is set to true). More...
 
 TypedParamBase (ParamsBase &Owner, std::string ParamName, ParamType DefaultValue=ParamType())
 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::Param< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >

Parameter for links to a single 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 1150 of file Object.h.

Member Typedef Documentation

◆ ManagerType

template<typename LinkType >
using DynExp::ParamsBase::Param< 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 1154 of file Object.h.

◆ ObjectType

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

Type of the linked Object.

Definition at line 1153 of file Object.h.

Constructor & Destructor Documentation

◆ Param()

template<typename LinkType >
DynExp::ParamsBase::Param< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::Param ( 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 1161 of file Object.h.

Member Function Documentation

◆ AddToDialogChild()

template<typename LinkType >
virtual void DynExp::ParamsBase::Param< 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 1222 of file Object.h.

◆ ContainsID()

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

Checks whether an item has been assigned to this parameter.

Returns
Returns true if the assigned ID is not 'ItemIDNotSet', false otherwise.

Definition at line 1182 of file Object.h.

◆ EnsureReadyStateChild()

template<typename LinkType >
void DynExp::ParamsBase::Param< 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 1234 of file Object.h.

◆ FromXMLNodeChild()

template<typename LinkType >
virtual void DynExp::ParamsBase::Param< 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::TypedParamBase< ParamType >.

Definition at line 1216 of file Object.h.

◆ GetCommonManagerChild()

template<typename LinkType >
virtual const CommonResourceManagerBase* DynExp::ParamsBase::Param< 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 1214 of file Object.h.

◆ GetLink()

template<typename LinkType >
const LinkType& DynExp::ParamsBase::Param< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::GetLink ( ) const
inlinenoexcept

Returns the link of type LinkType derived from ObjectLinkBase to the Object the parameter refers to.

Returns
Returns const LinkType& in order to prohibit foreign classes to change ObjectLink.

Definition at line 1189 of file Object.h.

◆ GetManager()

template<typename LinkType >
const auto& DynExp::ParamsBase::Param< 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 1176 of file Object.h.

◆ IsReadyChild()

template<typename LinkType >
bool DynExp::ParamsBase::Param< 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 1244 of file Object.h.

◆ MakeLink()

template<typename LinkType >
void DynExp::ParamsBase::Param< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::MakeLink ( )
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 1198 of file Object.h.

◆ operator=()

template<typename LinkType >
const ParamType& DynExp::ParamsBase::TypedParamBase< ParamType >::operator=
inline

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

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

Definition at line 1135 of file Object.h.

Member Data Documentation

◆ Link

template<typename LinkType >
LinkType DynExp::ParamsBase::Param< LinkType, std::enable_if_t< std::is_base_of_v< ObjectLinkBase, LinkType > > >::Link
private

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

Definition at line 1277 of file Object.h.

◆ Manager

template<typename LinkType >
const ManagerType& DynExp::ParamsBase::Param< 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 1271 of file Object.h.


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