Added DevInst pointer to Signal
[pulseview.git] / pv / data / decode / decoder.cpp
index 05adf250717549f27c74e1c2225578ea5de3da6c..b293cacb010790c61f46edef34c7f81f0306abfe 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <libsigrok/libsigrok.h>
 #include <libsigrokdecode/libsigrokdecode.h>
 
 #include "decoder.h"
 
 #include <pv/view/logicsignal.h>
 
-using namespace boost;
-using namespace std;
+using boost::shared_ptr;
+using std::map;
+using std::string;
 
 namespace pv {
 namespace data {
 namespace decode {
 
 Decoder::Decoder(const srd_decoder *const dec) :
-       _decoder(dec)
+       _decoder(dec),
+       _shown(true)
 {
 }
 
@@ -48,6 +51,16 @@ const srd_decoder* Decoder::decoder() const
        return _decoder;
 }
 
+bool Decoder::shown() const
+{
+       return _shown;
+}
+
+void Decoder::show(bool show)
+{
+       _shown = show;
+}
+
 const map<const srd_probe*, shared_ptr<view::LogicSignal> >&
 Decoder::probes() const
 {
@@ -72,6 +85,18 @@ void Decoder::set_option(const char *id, GVariant *value)
        _options[id] = value;
 }
 
+bool Decoder::have_required_probes() const
+{
+       for (GSList *p = _decoder->probes; p; p = p->next) {
+               const srd_probe *const probe = (const srd_probe*)p->data;
+               assert(probe);
+               if (_probes.find(probe) == _probes.end())
+                       return false;
+       }
+
+       return true;
+}
+
 srd_decoder_inst* Decoder::create_decoder_inst(
        srd_session *const session) const
 {