From 37f727ac0746fd85504aa46c1f023c09b3eff33a Mon Sep 17 00:00:00 2001 From: hibby Date: Fri, 16 Feb 2018 15:17:14 +0000 Subject: New upstream version 1.8.0+repack --- TransceiverFactory.cpp | 88 ++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 43 deletions(-) (limited to 'TransceiverFactory.cpp') diff --git a/TransceiverFactory.cpp b/TransceiverFactory.cpp index cfe58487..78ce2244 100644 --- a/TransceiverFactory.cpp +++ b/TransceiverFactory.cpp @@ -21,25 +21,6 @@ char const * const TransceiverFactory::basic_transceiver_name_ = "None"; namespace { - struct init - { - init () - { - qRegisterMetaType ("TransceiverFactory::DataBits"); - qRegisterMetaTypeStreamOperators ("TransceiverFactory::DataBits"); - qRegisterMetaType ("TransceiverFactory::StopBits"); - qRegisterMetaTypeStreamOperators ("TransceiverFactory::StopBits"); - qRegisterMetaType ("TransceiverFactory::Handshake"); - qRegisterMetaTypeStreamOperators ("TransceiverFactory::Handshake"); - qRegisterMetaType ("TransceiverFactory::PTTMethod"); - qRegisterMetaTypeStreamOperators ("TransceiverFactory::PTTMethod"); - qRegisterMetaType ("TransceiverFactory::TXAudioSource"); - qRegisterMetaTypeStreamOperators ("TransceiverFactory::TXAudioSource"); - qRegisterMetaType ("TransceiverFactory::SplitMode"); - qRegisterMetaTypeStreamOperators ("TransceiverFactory::SplitMode"); - } - } static_initializer; - enum // supported non-hamlib radio interfaces { NonHamlibBaseId = 9899 @@ -62,6 +43,11 @@ TransceiverFactory::TransceiverFactory () #endif } +TransceiverFactory::~TransceiverFactory () +{ + HamlibTransceiver::unregister_transceivers (); +} + auto TransceiverFactory::supported_transceivers () const -> Transceivers const& { return transceivers_; @@ -101,36 +87,44 @@ std::unique_ptr TransceiverFactory::create (ParameterPack const& pa { case CommanderId: { - // we start with a dummy HamlibTransceiver object instance that can support direct PTT - std::unique_ptr basic_transceiver {new HamlibTransceiver {params.ptt_type, params.ptt_port}}; - if (target_thread) + std::unique_ptr basic_transceiver; + if (PTT_method_CAT != params.ptt_type) { - basic_transceiver.get ()->moveToThread (target_thread); + // we start with a dummy HamlibTransceiver object instance that can support direct PTT + basic_transceiver.reset (new HamlibTransceiver {params.ptt_type, params.ptt_port}); + if (target_thread) + { + basic_transceiver.get ()->moveToThread (target_thread); + } } // wrap the basic Transceiver object instance with a decorator object that talks to DX Lab Suite Commander result.reset (new DXLabSuiteCommanderTransceiver {std::move (basic_transceiver), params.network_port, PTT_method_CAT == params.ptt_type, params.poll_interval}); if (target_thread) { - result.get ()->moveToThread (target_thread); + result->moveToThread (target_thread); } } break; case HRDId: { - // we start with a dummy HamlibTransceiver object instance that can support direct PTT - std::unique_ptr basic_transceiver {new HamlibTransceiver {params.ptt_type, params.ptt_port}}; - if (target_thread) + std::unique_ptr basic_transceiver; + if (PTT_method_CAT != params.ptt_type) { - basic_transceiver.get ()->moveToThread (target_thread); + // we start with a dummy HamlibTransceiver object instance that can support direct PTT + basic_transceiver.reset (new HamlibTransceiver {params.ptt_type, params.ptt_port}); + if (target_thread) + { + basic_transceiver.get ()->moveToThread (target_thread); + } } // wrap the basic Transceiver object instance with a decorator object that talks to ham Radio Deluxe - result.reset (new HRDTransceiver {std::move (basic_transceiver), params.network_port, PTT_method_CAT == params.ptt_type, params.poll_interval}); + result.reset (new HRDTransceiver {std::move (basic_transceiver), params.network_port, PTT_method_CAT == params.ptt_type, params.audio_source, params.poll_interval}); if (target_thread) { - result.get ()->moveToThread (target_thread); + result->moveToThread (target_thread); } } break; @@ -138,36 +132,44 @@ std::unique_ptr TransceiverFactory::create (ParameterPack const& pa #if defined (WIN32) case OmniRigOneId: { - // we start with a dummy HamlibTransceiver object instance that can support direct PTT - std::unique_ptr basic_transceiver {new HamlibTransceiver {params.ptt_type, params.ptt_port}}; - if (target_thread) + std::unique_ptr basic_transceiver; + if (PTT_method_CAT != params.ptt_type && "CAT" != params.ptt_port) { - basic_transceiver.get ()->moveToThread (target_thread); + // we start with a dummy HamlibTransceiver object instance that can support direct PTT + basic_transceiver.reset (new HamlibTransceiver {params.ptt_type, params.ptt_port}); + if (target_thread) + { + basic_transceiver.get ()->moveToThread (target_thread); + } } // wrap the basic Transceiver object instance with a decorator object that talks to OmniRig rig one result.reset (new OmniRigTransceiver {std::move (basic_transceiver), OmniRigTransceiver::One, params.ptt_type, params.ptt_port}); if (target_thread) { - result.get ()->moveToThread (target_thread); + result->moveToThread (target_thread); } } break; case OmniRigTwoId: { - // we start with a dummy HamlibTransceiver object instance that can support direct PTT - std::unique_ptr basic_transceiver {new HamlibTransceiver {params.ptt_type, params.ptt_port}}; - if (target_thread) + std::unique_ptr basic_transceiver; + if (PTT_method_CAT != params.ptt_type && "CAT" != params.ptt_port) { - basic_transceiver.get ()->moveToThread (target_thread); + // we start with a dummy HamlibTransceiver object instance that can support direct PTT + basic_transceiver.reset (new HamlibTransceiver {params.ptt_type, params.ptt_port}); + if (target_thread) + { + basic_transceiver.get ()->moveToThread (target_thread); + } } // wrap the basic Transceiver object instance with a decorator object that talks to OmniRig rig two result.reset (new OmniRigTransceiver {std::move (basic_transceiver), OmniRigTransceiver::Two, params.ptt_type, params.ptt_port}); if (target_thread) { - result.get ()->moveToThread (target_thread); + result->moveToThread (target_thread); } } break; @@ -177,7 +179,7 @@ std::unique_ptr TransceiverFactory::create (ParameterPack const& pa result.reset (new HamlibTransceiver {supported_transceivers ()[params.rig_name].model_number_, params}); if (target_thread) { - result.get ()->moveToThread (target_thread); + result->moveToThread (target_thread); } break; } @@ -188,11 +190,11 @@ std::unique_ptr TransceiverFactory::create (ParameterPack const& pa result.reset (new EmulateSplitTransceiver {std::move (result)}); if (target_thread) { - result.get ()->moveToThread (target_thread); + result->moveToThread (target_thread); } } - return std::move (result); + return result; } #if !defined (QT_NO_DEBUG_STREAM) -- cgit v1.2.3