2 * This file is part of the PulseView project.
4 * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <libsigrokdecode/libsigrokdecode.h>
25 #include <pv/view/logicsignal.h>
27 using namespace boost;
34 Decoder::Decoder(const srd_decoder *const dec) :
36 _options(g_hash_table_new_full(g_str_hash,
37 g_str_equal, g_free, (GDestroyNotify)g_variant_unref))
43 g_hash_table_destroy(_options);
46 const srd_decoder* Decoder::decoder() const
51 const map<const srd_probe*, shared_ptr<view::LogicSignal> >&
52 Decoder::probes() const
57 void Decoder::set_probes(std::map<const srd_probe*,
58 boost::shared_ptr<view::LogicSignal> > probes)
63 const GHashTable* Decoder::options() const
68 void Decoder::set_option(const char *id, GVariant *value)
71 g_hash_table_replace(_options, (void*)g_strdup(id), value);
74 srd_decoder_inst* Decoder::create_decoder_inst(
75 srd_session *const session) const
77 // Create the decoder instance
78 srd_decoder_inst *const decoder_inst = srd_inst_new(
79 session, _decoder->id, _options);
84 GHashTable *const probes = g_hash_table_new_full(g_str_hash,
85 g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
87 for(map<const srd_probe*, shared_ptr<view::LogicSignal> >::
88 const_iterator i = _probes.begin();
89 i != _probes.end(); i++)
91 shared_ptr<view::LogicSignal> signal((*i).second);
92 GVariant *const gvar = g_variant_new_int32(
93 signal->probe()->index);
94 g_variant_ref_sink(gvar);
95 g_hash_table_insert(probes, (*i).first->id, gvar);
98 srd_inst_probe_set_all(decoder_inst, probes);