DynExp
Highly flexible laboratory automation for dynamically changing experiments.
DynExp::LinkedObjectWrapper< ObjectT > Class Template Reference

Holds a shared_ptr to a resource (instance of class Object) and lets the resource keep track of its usage count by increasing a respective counter of the resource on construction and by decreasing the counter on destruction of the LinkedObjectWrapper instance again. Not copyable in order not to mess up the usage counter stored in LinkedObjectWrapper::DestinyResource. Only accessed via a thread's instance of class RunnableInstance in that thread. Also refer to RunnableInstance. More...

+ Inheritance diagram for DynExp::LinkedObjectWrapper< ObjectT >:

Public Types

using ObjectType = std::add_const_t< ObjectT >
 Const type of the managed Object. More...
 

Public Member Functions

 LinkedObjectWrapper (const RunnableInstance &Owner, std::shared_ptr< ObjectType > &&DestinyResource, const std::chrono::milliseconds Timeout)
 Constructs a LinkedObjectWrapper instance and calls LinkedObjectWrapper::Register(). More...
 
virtual ~LinkedObjectWrapper ()
 Destructor calls LinkedObjectWrapper::Deregister(). More...
 
virtual bool IsRegistered () const noexcept override
 Returns whether the wrapper has registered its owning Object instance (through Owner) as a user of the target resource (refer to LinkedObjectWrapper::DestinyResource). More...
 
std::string GetLinkedObjectDesc () const
 Builds and returns a human-readable string uniquely identifying the Object instance DestinyResource. The function does not perform a check whether the owning Object instance has been registered (i.e. IsRegisteredFlag is true). More...
 
decltype(auto) get () const
 Getter for the target resource which is used by the owning Object instance. More...
 
decltype(auto) get ()
 Getter for the target resource which is used by the owning Object instance. More...
 
const auto & operator* () const
 Dereferencing getter. More...
 
auto & operator* ()
 
const auto operator-> () const
 Getter for the target resource which is used by the owning Object instance. More...
 
auto operator-> ()
 Getter for the target resource which is used by the owning Object instance. More...
 
- Public Member Functions inherited from DynExp::LinkedObjectWrapperBase
 LinkedObjectWrapperBase (const RunnableInstance &Owner)
 Constructs a LinkedObjectWrapperBase instance. More...
 
virtual ~LinkedObjectWrapperBase ()=0
 
const ObjectGetOwner () const noexcept
 Returns the owner of this wrapper. More...
 
- Public Member Functions inherited from Util::INonCopyable
 INonCopyable (const INonCopyable &)=delete
 
INonCopyableoperator= (const INonCopyable &)=delete
 

Private Member Functions

virtual void Register (const std::chrono::milliseconds Timeout) override
 Registers the wrapper's owning Object instance (through Owner) as a user of the target resource (refer to LinkedObjectWrapper::DestinyResource). More...
 
virtual void Deregister (const std::chrono::milliseconds Timeout) override
 Deregisters the wrapper's owning Object instance (through Owner) as a user of the target resource (refer to LinkedObjectWrapper::DestinyResource). More...
 

Private Attributes

const std::shared_ptr< ObjectTypeDestinyResource
 Target resource which is used by the Object instance LinkedObjectWrapperBase::Owner belongs to. More...
 
bool IsRegisteredFlag
 Indicates whether the wrapper has registered its owning Object instance (through LinkedObjectWrapperBase::Owner) as a user of the target resource DestinyResource. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Util::INonCopyable
constexpr INonCopyable ()=default
 
 ~INonCopyable ()=default
 

Detailed Description

template<typename ObjectT>
class DynExp::LinkedObjectWrapper< ObjectT >

Holds a shared_ptr to a resource (instance of class Object) and lets the resource keep track of its usage count by increasing a respective counter of the resource on construction and by decreasing the counter on destruction of the LinkedObjectWrapper instance again. Not copyable in order not to mess up the usage counter stored in LinkedObjectWrapper::DestinyResource. Only accessed via a thread's instance of class RunnableInstance in that thread. Also refer to RunnableInstance.

Template Parameters
ObjectTType of the managed Object.

Definition at line 2822 of file Object.h.

Member Typedef Documentation

◆ ObjectType

template<typename ObjectT >
using DynExp::LinkedObjectWrapper< ObjectT >::ObjectType = std::add_const_t<ObjectT>

Const type of the managed Object.

Definition at line 2825 of file Object.h.

Constructor & Destructor Documentation

◆ LinkedObjectWrapper()

template<typename ObjectT >
DynExp::LinkedObjectWrapper< ObjectT >::LinkedObjectWrapper ( const RunnableInstance Owner,
std::shared_ptr< ObjectType > &&  DestinyResource,
const std::chrono::milliseconds  Timeout 
)
inline

Constructs a LinkedObjectWrapper instance and calls LinkedObjectWrapper::Register().

Parameters
OwnerRefer to LinkedObjectWrapperBase::Owner.
DestinyResourceRefer to DestinyResource.
TimeoutTimeout of the mutex-locking operation in ObjectUserList

Definition at line 2833 of file Object.h.

◆ ~LinkedObjectWrapper()

template<typename ObjectT >
virtual DynExp::LinkedObjectWrapper< ObjectT >::~LinkedObjectWrapper ( )
inlinevirtual

Destructor calls LinkedObjectWrapper::Deregister().

Definition at line 2844 of file Object.h.

