summaryrefslogtreecommitdiff
path: root/TransceiverFactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TransceiverFactory.cpp')
-rw-r--r--TransceiverFactory.cpp88
1 files changed, 45 insertions, 43 deletions
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> ("TransceiverFactory::DataBits");
- qRegisterMetaTypeStreamOperators<TransceiverFactory::DataBits> ("TransceiverFactory::DataBits");
- qRegisterMetaType<TransceiverFactory::StopBits> ("TransceiverFactory::StopBits");
- qRegisterMetaTypeStreamOperators<TransceiverFactory::StopBits> ("TransceiverFactory::StopBits");
- qRegisterMetaType<TransceiverFactory::Handshake> ("TransceiverFactory::Handshake");
- qRegisterMetaTypeStreamOperators<TransceiverFactory::Handshake> ("TransceiverFactory::Handshake");
- qRegisterMetaType<TransceiverFactory::PTTMethod> ("TransceiverFactory::PTTMethod");
- qRegisterMetaTypeStreamOperators<TransceiverFactory::PTTMethod> ("TransceiverFactory::PTTMethod");
- qRegisterMetaType<TransceiverFactory::TXAudioSource> ("TransceiverFactory::TXAudioSource");
- qRegisterMetaTypeStreamOperators<TransceiverFactory::TXAudioSource> ("TransceiverFactory::TXAudioSource");
- qRegisterMetaType<TransceiverFactory::SplitMode> ("TransceiverFactory::SplitMode");
- qRegisterMetaTypeStreamOperators<TransceiverFactory::SplitMode> ("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<Transceiver> TransceiverFactory::create (ParameterPack const& pa
{
case CommanderId:
{
- // we start with a dummy HamlibTransceiver object instance that can support direct PTT
- std::unique_ptr<TransceiverBase> basic_transceiver {new HamlibTransceiver {params.ptt_type, params.ptt_port}};
- if (target_thread)
+ std::unique_ptr<TransceiverBase> 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<TransceiverBase> basic_transceiver {new HamlibTransceiver {params.ptt_type, params.ptt_port}};
- if (target_thread)
+ std::unique_ptr<TransceiverBase> 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<Transceiver> 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<TransceiverBase> basic_transceiver {new HamlibTransceiver {params.ptt_type, params.ptt_port}};
- if (target_thread)
+ std::unique_ptr<TransceiverBase> 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<TransceiverBase> basic_transceiver {new HamlibTransceiver {params.ptt_type, params.ptt_port}};
- if (target_thread)
+ std::unique_ptr<TransceiverBase> 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<Transceiver> 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<Transceiver> 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)