/** * @RDE_HEADER@ * SimpleCommand * $Id$ * $HeadURL$ * $Author$ * Created by Christian Fröbel, SLSE, 2017-07-11 */ #include "simple_command.h" #include "iava_comm.h" #include "iava_command_done_observer.h" #include "ivd_comm.h" #include "ivd_command_done_observer.h" #include namespace AudioVideoManagement { namespace detail { template SimpleCommand::SimpleCommand(const QString &commandDesc, Comm *comm, DoneObserver *observer, std::function commandInvoker, int okCount) : m_commandInvoker(std::move(commandInvoker)) , m_expectedOkCount(okCount) , m_comm(comm) , m_observer(observer) , m_commandDesc(commandDesc) { Q_ASSERT(comm); Q_ASSERT(observer); Q_ASSERT(okCount > 0); } template void SimpleCommand::send() { connect(m_comm, &Comm::ok, this, &SimpleCommand::onOk); m_commandInvoker(m_comm); } template void SimpleCommand::onOk() { Q_ASSERT(m_okCount < m_expectedOkCount); ++m_okCount; if (m_okCount == m_expectedOkCount) done(); } template void SimpleCommand::done() { m_comm->disconnect(this); m_observer->done(this); } /** * Explicit template instantiations. */ ///@{ template class SimpleCommand; template class SimpleCommand; ///@} } // namespace detail } // namespace AudioVideoManagement