DynExp
Highly flexible laboratory automation for dynamically changing experiments.
DynExp::Object Class Referenceabstract

Base class for all DynExp Objects like hardware adapters (DynExp::HardwareAdapterBase), instruments (DynExp::InstrumentBase) and modules (DynExp::ModuleBase). Subclasses should also derive either form Util::INonCopyable or Util::ILockable since Object is not intended to be copied. Especially, it must not be moved to another thread (than the one creating it). Logical const-ness: const member functions can be called by other threads, non-const functions are visible only to main thread. More...

+ Inheritance diagram for DynExp::Object:

Classes

struct  dispatch_tag
 Refer to ParamsBase::dispatch_tag. More...
 
class  LinkedObjectWrapperOnlyType
 Allow exclusive access to some of Object's private methods to any LinkedObjectWrapper<T>. More...
 

Public Types

using ParamsType = ParamsBase
 Type of the parameter class belonging to this Object type. Declare this alias in every derived class with the respective parameter class accompanying the derived Object. More...
 
using ParamsTypeSyncPtrType = Util::SynchronizedPointer< ParamsType >
 Alias for the return type of Object::GetParams(). Parameters wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way. More...
 
using ParamsConstTypeSyncPtrType = Util::SynchronizedPointer< const ParamsType >
 Alias for the return type of Object::GetParams() const. Parameters wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way. More...
 
using ConfigType = ConfiguratorBase
 Type of the configurator class belonging to this Object type. Declare this alias in every derived class with the respective configurator class accompanying the derived Object. More...
 

Public Member Functions

ItemIDType GetID () const noexcept
 Returns the ID of this Object instance. Thread-safe since ID is const. More...
 
std::string GetCategoryAndName () const
 Builds a string from an Object's category and name to allow the user to identify an Object's type. More...
 
void EnsureReadyState (bool IsAutomaticStartup)
 Ensures that this Object instance is ready by possibly starting its worker thread or by opening connections to hardware devices. More...
 
void CheckLinkedObjectStates () const
 Checks whether Object instances this instance uses are in a ready state. Override CheckLinkedObjectStatesChild() to implement this behavior. More...
 
Not thread-safe

These functions must be called by the thread owning this Object instance only! Additionally, these functions must only be called when this Object instance is not in use by another Object instance!

void Reset ()
 Resets this Object instance (including all its derived classes) by calling ResetImpl(). A reset implies that the derived classes reload all their parameters from Params and that all LinkedObjectWrapper instances owned by this Object instance become invalidated. More...
 
void BlockIfUnused (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout)
 Blocks this Object instance setting Object::IsBlocked to true. Refer to Object::IsBlocked for the consequences. More...
 

Static Public Member Functions

static std::string CategoryAndNameToStr (const std::string &Category, const std::string &Name)
 Builds a string from an Object's category and name to allow the user to identify an Object's type. More...
 

Public Attributes

LinkedObjectWrapperOnlyType LinkedObjectWrapperOnly
 Allow exclusive access to some of Object's private methods to any LinkedObjectWrapper<T>. More...
 

Static Public Attributes

static constexpr std::chrono::milliseconds GetParamsTimeoutDefault = std::chrono::milliseconds(100)
 Default timeout used by Object::GetParams() to lock the mutex of the parameter instance assigned to this Object instance. More...
 

Protected Member Functions

 Object (const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params)
 Constructs an Object instance. More...
 
virtual ~Object ()=0
 
void EnsureCallFromOwningThread () const
 Asserts that the call to this function is performed from the thread which constructed this Object instance (the thread with the id stored in Object::OwnerThreadID). More...
 
