DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Util::Warning Class Reference

Class to store information about warnings in a thread-safe manner (deriving from ILockable). All function calls are thread-safe. More...

+ Inheritance diagram for Util::Warning:

Classes

struct  WarningData
 Data associated with a warning. The class is convertible to bool (true if it describes an error/warning, false otherwise). More...
 

Public Member Functions

 Warning ()
 Constructs an empty Warning. More...
 
 Warning (std::string Description, const int ErrorCode=DynExpErrorCodes::GeneralError, const std::source_location Location=std::source_location::current())
 Constructs a Warning from specified information. More...
 
 Warning (const Exception &e)
 Constructs a Warning retrieving the warning data from an exception e. More...
 
 Warning (Warning &&Other) noexcept
 Constructs a Warning moving Other's warning data to this instance clearing Other's warning data. More...
 
virtual ~Warning ()=default
 
void Reset ()
 Clears the warning data. More...
 
Warningoperator= (const Exception &e)
 Retrives the warning data from an exception e derived from Exception. More...
 
Warningoperator= (Warning &&Other) noexcept
 Swaps in the warning data of this instance with Other's warning data. More...
 
WarningData Get () const
 Returns a copy of the warning data. More...
 
- Public Member Functions inherited from Util::INonCopyable
 INonCopyable (const INonCopyable &)=delete
 
INonCopyableoperator= (const INonCopyable &)=delete
 

Private Attributes

std::unique_ptr< WarningDataData
 Pointer to warning data. Must never be nullptr. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Util::ILockable
static constexpr std::chrono::milliseconds DefaultTimeout = std::chrono::milliseconds(10)
 Duration which is used as a default timeout within all methods of this class if no different duration is passed to them. More...
 
- Protected Types inherited from Util::ILockable
using MutexType = std::timed_mutex
 
using LockType = std::unique_lock< MutexType >
 
- Protected Member Functions inherited from Util::ILockable
 ILockable ()=default
 
 ~ILockable ()=default
 
LockType AcquireLock (const std::chrono::milliseconds Timeout=DefaultTimeout) const
 Locks the internal mutex. Blocks until the mutex is locked or until the timeout duration is exceeded. More...
 
- Protected Member Functions inherited from Util::INonCopyable
constexpr INonCopyable ()=default
 
 ~INonCopyable ()=default
 

Detailed Description

Class to store information about warnings in a thread-safe manner (deriving from ILockable). All function calls are thread-safe.

Definition at line 965 of file Util.h.

Constructor & Destructor Documentation

◆ Warning() [1/4]

Util::Warning::Warning ( )
inline

Constructs an empty Warning.

Definition at line 1000 of file Util.h.

◆ Warning() [2/4]

Util::Warning::Warning ( std::string  Description,
const int  ErrorCode = DynExpErrorCodes::GeneralError,
const std::source_location  Location = std::source_location::current() 
)
inline

Constructs a Warning from specified information.

Parameters
DescriptionString describing the reason and consequences of the warning
ErrorCodeDynExp error code from DynExpErrorCodes::DynExpErrorCodes
LocationOrigin of the warning. Do not pass anything except when deriving from this class.

Definition at line 1008 of file Util.h.

◆ Warning() [3/4]

Util::Warning::Warning ( const Exception e)
inline

Constructs a Warning retrieving the warning data from an exception e.

Parameters
eException derived from class Exception

Definition at line 1016 of file Util.h.

◆ Warning() [4/4]

Util::Warning::Warning ( Warning &&  Other)
noexcept

Constructs a Warning moving Other's warning data to this instance clearing Other's warning data.

Parameters
OtherWarning to move from

Definition at line 266 of file Util.cpp.

◆ ~Warning()

virtual Util::Warning::~Warning ( )
virtualdefault

Member Function Documentation

◆ Get()

Warning::WarningData Util::Warning::Get ( ) const

Returns a copy of the warning data.

Definition at line 297 of file Util.cpp.

◆ operator=() [1/2]

Warning & Util::Warning::operator= ( const Exception e)

Retrives the warning data from an exception e derived from Exception.

Definition at line 280 of file Util.cpp.

◆ operator=() [2/2]

Warning & Util::Warning::operator= ( Warning &&  Other)
noexcept

Swaps in the warning data of this instance with Other's warning data.

Definition at line 288 of file Util.cpp.

◆ Reset()

void Util::Warning::Reset ( )

Clears the warning data.

Definition at line 273 of file Util.cpp.

Member Data Documentation

◆ Data

std::unique_ptr<WarningData> Util::Warning::Data
private

Pointer to warning data. Must never be nullptr.

Definition at line 1038 of file Util.h.


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