8#ifndef OCF_DAQ_SOURCE_HPP_
9#define OCF_DAQ_SOURCE_HPP_
15#include <Metadaqif.hpp>
17#include <boost/signals2/signal.hpp>
18#include <fmt/ostream.h>
38 <<
", error_flag=" << (s.
GetErrorFlag() ?
"true" :
"false");
48 template <
class Subscriber>
105 PrimSource(std::string name, std::shared_ptr<RrClient> client)
106 : m_name(std::move(name)), m_rr_client(std::move(client)) {
107 if (m_name.empty()) {
108 throw std::invalid_argument(
"'name' is invalid");
111 throw std::invalid_argument(
"'client' is invalid");
128 os <<
"PrimSource: " << s.m_name;
134 std::shared_ptr<RrClient> m_rr_client;
149 MetaSource(std::string name, std::shared_ptr<RrClient> client)
150 : m_name(std::move(name)), m_rr_client(std::move(client)) {
151 if (m_name.empty()) {
152 throw std::invalid_argument(
"'name' is invalid");
155 throw std::invalid_argument(
"'client' is invalid");
172 os <<
"MetaSource: " << s.m_name;
178 std::shared_ptr<RrClient> m_rr_client;
189 explicit DaqSources(std::vector<PrimSource> prim_sources, std::vector<MetaSource> meta_sources)
190 : m_prim_sources(std::move(prim_sources)), m_meta_sources(std::move(meta_sources)) {
193 return m_prim_sources;
197 return m_prim_sources;
201 return m_meta_sources;
205 return m_meta_sources;
209 std::vector<PrimSource> m_prim_sources;
210 std::vector<MetaSource> m_meta_sources;
216struct fmt::formatter<
daq::Source<T>> : ostream_formatter {};
219struct fmt::formatter<
daq::PrimSource> : ostream_formatter {};
222struct fmt::formatter<
daq::MetaSource> : ostream_formatter {};
Data acquisition sources.
std::vector< MetaSource > & GetMetadataSources() noexcept
std::vector< MetaSource > const & GetMetadataSources() const noexcept
std::vector< PrimSource > & GetPrimarySources() noexcept
DaqSources(std::vector< PrimSource > prim_sources, std::vector< MetaSource > meta_sources)
std::vector< PrimSource > const & GetPrimarySources() const noexcept
Keeps relevant state to be able to communicate with a primary data source.
PrimSource & operator=(PrimSource &&)=default
PrimSource(PrimSource &&)=default
std::string const & GetName() const
recif::RecCmdsAsync RrClient
friend std::ostream & operator<<(std::ostream &os, PrimSource const &s)
PrimSource(std::string name, std::shared_ptr< RrClient > client)
PrimSource & operator=(PrimSource &)=default
PrimSource(PrimSource const &)=default
Declares daq::State and related functions.
std::variant< PrimSource, MetaSource > SourceVariant
State
Observable states of the data acquisition process.
@ NotStarted
Initial state of data acquisition.
Config class header file.
Simple class that holds the source and associated state.
boost::signals2::connection ConnectStateListener(Subscriber subscriber)
Connect subscriber that is invoked on state changes.
T const & GetSource() const
friend std::ostream & operator<<(std::ostream &os, Source< T > const &s)
boost::signals2::signal< void(State, bool)> StateSignal
bool GetErrorFlag() const
StateSignal m_state_signal
void SetState(State state, std::optional< bool > error_flag={})