From 6e89374a6796f8d5d9cc61b0a2f7e98562a034ae Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sun, 27 Oct 2013 13:15:16 +0000 Subject: [PATCH] Renamed pv::data::Decoder to DecoderStack --- CMakeLists.txt | 6 +-- pv/data/{decoder.cpp => decoderstack.cpp} | 42 +++++++++---------- pv/data/{decoder.h => decoderstack.h} | 18 ++++---- pv/prop/binding/decoderoptions.cpp | 4 +- pv/prop/binding/decoderoptions.h | 6 +-- pv/sigsession.cpp | 4 +- pv/view/decodetrace.cpp | 46 ++++++++++----------- pv/view/decodetrace.h | 9 ++-- test/CMakeLists.txt | 6 +-- test/data/{decoder.cpp => decoderstack.cpp} | 10 ++--- 10 files changed, 76 insertions(+), 75 deletions(-) rename pv/data/{decoder.cpp => decoderstack.cpp} (82%) rename pv/data/{decoder.h => decoderstack.h} (87%) rename test/data/{decoder.cpp => decoderstack.cpp} (89%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 51ba86ef..0f7502a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -## + ## This file is part of the PulseView project. ## ## Copyright (C) 2012 Joel Holdsworth @@ -107,7 +107,7 @@ set(pulseview_SOURCES pv/sigsession.cpp pv/data/analog.cpp pv/data/analogsnapshot.cpp - pv/data/decoder.cpp + pv/data/decoderstack.cpp pv/data/logic.cpp pv/data/logicsnapshot.cpp pv/data/signaldata.cpp @@ -154,7 +154,7 @@ set(pulseview_SOURCES set(pulseview_HEADERS pv/mainwindow.h pv/sigsession.h - pv/data/decoder.h + pv/data/decoderstack.h pv/dialogs/about.h pv/dialogs/connect.h pv/popups/deviceoptions.h diff --git a/pv/data/decoder.cpp b/pv/data/decoderstack.cpp similarity index 82% rename from pv/data/decoder.cpp rename to pv/data/decoderstack.cpp index a9168ae2..d56422a9 100644 --- a/pv/data/decoder.cpp +++ b/pv/data/decoderstack.cpp @@ -26,7 +26,7 @@ #include -#include "decoder.h" +#include "decoderstack.h" #include #include @@ -39,20 +39,20 @@ using namespace std; namespace pv { namespace data { -const double Decoder::DecodeMargin = 1.0; -const double Decoder::DecodeThreshold = 0.2; -const int64_t Decoder::DecodeChunkLength = 4096; +const double DecoderStack::DecodeMargin = 1.0; +const double DecoderStack::DecodeThreshold = 0.2; +const int64_t DecoderStack::DecodeChunkLength = 4096; -mutex Decoder::_global_decode_mutex; +mutex DecoderStack::_global_decode_mutex; -Decoder::Decoder(const srd_decoder *const dec) : +DecoderStack::DecoderStack(const srd_decoder *const dec) : _decoder(dec), _options(g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_variant_unref)) { } -Decoder::~Decoder() +DecoderStack::~DecoderStack() { _decode_thread.interrupt(); _decode_thread.join(); @@ -60,30 +60,30 @@ Decoder::~Decoder() g_hash_table_destroy(_options); } -const srd_decoder* Decoder::decoder() const +const srd_decoder* DecoderStack::decoder() const { return _decoder; } const map >& -Decoder::probes() const +DecoderStack::probes() const { return _probes; } -void Decoder::set_probes(std::map > probes) { _probes = probes; begin_decode(); } -const GHashTable* Decoder::options() const +const GHashTable* DecoderStack::options() const { return _options; } -void Decoder::set_option(const char *id, GVariant *value) +void DecoderStack::set_option(const char *id, GVariant *value) { g_variant_ref(value); g_hash_table_replace(_options, (void*)g_strdup(id), value); @@ -91,19 +91,19 @@ void Decoder::set_option(const char *id, GVariant *value) } const vector< shared_ptr > - Decoder::annotations() const + DecoderStack::annotations() const { lock_guard lock(_mutex); return _annotations; } -QString Decoder::error_message() +QString DecoderStack::error_message() { lock_guard lock(_mutex); return _error_message; } -void Decoder::begin_decode() +void DecoderStack::begin_decode() { _decode_thread.interrupt(); _decode_thread.join(); @@ -135,15 +135,15 @@ void Decoder::begin_decode() assert(sig); shared_ptr data = sig->data(); - _decode_thread = boost::thread(&Decoder::decode_proc, this, + _decode_thread = boost::thread(&DecoderStack::decode_proc, this, data); } -void Decoder::clear_snapshots() +void DecoderStack::clear_snapshots() { } -void Decoder::decode_proc(shared_ptr data) +void DecoderStack::decode_proc(shared_ptr data) { srd_session *session; uint8_t chunk[DecodeChunkLength]; @@ -167,7 +167,7 @@ void Decoder::decode_proc(shared_ptr data) g_variant_new_uint64((uint64_t)_samplerate)); srd_pd_output_callback_add(session, SRD_OUTPUT_ANN, - Decoder::annotation_callback, this); + DecoderStack::annotation_callback, this); // Create the decoder instance srd_decoder_inst *const decoder_inst = srd_inst_new( @@ -218,14 +218,14 @@ void Decoder::decode_proc(shared_ptr data) srd_session_destroy(session); } -void Decoder::annotation_callback(srd_proto_data *pdata, void *decoder) +void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder) { using namespace pv::view::decode; assert(pdata); assert(decoder); - Decoder *const d = (Decoder*)decoder; + DecoderStack *const d = (DecoderStack*)decoder; shared_ptr a(new Annotation(pdata)); lock_guard lock(d->_mutex); diff --git a/pv/data/decoder.h b/pv/data/decoderstack.h similarity index 87% rename from pv/data/decoder.h rename to pv/data/decoderstack.h index 72ccd2ec..844a2b54 100644 --- a/pv/data/decoder.h +++ b/pv/data/decoderstack.h @@ -18,8 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef PULSEVIEW_PV_DATA_DECODER_H -#define PULSEVIEW_PV_DATA_DECODER_H +#ifndef PULSEVIEW_PV_DATA_DECODERSTACK_H +#define PULSEVIEW_PV_DATA_DECODERSTACK_H #include "signaldata.h" @@ -37,8 +37,8 @@ struct srd_decoder; struct srd_probe; struct srd_proto_data; -namespace DecoderTest { -class TwoDecoder; +namespace DecoderStackTest { +class TwoDecoderStack; } namespace pv { @@ -56,7 +56,7 @@ namespace data { class Logic; -class Decoder : public QObject, public SignalData +class DecoderStack : public QObject, public SignalData { Q_OBJECT @@ -66,9 +66,9 @@ private: static const int64_t DecodeChunkLength; public: - Decoder(const srd_decoder *const decoder); + DecoderStack(const srd_decoder *const decoder); - virtual ~Decoder(); + virtual ~DecoderStack(); const srd_decoder* decoder() const; @@ -121,10 +121,10 @@ private: boost::thread _decode_thread; - friend class DecoderTest::TwoDecoder; + friend class DecoderStackTest::TwoDecoderStack; }; } // namespace data } // namespace pv -#endif // PULSEVIEW_PV_DATA_DECODER_H +#endif // PULSEVIEW_PV_DATA_DECODERSTACK_H diff --git a/pv/prop/binding/decoderoptions.cpp b/pv/prop/binding/decoderoptions.cpp index 5ad7e356..0a6cd15c 100644 --- a/pv/prop/binding/decoderoptions.cpp +++ b/pv/prop/binding/decoderoptions.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -36,7 +36,7 @@ namespace pv { namespace prop { namespace binding { -DecoderOptions::DecoderOptions(shared_ptr decoder) : +DecoderOptions::DecoderOptions(shared_ptr decoder) : _decoder(decoder) { assert(_decoder); diff --git a/pv/prop/binding/decoderoptions.h b/pv/prop/binding/decoderoptions.h index 11b0be72..e507e87c 100644 --- a/pv/prop/binding/decoderoptions.h +++ b/pv/prop/binding/decoderoptions.h @@ -28,7 +28,7 @@ namespace pv { namespace data { -class Decoder; +class DecoderStack; } namespace prop { @@ -37,7 +37,7 @@ namespace binding { class DecoderOptions : public Binding { public: - DecoderOptions(boost::shared_ptr decoder); + DecoderOptions(boost::shared_ptr decoder); private: GVariant* getter(const char *id); @@ -45,7 +45,7 @@ private: void setter(const char *id, GVariant *value); private: - boost::shared_ptr _decoder; + boost::shared_ptr _decoder; }; } // binding diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 24a059ea..a6a2875e 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -26,7 +26,7 @@ #include "data/analog.h" #include "data/analogsnapshot.h" -#include "data/decoder.h" +#include "data/decoderstack.h" #include "data/logic.h" #include "data/logicsnapshot.h" @@ -208,7 +208,7 @@ bool SigSession::add_decoder(srd_decoder *const dec) lock_guard lock(_signals_mutex); // Create the decoder - shared_ptr decoder(new data::Decoder(dec)); + shared_ptr decoder(new data::DecoderStack(dec)); // Auto select the initial probes for(const GSList *i = dec->probes; i; i = i->next) diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 29c4a6e9..51b17e5e 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -36,7 +36,7 @@ extern "C" { #include "decodetrace.h" #include -#include +#include #include #include #include @@ -58,16 +58,16 @@ const QColor DecodeTrace::DecodeColours[4] = { const QColor DecodeTrace::ErrorBgColour = QColor(0xEF, 0x29, 0x29); DecodeTrace::DecodeTrace(pv::SigSession &session, - boost::shared_ptr decoder, int index) : - Trace(session, QString(decoder->decoder()->name)), - _decoder(decoder), - _binding(decoder) + boost::shared_ptr decoder_stack, int index) : + Trace(session, QString(decoder_stack->decoder()->name)), + _decoder_stack(decoder_stack), + _binding(decoder_stack) { - assert(_decoder); + assert(_decoder_stack); _colour = DecodeColours[index % countof(DecodeColours)]; - connect(_decoder.get(), SIGNAL(new_decode_data()), + connect(_decoder_stack.get(), SIGNAL(new_decode_data()), this, SLOT(on_new_decode_data())); } @@ -76,9 +76,9 @@ bool DecodeTrace::enabled() const return true; } -const boost::shared_ptr& DecodeTrace::decoder() const +const boost::shared_ptr& DecodeTrace::decoder() const { - return _decoder; + return _decoder_stack; } void DecodeTrace::set_view(pv::view::View *view) @@ -96,8 +96,8 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) { using namespace pv::view::decode; - assert(_decoder); - const QString err = _decoder->error_message(); + assert(_decoder_stack); + const QString err = _decoder_stack->error_message(); if (!err.isEmpty()) { draw_error(p, err, left, right); return; @@ -109,18 +109,18 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) const double scale = _view->scale(); assert(scale > 0); - double samplerate = _decoder->get_samplerate(); + double samplerate = _decoder_stack->get_samplerate(); // Show sample rate as 1Hz when it is unknown if (samplerate == 0.0) samplerate = 1.0; const double pixels_offset = (_view->offset() - - _decoder->get_start_time()) / scale; + _decoder_stack->get_start_time()) / scale; const double samples_per_pixel = samplerate * scale; - assert(_decoder); - vector< shared_ptr > annotations(_decoder->annotations()); + assert(_decoder_stack); + vector< shared_ptr > annotations(_decoder_stack->annotations()); BOOST_FOREACH(shared_ptr a, annotations) { assert(a); a->paint(p, get_text_colour(), _text_size.height(), @@ -134,9 +134,9 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form) assert(form); assert(parent); - assert(_decoder); + assert(_decoder_stack); - const srd_decoder *const decoder = _decoder->decoder(); + const srd_decoder *const decoder = _decoder_stack->decoder(); assert(decoder); @@ -184,7 +184,7 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form) // Add stacking button QPushButton *const stack_button = - new QPushButton(tr("Stack Decoder"), parent); + new QPushButton(tr("Stack DecoderStack"), parent); pv::widgets::DecoderMenu *const decoder_menu = new pv::widgets::DecoderMenu(parent); stack_button->setMenu(decoder_menu); @@ -234,16 +234,16 @@ QComboBox* DecodeTrace::create_probe_selector( { const vector< shared_ptr > sigs = _session.get_signals(); - assert(_decoder); + assert(_decoder_stack); const map >::const_iterator probe_iter = - _decoder->probes().find(probe); + _decoder_stack->probes().find(probe); QComboBox *selector = new QComboBox(parent); selector->addItem("-", qVariantFromValue((void*)NULL)); - if (probe_iter == _decoder->probes().end()) + if (probe_iter == _decoder_stack->probes().end()) selector->setCurrentIndex(0); for(size_t i = 0; i < sigs.size(); i++) { @@ -264,7 +264,7 @@ QComboBox* DecodeTrace::create_probe_selector( void DecodeTrace::commit_probes() { - assert(_decoder); + assert(_decoder_stack); map > probe_map; const vector< shared_ptr > sigs = _session.get_signals(); @@ -286,7 +286,7 @@ void DecodeTrace::commit_probes() } } - _decoder->set_probes(probe_map); + _decoder_stack->set_probes(probe_map); } void DecodeTrace::on_new_decode_data() diff --git a/pv/view/decodetrace.h b/pv/view/decodetrace.h index 6f7182f4..229df86d 100644 --- a/pv/view/decodetrace.h +++ b/pv/view/decodetrace.h @@ -36,7 +36,7 @@ class QComboBox; namespace pv { namespace data { -class Decoder; +class DecoderStack; } namespace view { @@ -51,11 +51,12 @@ private: public: DecodeTrace(pv::SigSession &session, - boost::shared_ptr decoder, int index); + boost::shared_ptr decoder_stack, + int index); bool enabled() const; - const boost::shared_ptr& decoder() const; + const boost::shared_ptr& decoder() const; void set_view(pv::view::View *view); @@ -98,7 +99,7 @@ private slots: void on_probe_selected(int); private: - boost::shared_ptr _decoder; + boost::shared_ptr _decoder_stack; uint64_t _decode_start, _decode_end; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index afe26a16..5cc18c16 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -41,7 +41,7 @@ set(pulseview_TEST_SOURCES ${PROJECT_SOURCE_DIR}/pv/view/cursorpair.cpp ${PROJECT_SOURCE_DIR}/pv/data/analog.cpp ${PROJECT_SOURCE_DIR}/pv/data/analogsnapshot.cpp - ${PROJECT_SOURCE_DIR}/pv/data/decoder.cpp + ${PROJECT_SOURCE_DIR}/pv/data/decoderstack.cpp ${PROJECT_SOURCE_DIR}/pv/data/logic.cpp ${PROJECT_SOURCE_DIR}/pv/data/logicsnapshot.cpp ${PROJECT_SOURCE_DIR}/pv/data/snapshot.cpp @@ -73,7 +73,7 @@ set(pulseview_TEST_SOURCES ${PROJECT_SOURCE_DIR}/pv/widgets/popup.cpp ${PROJECT_SOURCE_DIR}/pv/widgets/wellarray.cpp data/analogsnapshot.cpp - data/decoder.cpp + data/decoderstack.cpp data/logicsnapshot.cpp test.cpp ) @@ -81,7 +81,7 @@ set(pulseview_TEST_SOURCES # This list includes only QObject derrived class headers set(pulseview_TEST_HEADERS ${PROJECT_SOURCE_DIR}/pv/sigsession.h - ${PROJECT_SOURCE_DIR}/pv/data/decoder.h + ${PROJECT_SOURCE_DIR}/pv/data/decoderstack.h ${PROJECT_SOURCE_DIR}/pv/prop/int.h ${PROJECT_SOURCE_DIR}/pv/prop/property.h ${PROJECT_SOURCE_DIR}/pv/prop/string.h diff --git a/test/data/decoder.cpp b/test/data/decoderstack.cpp similarity index 89% rename from test/data/decoder.cpp rename to test/data/decoderstack.cpp index 6a48fb04..84a496f1 100644 --- a/test/data/decoder.cpp +++ b/test/data/decoderstack.cpp @@ -23,7 +23,7 @@ #include -#include "../../pv/data/decoder.h" +#include "../../pv/data/decoderstack.h" #include "../../pv/devicemanager.h" #include "../../pv/sigsession.h" #include "../../pv/view/decodetrace.h" @@ -31,9 +31,9 @@ using namespace boost; using namespace std; -BOOST_AUTO_TEST_SUITE(DecoderTest) +BOOST_AUTO_TEST_SUITE(DecoderStackTest) -BOOST_AUTO_TEST_CASE(TwoDecoder) +BOOST_AUTO_TEST_CASE(TwoDecoderStack) { using namespace pv; @@ -62,10 +62,10 @@ BOOST_AUTO_TEST_CASE(TwoDecoder) const vector< shared_ptr > sigs = ss.get_decode_signals(); - shared_ptr dec0 = sigs[0]->decoder(); + shared_ptr dec0 = sigs[0]->decoder(); BOOST_REQUIRE(dec0); - shared_ptr dec1 = sigs[0]->decoder(); + shared_ptr dec1 = sigs[0]->decoder(); BOOST_REQUIRE(dec1); // Wait for the decode threads to complete -- 2.30.2