ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
Classes | Public Member Functions | Protected Member Functions | Friends | List of all members
daq::ObservableStatus Class Reference

Stores data acquisition status and allows subscription to status changes. More...

#include <status.hpp>

Classes

class  DeferSignal
 Defer signal changes until later time. More...
 

Public Member Functions

 ObservableStatus (std::string id, std::string file_id) noexcept
 Construct a new object. More...
 
 ObservableStatus (Status status)
 
 ObservableStatus (ObservableStatus &&)=default
 
 ObservableStatus (ObservableStatus const &)=delete
 
ObservableStatusoperator= (ObservableStatus &&)=default
 
ObservableStatusoperator= (ObservableStatus const &)=delete
 
bool operator== (ObservableStatus const &rhs) const noexcept
 
bool operator!= (ObservableStatus const &rhs) const noexcept
 
bool operator== (Status const &rhs) const noexcept
 
bool operator!= (Status const &rhs) const noexcept
 
ObservableStatusoperator= (Status const &status)
 Assign new status where the new status refers to the same DAQ. More...
 
Accessors
std::string const & GetId () const noexcept
 
std::string const & GetFileId () const noexcept
 
State GetState () const noexcept
 
bool GetError () const noexcept
 
std::vector< Alert > const & GetAlerts () const noexcept
 

Protected Member Functions

void SignalChanges (bool forced=false) noexcept
 Signal changes to observers. More...
 
void EnableSignals () noexcept
 
void DisableSignals () noexcept
 

Friends

class DeferSignal
 

Modifiers

using Signal = boost::signals2::signal< void(ObservableStatus const &)>
 Connect observer that is invoked when state is modified. More...
 
void SetState (State s, std::optional< bool > error=std::nullopt) noexcept
 Set state of data acquisition. More...
 
void SetError (bool error) noexcept
 Set error flag for data acquisition. More...
 
void SetResult (std::string result)
 Set resulting data product path. More...
 
void SetAlert (Alert alert)
 Set alert. More...
 
void ClearAlert (AlertId const &alert)
 Clear alert. More...
 
template<class Observer >
boost::signals2::connection ConnectObserver (Observer o)
 Connect observer that is invoked when state is modified. More...
 
boost::signals2::connection ConnectStatus (Signal::slot_type const &slot)
 Connect observer that is invoked when state is modified. More...
 
 operator Status () const
 Allow implicit conversion to non-observable status. More...
 
Status const & GetStatus () const noexcept
 Connect observer that is invoked when state is modified. More...
 

Detailed Description

Stores data acquisition status and allows subscription to status changes.

DaqController instances will update ObservableStatus as changes occur.

Definition at line 161 of file status.hpp.

Member Typedef Documentation

◆ Signal

using daq::ObservableStatus::Signal = boost::signals2::signal<void(ObservableStatus const&)>

Connect observer that is invoked when state is modified.

Parameters
oObserver callable invoked on status changes (state or file changes) Observer must be invocable with signature void(ObservableStatus const&).
Returns
signal connection object that can be used to disconnect observer:
auto c = status.ConnectObserver([](ObservableStatus const& s){});
// later the connection object can be used to disconnect
c.disconnect();

Definition at line 305 of file status.hpp.

Constructor & Destructor Documentation

◆ ObservableStatus() [1/4]

daq::ObservableStatus::ObservableStatus ( std::string  id,
std::string  file_id 
)
explicitnoexcept

Construct a new object.

Parameters
idData acquisition identifier.

Definition at line 139 of file status.cpp.

◆ ObservableStatus() [2/4]

daq::ObservableStatus::ObservableStatus ( Status  status)
explicit

Definition at line 136 of file status.cpp.

◆ ObservableStatus() [3/4]

daq::ObservableStatus::ObservableStatus ( ObservableStatus &&  )
default

◆ ObservableStatus() [4/4]

daq::ObservableStatus::ObservableStatus ( ObservableStatus const &  )
delete

Member Function Documentation

◆ ClearAlert()

void daq::ObservableStatus::ClearAlert ( AlertId const &  alert)

Clear alert.

Parameters
alertto clear.

Definition at line 223 of file status.cpp.

◆ ConnectObserver()

template<class Observer >
boost::signals2::connection daq::ObservableStatus::ConnectObserver ( Observer  o)
inline

Connect observer that is invoked when state is modified.

Parameters
oObserver callable invoked on status changes (state or file changes) Observer must be invocable with signature void(ObservableStatus const&).
Returns
signal connection object that can be used to disconnect observer:
auto c = status.ConnectObserver([](ObservableStatus const& s){});
// later the connection object can be used to disconnect
c.disconnect();

Definition at line 307 of file status.hpp.

◆ ConnectStatus()

boost::signals2::connection daq::ObservableStatus::ConnectStatus ( Signal::slot_type const &  slot)
inline

Connect observer that is invoked when state is modified.

