mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-11 08:07:24 -05:00
66 lines
2.1 KiB
Java
66 lines
2.1 KiB
Java
/*
|
|
*
|
|
* * ******************************************************************************
|
|
* * 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 <http://www.gnu.org/licenses/>
|
|
* * *****************************************************************************
|
|
*
|
|
*
|
|
*/
|
|
|
|
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<SourceEvent> mSourceEventListener;
|
|
|
|
/**
|
|
* Registers the listener to receive source events from this decoder
|
|
*/
|
|
@Override
|
|
public void setSourceEventListener(Listener<SourceEvent> 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);
|
|
}
|
|
}
|
|
}
|