From 119aff65d8ad0c4cdaff32d9b68cee00d90a5f35 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Mon, 31 Dec 2012 14:36:08 +0000 Subject: [PATCH] Added pv::data::Decoder container object --- CMakeLists.txt | 1 + pv/data/decoder.cpp | 41 +++++++++++++++++++++++++++++++++++ pv/data/decoder.h | 47 ++++++++++++++++++++++++++++++++++++++++ pv/sigsession.cpp | 8 ++++++- pv/view/decodesignal.cpp | 9 +++++--- pv/view/decodesignal.h | 10 +++++++-- 6 files changed, 110 insertions(+), 6 deletions(-) create mode 100644 pv/data/decoder.cpp create mode 100644 pv/data/decoder.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e7235970..e66f1251 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,7 @@ set(pulseview_SOURCES pv/sigsession.cpp pv/data/analog.cpp pv/data/analogsnapshot.cpp + pv/data/decoder.cpp pv/data/logic.cpp pv/data/logicsnapshot.cpp pv/data/signaldata.cpp diff --git a/pv/data/decoder.cpp b/pv/data/decoder.cpp new file mode 100644 index 00000000..ea0fed6b --- /dev/null +++ b/pv/data/decoder.cpp @@ -0,0 +1,41 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2012 Joel Holdsworth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "decoder.h" + +namespace pv { +namespace data { + +Decoder::Decoder(const srd_decoder *const dec) : + _decoder(dec) +{ +} + +const srd_decoder* Decoder::get_decoder() const +{ + return _decoder; +} + +void Decoder::clear_snapshots() +{ +} + +} // namespace data +} // namespace pv diff --git a/pv/data/decoder.h b/pv/data/decoder.h new file mode 100644 index 00000000..228aedab --- /dev/null +++ b/pv/data/decoder.h @@ -0,0 +1,47 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2012 Joel Holdsworth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef PULSEVIEW_PV_DATA_DECODER_H +#define PULSEVIEW_PV_DATA_DECODER_H + +#include "signaldata.h" + +struct srd_decoder; + +namespace pv { +namespace data { + +class Decoder : public SignalData +{ +public: + Decoder(const srd_decoder *const dec); + + const srd_decoder* get_decoder() const; + + void clear_snapshots(); + +private: + const srd_decoder *const _decoder; +}; + +} // namespace data +} // namespace pv + +#endif // PULSEVIEW_PV_DATA_DECODER_H diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index c2c2dc98..da5d3f01 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -21,8 +21,10 @@ #include "sigsession.h" #include "devicemanager.h" + #include "data/analog.h" #include "data/analogsnapshot.h" +#include "data/decoder.h" #include "data/logic.h" #include "data/logicsnapshot.h" @@ -199,7 +201,11 @@ boost::shared_ptr SigSession::get_data() void SigSession::add_decoder(srd_decoder *const dec) { { - shared_ptr d(new view::DecodeSignal(*this, dec)); + lock_guard lock(_signals_mutex); + shared_ptr decoder( + new data::Decoder(dec)); + shared_ptr d( + new view::DecodeSignal(*this, decoder)); _decode_traces.push_back(d); } signals_changed(); diff --git a/pv/view/decodesignal.cpp b/pv/view/decodesignal.cpp index 1e534275..d2717892 100644 --- a/pv/view/decodesignal.cpp +++ b/pv/view/decodesignal.cpp @@ -24,15 +24,18 @@ extern "C" { #include "decodesignal.h" +#include + using namespace boost; using namespace std; namespace pv { namespace view { -DecodeSignal::DecodeSignal(pv::SigSession &session, srd_decoder *const dec) : - Trace(session, QString(dec->name)), - _decoder(dec) +DecodeSignal::DecodeSignal(pv::SigSession &session, + boost::shared_ptr decoder) : + Trace(session, QString(decoder->get_decoder()->name)), + _decoder(decoder) { _colour = Qt::red; } diff --git a/pv/view/decodesignal.h b/pv/view/decodesignal.h index e52c7947..755fefe6 100644 --- a/pv/view/decodesignal.h +++ b/pv/view/decodesignal.h @@ -26,12 +26,18 @@ #include namespace pv { + +namespace data { +class Decoder; +} + namespace view { class DecodeSignal : public Trace { public: - DecodeSignal(pv::SigSession &session, srd_decoder *const dec); + DecodeSignal(pv::SigSession &session, + boost::shared_ptr decoder); void init_context_bar_actions(QWidget *parent); @@ -61,7 +67,7 @@ private: int get_nominal_offset(const QRect &rect) const; private: - srd_decoder *const _decoder; + boost::shared_ptr _decoder; }; } // namespace view -- 2.30.2