Member Function Documentation

◆ Deregister()

template<typename ObjectT >
virtual void DynExp::LinkedObjectWrapper< ObjectT >::Deregister ( const std::chrono::milliseconds  Timeout)
inlineoverrideprivatevirtual

Deregisters the wrapper's owning Object instance (through Owner) as a user of the target resource (refer to LinkedObjectWrapper::DestinyResource).

Parameters
TimeoutTimeout of the mutex-locking operation in ObjectUserList

Implements DynExp::LinkedObjectWrapperBase.

Definition at line 2952 of file Object.h.

◆ get() [1/2]

template<typename ObjectT >
decltype(auto) DynExp::LinkedObjectWrapper< ObjectT >::get ( )
inline

Getter for the target resource which is used by the owning Object instance.

Returns
Returns DestinyResource.
Exceptions
Util::InvalidStateExceptionis thrown if the owning Object instance has not been registered (i.e. IsRegisteredFlag is false). Dereferencing getter. Getter for the target resource which is used by the owning Object instance.
Returns
Returns DestinyResource.
Exceptions
Util::InvalidStateExceptionis thrown if the owning Object instance has not been registered (i.e. IsRegisteredFlag is false).

Definition at line 2902 of file Object.h.

◆ get() [2/2]

template<typename ObjectT >
decltype(auto) DynExp::LinkedObjectWrapper< ObjectT >::get ( ) const
inline

Getter for the target resource which is used by the owning Object instance.

Returns
Returns DestinyResource.
Exceptions
Util::InvalidStateExceptionis thrown if the owning Object instance has not been registered (i.e. IsRegisteredFlag is false).

Definition at line 2900 of file Object.h.

◆ GetLinkedObjectDesc()

template<typename ObjectT >
std::string DynExp::LinkedObjectWrapper< ObjectT >::GetLinkedObjectDesc ( ) const
inline

Builds and returns a human-readable string uniquely identifying the Object instance DestinyResource. The function does not perform a check whether the owning Object instance has been registered (i.e. IsRegisteredFlag is true).

Returns
String containing the type category, type name, and user-defined name identifying DestinyResource.

Definition at line 2892 of file Object.h.

◆ IsRegistered()

template<typename ObjectT >
virtual bool DynExp::LinkedObjectWrapper< ObjectT >::IsRegistered ( ) const
inlineoverridevirtualnoexcept

Returns whether the wrapper has registered its owning Object instance (through Owner) as a user of the target resource (refer to LinkedObjectWrapper::DestinyResource).

Returns
Returns true if already registered, false otherwise.

Implements DynExp::LinkedObjectWrapperBase.

Definition at line 2883 of file Object.h.

◆ operator*() [1/2]

template<typename ObjectT >
auto& DynExp::LinkedObjectWrapper< ObjectT >::operator* ( )
inline

Definition at line 2928 of file Object.h.

◆ operator*() [2/2]

template<typename ObjectT >
const auto& DynExp::LinkedObjectWrapper< ObjectT >::operator* ( ) const
inline

Dereferencing getter.

Getter for the target resource which is used by the owning Object instance.

Returns
Returns DestinyResource.
Exceptions
Util::InvalidStateExceptionis thrown if the owning Object instance has not been registered (i.e. IsRegisteredFlag is false).

Definition at line 2903 of file Object.h.

◆ operator->() [1/2]

template<typename ObjectT >
auto DynExp::LinkedObjectWrapper< ObjectT >::operator-> ( )
inline

Getter for the target resource which is used by the owning Object instance.

Returns
Returns DestinyResource.
Exceptions
Util::InvalidStateExceptionis thrown if the owning Object instance has not been registered (i.e. IsRegisteredFlag is false).

Definition at line 2936 of file Object.h.

◆ operator->() [2/2]

template<typename ObjectT >
const auto DynExp::LinkedObjectWrapper< ObjectT >::operator-> ( ) const
inline

Getter for the target resource which is used by the owning Object instance.

Returns
Returns DestinyResource.
Exceptions
Util::InvalidStateExceptionis thrown if the owning Object instance has not been registered (i.e. IsRegisteredFlag is false).

Definition at line 2935 of file Object.h.

◆ Register()

template<typename ObjectT >
virtual void DynExp::LinkedObjectWrapper< ObjectT >::Register ( const std::chrono::milliseconds  Timeout)
inlineoverrideprivatevirtual

Registers the wrapper's owning Object instance (through Owner) as a user of the target resource (refer to LinkedObjectWrapper::DestinyResource).

Parameters
TimeoutTimeout of the mutex-locking operation in ObjectUserList

Implements DynExp::LinkedObjectWrapperBase.

Definition at line 2939 of file Object.h.

Member Data Documentation

◆ DestinyResource

template<typename ObjectT >
const std::shared_ptr<ObjectType> DynExp::LinkedObjectWrapper< ObjectT >::DestinyResource
private

Target resource which is used by the Object instance LinkedObjectWrapperBase::Owner belongs to.

Definition at line 2966 of file Object.h.

◆ IsRegisteredFlag

template<typename ObjectT >
bool DynExp::LinkedObjectWrapper< ObjectT >::IsRegisteredFlag
private

Indicates whether the wrapper has registered its owning Object instance (through LinkedObjectWrapperBase::Owner) as a user of the target resource DestinyResource.

Definition at line 2972 of file Object.h.


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