* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <libsigrokdecode/libsigrokdecode.h>
+
#include "decoder.h"
#include <pv/view/signal.h>
+using namespace boost;
+using namespace std;
+
namespace pv {
namespace data {
std::map<const srd_probe*,
boost::shared_ptr<pv::view::Signal> > probes) :
_decoder(dec),
- _probes(probes)
+ _probes(probes),
+ _decoder_inst(NULL)
{
+ init_decoder();
}
const srd_decoder* Decoder::get_decoder() const
return _decoder;
}
+void Decoder::init_decoder()
+{
+ _decoder_inst = srd_inst_new(_decoder->id, NULL);
+ assert(_decoder_inst);
+
+ GHashTable *probes = g_hash_table_new_full(g_str_hash,
+ g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
+
+ for(map<const srd_probe*, shared_ptr<view::Signal> >::
+ const_iterator i = _probes.begin();
+ i != _probes.end(); i++)
+ {
+ shared_ptr<view::Signal> signal((*i).second);
+ GVariant *const gvar = g_variant_new_int32(
+ signal->probe()->index);
+ g_variant_ref_sink(gvar);
+ g_hash_table_insert(probes, (*i).first->id, gvar);
+ }
+
+ srd_inst_probe_set_all(_decoder_inst, probes);
+}
+
void Decoder::clear_snapshots()
{
}
#include <boost/shared_ptr.hpp>
struct srd_decoder;
+struct srd_decoder_inst;
struct srd_probe;
namespace pv {
class Decoder : public SignalData
{
public:
- Decoder(const srd_decoder *const dec, std::map<const srd_probe*,
- boost::shared_ptr<pv::view::Signal> > probes);
+ Decoder(const srd_decoder *const decoder,
+ std::map<const srd_probe*,
+ boost::shared_ptr<pv::view::Signal> > probes);
const srd_decoder* get_decoder() const;
void clear_snapshots();
+private:
+ void init_decoder();
+
private:
const srd_decoder *const _decoder;
std::map<const srd_probe*, boost::shared_ptr<view::Signal> >
_probes;
+
+ srd_decoder_inst *_decoder_inst;
};
} // namespace data