ifw-daq  3.0.0-pre2
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 165 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();
ObservableStatus(std::string id, std::string file_id) noexcept
Construct a new object.
Definition: status.cpp:170

Definition at line 309 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 170 of file status.cpp.

◆ ObservableStatus() [2/4]

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

Definition at line 167 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 254 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 311 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 314 of file status.hpp.

◆ DisableSignals()

void daq::ObservableStatus::DisableSignals ( )
protectednoexcept

Definition at line 282 of file status.cpp.

◆ EnableSignals()

void daq::ObservableStatus::EnableSignals ( )
protectednoexcept

Definition at line 278 of file status.cpp.

◆ GetAlerts()

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

Definition at line 207 of file status.cpp.

◆ GetError()

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

Definition at line 219 of file status.cpp.

◆ GetFileId()

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

Definition at line 211 of file status.cpp.

◆ GetId()

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

Definition at line 203 of file status.cpp.

◆ GetState()

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

Definition at line 215 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 274 of file status.cpp.

◆ operator Status()

daq::ObservableStatus::operator Status ( ) const

Allow implicit conversion to non-observable status.

Definition at line 270 of file status.cpp.

◆ operator!=() [1/2]

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

Definition at line 191 of file status.cpp.

◆ operator!=() [2/2]

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

Definition at line 199 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 174 of file status.cpp.

◆ operator==() [1/2]

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

Definition at line 187 of file status.cpp.

◆ operator==() [2/2]

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

Definition at line 195 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 249 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 236 of file status.cpp.

◆ SetResult()

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

Set resulting data product path.

Parameters
result

Definition at line 244 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 223 of file status.cpp.

◆ SignalChanges()

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

Signal changes to observers.

Definition at line 260 of file status.cpp.

Friends And Related Function Documentation

◆ DeferSignal

friend class DeferSignal
friend

Definition at line 324 of file status.hpp.


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