Parameters
oObserver callable invoked on status changes (state or file changes) Observer must be invocable with signature void(ObservableStatus const&).
Returns
signal connection object that can be used to disconnect observer:
auto c = status.ConnectObserver([](ObservableStatus const& s){});
// later the connection object can be used to disconnect
c.disconnect();

Definition at line 310 of file status.hpp.

◆ DisableSignals()

void daq::ObservableStatus::DisableSignals ( )
protectednoexcept

Definition at line 251 of file status.cpp.

◆ EnableSignals()

void daq::ObservableStatus::EnableSignals ( )
protectednoexcept

Definition at line 247 of file status.cpp.

◆ GetAlerts()

std::vector< Alert > const & daq::ObservableStatus::GetAlerts ( ) const
noexcept
Returns
Data acquisition identifier

Definition at line 176 of file status.cpp.

◆ GetError()

bool daq::ObservableStatus::GetError ( ) const
noexcept
Returns
Data acquisition error flag.

Definition at line 188 of file status.cpp.

◆ GetFileId()

std::string const & daq::ObservableStatus::GetFileId ( ) const
noexcept
Returns
OLAS file id

Definition at line 180 of file status.cpp.

◆ GetId()

std::string const & daq::ObservableStatus::GetId ( ) const
noexcept
Returns
Data acquisition identifier

Definition at line 172 of file status.cpp.

◆ GetState()

State daq::ObservableStatus::GetState ( ) const
noexcept
Returns
Data acquisition state

Definition at line 184 of file status.cpp.

◆ GetStatus()

Status const & daq::ObservableStatus::GetStatus ( ) const
noexcept

Connect observer that is invoked when state is modified.

Parameters
oObserver callable invoked on status changes (state or file changes) Observer must be invocable with signature void(ObservableStatus const&).
Returns
signal connection object that can be used to disconnect observer:
auto c = status.ConnectObserver([](ObservableStatus const& s){});
// later the connection object can be used to disconnect
c.disconnect();

Definition at line 243 of file status.cpp.

◆ operator Status()

daq::ObservableStatus::operator Status ( ) const

Allow implicit conversion to non-observable status.

Definition at line 239 of file status.cpp.

◆ operator!=() [1/2]

bool daq::ObservableStatus::operator!= ( ObservableStatus const &  rhs) const
noexcept

Definition at line 160 of file status.cpp.

◆ operator!=() [2/2]

bool daq::ObservableStatus::operator!= ( Status const &  rhs) const
noexcept

Definition at line 168 of file status.cpp.

◆ operator=() [1/3]

ObservableStatus& daq::ObservableStatus::operator= ( ObservableStatus &&  )
default

◆ operator=() [2/3]

ObservableStatus& daq::ObservableStatus::operator= ( ObservableStatus const &  )
delete

◆ operator=() [3/3]

ObservableStatus & daq::ObservableStatus::operator= ( Status const &  status)

Assign new status where the new status refers to the same DAQ.

Parameters
statusNew status to assign from.
Exceptions
std::invalid_argumentif status.id is not equal to this->id.

Definition at line 143 of file status.cpp.

◆ operator==() [1/2]

bool daq::ObservableStatus::operator== ( ObservableStatus const &  rhs) const
noexcept

Definition at line 156 of file status.cpp.

◆ operator==() [2/2]

bool daq::ObservableStatus::operator== ( Status const &  rhs) const
noexcept

Definition at line 164 of file status.cpp.

◆ SetAlert()

void daq::ObservableStatus::SetAlert ( Alert  alert)

Set alert.

Note
An existing alert with same ID will be overwritten.
Parameters
alertto set.

Definition at line 218 of file status.cpp.

◆ SetError()

void daq::ObservableStatus::SetError ( bool  error)
noexcept

Set error flag for data acquisition.

Parameters
errorNew error flag status.
Postcondition
Connected observers have been signalled.

Definition at line 205 of file status.cpp.

◆ SetResult()

void daq::ObservableStatus::SetResult ( std::string  result)

Set resulting data product path.

Parameters
result

Definition at line 213 of file status.cpp.

◆ SetState()

void daq::ObservableStatus::SetState ( State  s,
std::optional< bool >  error = std::nullopt 
)
noexcept

Set state of data acquisition.

Parameters
sNew state
errorOptional new error flag value.
Postcondition
Connected observers have been signalled.

Definition at line 192 of file status.cpp.

◆ SignalChanges()

void daq::ObservableStatus::SignalChanges ( bool  forced = false)
protectednoexcept

Signal changes to observers.

Definition at line 229 of file status.cpp.

Friends And Related Function Documentation

◆ DeferSignal

friend class DeferSignal
friend

Definition at line 320 of file status.hpp.


The documentation for this class was generated from the following files:
daq::ObservableStatus::ObservableStatus
ObservableStatus(std::string id, std::string file_id) noexcept
Construct a new object.
Definition: status.cpp:139