/* * * * ****************************************************************************** * * Copyright (C) 2014-2020 Dennis Sheirer * * * * 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 3 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, see * * ***************************************************************************** * * */ package io.github.dsheirer.module.decode; import io.github.dsheirer.sample.Listener; import io.github.dsheirer.source.ISourceEventProvider; import io.github.dsheirer.source.SourceEvent; /** * Decoder that provides feedback to signal source(s) via SourceEvent broadcasts and supports registering source * event listeners. */ public abstract class FeedbackDecoder extends Decoder implements ISourceEventProvider { private Listener mSourceEventListener; /** * Registers the listener to receive source events from this decoder */ @Override public void setSourceEventListener(Listener listener) { mSourceEventListener = listener; } /** * Deregisters the listener from receiving source events from this decoder. */ @Override public void removeSourceEventListener() { mSourceEventListener = null; } /** * Broadcasts the specified source event to the optional registered source event listener */ public void broadcast(SourceEvent sourceEvent) { if(mSourceEventListener != null) { mSourceEventListener.receive(sourceEvent); } } }