ParamsTypeSyncPtrType GetNonConstParams (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
 Allows derived Objects to edit their own parameters - even in const task functions (for instruments) or event functions (for modules). More...
 
Non-const methods

Not const, to avoid usage by e.g. tasks of derived instruments.

auto LockUserList (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout)
 Locks the user list for thread-safe manipulation. More...
 
void DeregisterAllUnsafe ()
 Deregisters all users and notifies them that they need to check the states of their used linked objects. More...
 
auto GetUseCountUnsafe ()
 
auto GetUserNamesStringUnsafe () const
 
bool IsUnusedUnsafe ()
 Returns whether this Object instance is used by other instances (not thread-safe). More...
 

Private Member Functions

void LogWarning () const
 Writes Object::Warning to the event log returned by Util::EventLog(). More...
 

Private Attributes

const std::thread::id OwnerThreadID
 Thread id of the thread which has constructed (and owns) this Object instance. More...
 
const ParamsBasePtrType Params
 Pointer to the parameter class instance belonging to this Object instance. More...
 
Util::Warning Warning
 Last warning which occurred within this Object instance. (Logical const-ness: see above.) More...
 
ObjectUserList UserList
 List of Object instances making use of this Object instance. Other Object instances making use of this Object instance have to register and deregister themselves (via class LinkedObjectWrapper). More...
 
bool IsBlocked = false
 This flag indicates whether this Object instance is blocked in order to be destroyed subsequently. Blocked objects are never ready (Object::IsReady() returns always false for them). Thus, RunnableInstance cannot lock this object instance anymore. Unblocking is not possible since blocking indicates approaching destruction. More...
 

Thread-safe public functions

Thread-safe since mutex is locked.

using ParamsGetterType = Util::CallableMemberWrapper< Object, decltype(&Object::GetParams)>
 Invoking an instance of this alias is supposed to call Object::GetParams() of the instance the Util::CallableMemberWrapper has been constructed with. More...
 
ParamsConstTypeSyncPtrType GetParams (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
 Locks the mutex of the parameter class instance Params assigned to this Object instance and returns a pointer to the locked Params. More...
 
ParamsTypeSyncPtrType GetParams (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault)
 Locks the mutex of the parameter class instance Params assigned to this Object instance and returns a pointer to the locked Params. More...
 
auto GetObjectName (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
 Returns the name of this Object instance. More...
 
bool IsSharedUsageEnabled (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
 Returns whether shared usage has been enabled for this Object instance. Refer to ParamsBase::UsageType. More...
 
void SetWarning (std::string Description, int ErrorCode) const
 Setter for Object::Warning. Sets the warning by a description and an error code. More...
 
void SetWarning (const Util::Exception &e) const
 Setter for Object::Warning. Sets the warning by retrieving the warning data from an exception e. More...
 
void ClearWarning () const
 Resets Object::Warning. More...
 
auto GetWarning () const
 Returns Object::Warning in a thread-safe way by copying its internal data. More...
 
std::exception_ptr GetException (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const
 Returns a pointer to the exception which has caused this Object instance to fail. More...
 
bool IsReady () const
 Returns wheter this Object instance is ready (e.g. it is running or connected to a hardware device) and not blocked (refer to Object::IsBlocked). More...
 
auto GetUseCount (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const
 Counts the registered useres in a thread-safe way. More...
 
bool IsUnused (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const
 Returns whether this Object instance is used by other instances. More...
 
auto GetUserIDs (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const
 Returns a list of the IDs of the registered users in a thread-safe way. More...
 
auto GetUserNamesString (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const
 Builds a string describing which users are registered containing their object names, categories and type names in a thread-safe way. More...
 

Override

Override by derived class to make public versions of these functions behave as described above.

virtual std::string GetName () const =0
 Returns the name of this Object type. More...
 
virtual std::string GetCategory () const =0
 Returns the category of this Object type. More...
 
virtual void ResetImpl (dispatch_tag< Object >)=0
 Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every derived class gets called - starting from DynExp::Object, descending the inheritance hierarchy. More...
 
virtual std::exception_ptr GetExceptionChild (const std::chrono::milliseconds Timeout) const =0
 Returns a pointer to the exception which has caused this Object instance to fail. More...
 
virtual void EnsureReadyStateChild (bool IsAutomaticStartup)=0
 Ensures that this Object instance is ready by possibly starting its worker thread or by opening connections to hardware devices. More...
 
virtual bool IsReadyChild () const =0
 Returns wheter this Object instance is ready (e.g. it is running or connected to a hardware device) and not blocked (refer to Object::IsBlocked). More...
 
virtual void CheckLinkedObjectStatesChild () const
 Override to implement a check whether linked objects are in a ready state. More...
 

Detailed Description

Base class for all DynExp Objects like hardware adapters (DynExp::HardwareAdapterBase), instruments (DynExp::InstrumentBase) and modules (DynExp::ModuleBase). Subclasses should also derive either form Util::INonCopyable or Util::ILockable since Object is not intended to be copied. Especially, it must not be moved to another thread (than the one creating it). Logical const-ness: const member functions can be called by other threads, non-const functions are visible only to main thread.

Definition at line 1970 of file Object.h.


Class Documentation

◆ DynExp::Object::dispatch_tag

struct DynExp::Object::dispatch_tag

template<typename>
struct DynExp::Object::dispatch_tag< typename >

Refer to ParamsBase::dispatch_tag.

Template Parameters
Type(derived from class Object) to instantiate the dispatch tag template with.

Definition at line 2018 of file Object.h.

Member Typedef Documentation

◆ ConfigType

Type of the configurator class belonging to this Object type. Declare this alias in every derived class with the respective configurator class accompanying the derived Object.

Definition at line 1995 of file Object.h.

◆ ParamsConstTypeSyncPtrType

Alias for the return type of Object::GetParams() const. Parameters wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way.

Definition at line 1989 of file Object.h.

◆ ParamsGetterType

Invoking an instance of this alias is supposed to call Object::GetParams() of the instance the Util::CallableMemberWrapper has been constructed with.

Definition at line 2114 of file Object.h.

◆ ParamsType

Type of the parameter class belonging to this Object type. Declare this alias in every derived class with the respective parameter class accompanying the derived Object.

Definition at line 1977 of file Object.h.

◆ ParamsTypeSyncPtrType

Alias for the return type of Object::GetParams(). Parameters wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way.

Definition at line 1983 of file Object.h.

Constructor & Destructor Documentation

◆ Object()

DynExp::Object::Object ( const std::thread::id  OwnerThreadID,
ParamsBasePtrType &&  Params 
)
protected

Constructs an Object instance.

Parameters
OwnerThreadIDThread id of the thread owning the Object instance to be constructed.
ParamsParameter class instance to be assigned to the Object instance to be constructed.
Exceptions
Util::InvalidArgExceptionis thrown if OwnerThreadID is an invalid thread id or if Params is nullptr.

Definition at line 358 of file Object.cpp.

◆ ~Object()

DynExp::Object::~Object ( )
protectedpure virtual

Definition at line 368 of file Object.cpp.

Member Function Documentation

◆ BlockIfUnused()

void DynExp::Object::BlockIfUnused ( const std::chrono::milliseconds  Timeout = Util::ILockable::DefaultTimeout)

Blocks this Object instance setting Object::IsBlocked to true. Refer to Object::IsBlocked for the consequences.

Parameters
TimeoutTime to wait for locking the mutex of Object::UserList.
Exceptions
Util::NotAvailableExceptionis thrown if this Object instance is currently being used by another Object instance.

Definition at line 421 of file Object.cpp.

◆ CategoryAndNameToStr()

std::string DynExp::Object::CategoryAndNameToStr ( const std::string &  Category,
const std::string &  Name 
)
static

Builds a string from an Object's category and name to allow the user to identify an Object's type.

Parameters
CategoryRefer to Object::GetCategory().
NameRefer to Object::GetName().
Returns
Returns a human-readable string to identify a (derived) Object's type.

Definition at line 350 of file Object.cpp.

◆ CheckLinkedObjectStates()

void DynExp::Object::CheckLinkedObjectStates ( ) const
inline

Checks whether Object instances this instance uses are in a ready state. Override CheckLinkedObjectStatesChild() to implement this behavior.

Definition at line 2240 of file Object.h.

◆ CheckLinkedObjectStatesChild()

virtual void DynExp::Object::CheckLinkedObjectStatesChild ( ) const
inlineprivatevirtual

Override to implement a check whether linked objects are in a ready state.

Reimplemented in DynExp::RunnableObject.

Definition at line 2294 of file Object.h.

◆ ClearWarning()

void DynExp::Object::ClearWarning ( ) const
inline

Resets Object::Warning.

Definition at line 2190 of file Object.h.

◆ DeregisterAllUnsafe()

void DynExp::Object::DeregisterAllUnsafe ( )
inlineprotected

Deregisters all users and notifies them that they need to check the states of their used linked objects.

Definition at line 2265 of file Object.h.

◆ EnsureCallFromOwningThread()

void DynExp::Object::EnsureCallFromOwningThread ( ) const
protected

Asserts that the call to this function is performed from the thread which constructed this Object instance (the thread with the id stored in Object::OwnerThreadID).

Exceptions
Util::InvalidCallExceptionis thrown if the assertion fails.

Definition at line 468 of file Object.cpp.

◆ EnsureReadyState()

void DynExp::Object::EnsureReadyState ( bool  IsAutomaticStartup)

Ensures that this Object instance is ready by possibly starting its worker thread or by opening connections to hardware devices.

Parameters
IsAutomaticStartupPass true if ensuring other Object instances to be ready have caused a call to this function. Pass false if an action performed by the user has caused the call to this function.

Definition at line 446 of file Object.cpp.

◆ EnsureReadyStateChild()

virtual void DynExp::Object::EnsureReadyStateChild ( bool  IsAutomaticStartup)
privatepure virtual

Ensures that this Object instance is ready by possibly starting its worker thread or by opening connections to hardware devices.

Parameters
IsAutomaticStartupPass true if ensuring other Object instances to be ready have caused a call to this function. Pass false if an action performed by the user has caused the call to this function.

Implemented in DynExp::RunnableObject.

◆ GetCategory()

virtual std::string DynExp::Object::GetCategory ( ) const
pure virtual

Returns the category of this Object type.

Implemented in DynExpModule::Widefield::WidefieldMicroscope, DynExpModule::Trajectory1D, DynExpModule::StreamManipulator, DynExpModule::Stage1D, DynExpModule::SpectrumViewer::SpectrumViewer, DynExpModule::SignalPlotter, DynExpModule::SignalDesigner, DynExpModule::OutputPortWriter, DynExpModule::ODMR::ODMR, DynExpModule::LockinAmplifierControl, DynExpModule::InputPortReader, DynExpModule::ImageViewer::ImageViewer, DynExpModule::gRPCModule< gRPCServices >, DynExpModule::gRPCModule< gRPCServices... >, DynExpModule::ArbitraryFunctionFromCSV, DynExp::ModuleBase, DynExpInstr::TimeTagger, DynExpInstr::PositionerStage, DynExpInstr::Spectrometer, DynExpInstr::OutputPort, DynExpInstr::LockinAmplifier, DynExpInstr::InputPort, DynExpInstr::gRPCInstrument< Spectrometer, 0, DynExpProto::NetworkSpectrometer::NetworkSpectrometer >, DynExpInstr::gRPCInstrument< DynExp::InstrumentBase, 0, DynExpProto::WidefieldLocalization::WidefieldLocalization >, DynExpInstr::FunctionGenerator, DynExpInstr::DigitalOut, DynExpInstr::DigitalIn, DynExpInstr::DataStreamInstrument, DynExpInstr::Camera, DynExpInstr::AnalogOut, DynExpInstr::AnalogIn, DynExp::InstrumentBase, DynExpHardware::ZILabOneHardwareAdapter, DynExpHardware::SIPulseStreamerHardwareAdapter, DynExpHardware::SmarActHardwareAdapter, DynExpHardware::QutoolsTDCHardwareAdapter, DynExpHardware::PVCamHardwareAdapter, DynExpHardware::NIDAQHardwareAdapter, DynExpHardware::gRPCHardwareAdapter< gRPCStub >, DynExpHardware::gRPCHardwareAdapter< pulse_streamer::PulseStreamer >, DynExp::SerialCommunicationHardwareAdapter, and DynExp::HardwareAdapterBase.

◆ GetCategoryAndName()

std::string DynExp::Object::GetCategoryAndName ( ) const
inline

Builds a string from an Object's category and name to allow the user to identify an Object's type.

Returns
Returns a human-readable string to identify this Object instance's type.

Definition at line 2158 of file Object.h.

◆ GetException()

std::exception_ptr DynExp::Object::GetException ( const std::chrono::milliseconds  Timeout = Util::ILockable::DefaultTimeout) const
inline

Returns a pointer to the exception which has caused this Object instance to fail.

Parameters
TimeoutTime to wait for locking the mutex used to protect the stored exception data.
Returns
Pointer to the stored exception or a default-constructed std::exception_ptr if no exception occurred.

Definition at line 2204 of file Object.h.

◆ GetExceptionChild()

virtual std::exception_ptr DynExp::Object::GetExceptionChild ( const std::chrono::milliseconds  Timeout) const
privatepure virtual

Returns a pointer to the exception which has caused this Object instance to fail.

Parameters
TimeoutTime to wait for locking the mutex used to protect the stored exception data.
Returns
Pointer to the stored exception or a default-constructed std::exception_ptr if no exception occurred.

Implemented in DynExp::HardwareAdapterBase.

◆ GetID()

ItemIDType DynExp::Object::GetID ( ) const
inlinenoexcept

Returns the ID of this Object instance. Thread-safe since ID is const.

Returns
ID of this Object instance

Definition at line 2143 of file Object.h.

◆ GetName()

virtual std::string DynExp::Object::GetName ( ) const
pure virtual

Returns the name of this Object type.

Implemented in DynExpModule::Widefield::WidefieldMicroscope, DynExpModule::Trajectory1D, DynExpModule::StreamManipulator, DynExpModule::Stage1D, DynExpModule::SpectrumViewer::SpectrumViewer, DynExpModule::SignalPlotter, DynExpModule::SignalDesigner, DynExpModule::OutputPortWriter, DynExpModule::ODMR::ODMR, DynExpModule::NetworkTimeTaggerT< gRPCServices >, DynExpModule::NetworkDigitalOutT< gRPCServices >, DynExpModule::NetworkDigitalInT< gRPCServices >, DynExpModule::NetworkDataStreamInstrumentT< gRPCServices >, DynExpModule::NetworkDataStreamInstrumentT< gRPCServices... >, DynExpModule::NetworkAnalogOutT< gRPCServices >, DynExpModule::NetworkAnalogInT< gRPCServices >, DynExpModule::LockinAmplifierControl, DynExpModule::InputPortReader, DynExpModule::ImageViewer::ImageViewer, DynExpModule::gRPCModule< gRPCServices >, DynExpModule::gRPCModule< gRPCServices... >, DynExpModule::ArbitraryFunctionFromCSV, DynExpInstr::TimeTagger, DynExpInstr::PositionerStage, DynExpInstr::Spectrometer, DynExpInstr::OutputPort, DynExpInstr::LockinAmplifier, DynExpInstr::InputPort, DynExpInstr::gRPCInstrument< Spectrometer, 0, DynExpProto::NetworkSpectrometer::NetworkSpectrometer >, DynExpInstr::gRPCInstrument< DynExp::InstrumentBase, 0, DynExpProto::WidefieldLocalization::WidefieldLocalization >, DynExpInstr::FunctionGenerator, DynExpInstr::DigitalOut, DynExpInstr::DigitalIn, DynExpInstr::DataStreamInstrument, DynExpInstr::Camera, DynExpInstr::AnalogOut, DynExpInstr::AnalogIn, DynExpInstr::ZI_MFLI, DynExpInstr::WidefieldLocalization, DynExpInstr::SwabianInstrumentsPulseStreamer, DynExpInstr::SmarAct, DynExpInstr::RS_SMC100A, DynExpInstr::RS_SMB100B, DynExpInstr::QutoolsQuTAG, DynExpInstr::PVCam, DynExpInstr::PI_C_862, DynExpInstr::NIDAQDigitalOut, DynExpInstr::NIDAQDigitalIn, DynExpInstr::NIDAQAnalogOut, DynExpInstr::NIDAQAnalogIn, DynExpInstr::NetworkSpectrometer, DynExpInstr::NenionLeakvalveF3, DynExpInstr::InterModuleCommunicator, DynExpInstr::DummyDataStreamInstrument, DynExpInstr::DummyCamera, DynExpHardware::ZILabOneHardwareAdapter, DynExpHardware::SIPulseStreamerHardwareAdapter, DynExpHardware::SmarActHardwareAdapter, DynExp::HardwareAdapterSerialPort, DynExpHardware::QutoolsTDCHardwareAdapter, DynExpHardware::PVCamHardwareAdapter, DynExpHardware::NIDAQHardwareAdapter, DynExpHardware::gRPCHardwareAdapter< gRPCStub >, DynExpHardware::gRPCHardwareAdapter< pulse_streamer::PulseStreamer >, DynExp::HardwareAdapterTcpSocket, and DynExp::SerialCommunicationHardwareAdapter.

◆ GetNonConstParams()

Object::ParamsTypeSyncPtrType DynExp::Object::GetNonConstParams ( const std::chrono::milliseconds  Timeout = GetParamsTimeoutDefault) const
protected

Allows derived Objects to edit their own parameters - even in const task functions (for instruments) or event functions (for modules).

Parameters
TimeoutTime to wait for locking the mutex of Params.
Returns
Returns a pointer to ParamsType (non-const) to allow access all of its members.

Definition at line 475 of file Object.cpp.

◆ GetObjectName()

auto DynExp::Object::GetObjectName ( const std::chrono::milliseconds  Timeout = GetParamsTimeoutDefault) const
inline

Returns the name of this Object instance.

Parameters
TimeoutTime to wait for locking the mutex of Params.
Returns
User-defined name of this Object instance

Definition at line 2128 of file Object.h.

◆ GetParams() [1/2]

Object::ParamsTypeSyncPtrType DynExp::Object::GetParams ( const std::chrono::milliseconds  Timeout = GetParamsTimeoutDefault)

Locks the mutex of the parameter class instance Params assigned to this Object instance and returns a pointer to the locked Params.

Parameters
TimeoutTime to wait for locking the mutex of Params.
Returns
Returns a pointer to ParamsType (non-const) to allow access to all of its members.

Definition at line 441 of file Object.cpp.

◆ GetParams() [2/2]

Object::ParamsConstTypeSyncPtrType DynExp::Object::GetParams ( const std::chrono::milliseconds  Timeout = GetParamsTimeoutDefault) const

Locks the mutex of the parameter class instance Params assigned to this Object instance and returns a pointer to the locked Params.

Parameters
TimeoutTime to wait for locking the mutex of Params.
Returns
Returns a pointer to const ParamsType, since users of this Object instance are not allowed to access non-const members of ParamsType. These are only to be accessed by the main thread!

Definition at line 436 of file Object.cpp.

◆ GetUseCount()

auto DynExp::Object::GetUseCount ( const std::chrono::milliseconds  Timeout = Util::ILockable::DefaultTimeout) const
inline

Counts the registered useres in a thread-safe way.

Parameters
TimeoutTimeout of the mutex-locking operation.
Returns
Number of registered users.

Definition at line 2216 of file Object.h.

◆ GetUseCountUnsafe()

auto DynExp::Object::GetUseCountUnsafe ( )
inlineprotected

Definition at line 2266 of file Object.h.

◆ GetUserIDs()

auto DynExp::Object::GetUserIDs ( const std::chrono::milliseconds  Timeout = Util::ILockable::DefaultTimeout) const
inline

Returns a list of the IDs of the registered users in a thread-safe way.

Parameters
TimeoutTimeout of the mutex-locking operation.
Returns
List of IDs of registered users.

Definition at line 2228 of file Object.h.

◆ GetUserNamesString()

auto DynExp::Object::GetUserNamesString ( const std::chrono::milliseconds  Timeout = Util::ILockable::DefaultTimeout) const
inline

Builds a string describing which users are registered containing their object names, categories and type names in a thread-safe way.

Parameters
TimeoutTimeout of the mutex-locking operation.
Returns
String containing information about the registered users.

Definition at line 2233 of file Object.h.

◆ GetUserNamesStringUnsafe()

auto DynExp::Object::GetUserNamesStringUnsafe ( ) const
inlineprotected

Definition at line 2267 of file Object.h.

◆ GetWarning()

auto DynExp::Object::GetWarning ( ) const
inline

Returns Object::Warning in a thread-safe way by copying its internal data.

Returns
Data of type Util::Warning::WarningData stored in Object::Warning.

Definition at line 2196 of file Object.h.

◆ IsReady()

bool DynExp::Object::IsReady ( ) const
inline

Returns wheter this Object instance is ready (e.g. it is running or connected to a hardware device) and not blocked (refer to Object::IsBlocked).

Returns
Returns true if this Object instance is ready, false otherwise.

Definition at line 2211 of file Object.h.

◆ IsReadyChild()

virtual bool DynExp::Object::IsReadyChild ( ) const
privatepure virtual

◆ IsSharedUsageEnabled()

bool DynExp::Object::IsSharedUsageEnabled ( const std::chrono::milliseconds  Timeout = GetParamsTimeoutDefault) const
inline

Returns whether shared usage has been enabled for this Object instance. Refer to ParamsBase::UsageType.

Parameters
TimeoutTime to wait for locking the mutex of Params.
Returns
Returns true when shared usage is enabled, false otherwise.

Definition at line 2136 of file Object.h.

◆ IsUnused()

bool DynExp::Object::IsUnused ( const std::chrono::milliseconds  Timeout = Util::ILockable::DefaultTimeout) const
inline

Returns whether this Object instance is used by other instances.

Parameters
TimeoutTime to wait for locking the mutex of Object::UserList.
Returns
Returns true if Object::GetUseCount evaluates to zero, false otherwise.

Definition at line 2223 of file Object.h.

◆ IsUnusedUnsafe()

bool DynExp::Object::IsUnusedUnsafe ( )
inlineprotected

Returns whether this Object instance is used by other instances (not thread-safe).

Returns
Returns true if Object::GetUseCountUnsafe evaluates to zero, false otherwise.

Definition at line 2273 of file Object.h.

◆ LockUserList()

auto DynExp::Object::LockUserList ( const std::chrono::milliseconds  Timeout = Util::ILockable::DefaultTimeout)
inlineprotected

Locks the user list for thread-safe manipulation.

Parameters
TimeoutTimeout of the mutex-locking operation.
Returns
Lock-guard of the underlying mutex. Only use temporarily. Do not store longer than necessary.

Definition at line 2264 of file Object.h.

◆ LogWarning()

void DynExp::Object::LogWarning ( ) const
private

Writes Object::Warning to the event log returned by Util::EventLog().

Definition at line 480 of file Object.cpp.

◆ Reset()

void DynExp::Object::Reset ( )

Resets this Object instance (including all its derived classes) by calling ResetImpl(). A reset implies that the derived classes reload all their parameters from Params and that all LinkedObjectWrapper instances owned by this Object instance become invalidated.

Exceptions
Util::NotAvailableExceptionis thrown if this Object instance is currently being used by another Object instance.

Definition at line 403 of file Object.cpp.

◆ ResetImpl()

virtual void DynExp::Object::ResetImpl ( dispatch_tag< Object )
privatepure virtual

Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every derived class gets called - starting from DynExp::Object, descending the inheritance hierarchy.

Implemented in DynExp::RunnableObject, and DynExp::HardwareAdapterBase.

◆ SetWarning() [1/2]

void DynExp::Object::SetWarning ( const Util::Exception e) const

Setter for Object::Warning. Sets the warning by retrieving the warning data from an exception e.

Parameters
eException derived from class Util::Exception

Definition at line 461 of file Object.cpp.

◆ SetWarning() [2/2]

void DynExp::Object::SetWarning ( std::string  Description,
int  ErrorCode 
) const

Setter for Object::Warning. Sets the warning by a description and an error code.

Parameters
DescriptionString describing the reason and consequences of the warning
ErrorCodeDynExp error code from DynExpErrorCodes::DynExpErrorCodes

Definition at line 454 of file Object.cpp.

Member Data Documentation

◆ GetParamsTimeoutDefault

constexpr std::chrono::milliseconds DynExp::Object::GetParamsTimeoutDefault = std::chrono::milliseconds(100)
staticconstexpr

Default timeout used by Object::GetParams() to lock the mutex of the parameter instance assigned to this Object instance.

Definition at line 2010 of file Object.h.

◆ IsBlocked

bool DynExp::Object::IsBlocked = false
private

This flag indicates whether this Object instance is blocked in order to be destroyed subsequently. Blocked objects are never ready (Object::IsReady() returns always false for them). Thus, RunnableInstance cannot lock this object instance anymore. Unblocking is not possible since blocking indicates approaching destruction.

Definition at line 2320 of file Object.h.

◆ LinkedObjectWrapperOnly

LinkedObjectWrapperOnlyType DynExp::Object::LinkedObjectWrapperOnly

Allow exclusive access to some of Object's private methods to any LinkedObjectWrapper<T>.

Definition at line 2242 of file Object.h.

◆ OwnerThreadID

const std::thread::id DynExp::Object::OwnerThreadID
private

Thread id of the thread which has constructed (and owns) this Object instance.

Definition at line 2302 of file Object.h.

◆ Params

const ParamsBasePtrType DynExp::Object::Params
private

Pointer to the parameter class instance belonging to this Object instance.

Definition at line 2303 of file Object.h.

◆ UserList

ObjectUserList DynExp::Object::UserList
private

List of Object instances making use of this Object instance. Other Object instances making use of this Object instance have to register and deregister themselves (via class LinkedObjectWrapper).

Definition at line 2312 of file Object.h.

◆ Warning

Util::Warning DynExp::Object::Warning
mutableprivate

Last warning which occurred within this Object instance. (Logical const-ness: see above.)

Definition at line 2305 of file Object.h.


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