17 #ifndef __SDR_NODE_HH__
18 #define __SDR_NODE_HH__
29 #include "exception.hh"
94 template <
typename T>
static inline Type typeId();
127 inline Config::Type Config::typeId< std::complex<uint8_t> >() {
return Type_cu8; }
130 inline Config::Type Config::typeId< std::complex<int8_t> >() {
return Type_cs8; }
133 inline Config::Type Config::typeId< std::complex<uint16_t> >() {
return Type_cu16; }
136 inline Config::Type Config::typeId< std::complex<int16_t> >() {
return Type_cs16; }
139 inline Config::Type Config::typeId< std::complex<float> >() {
return Type_cf32; }
142 inline Config::Type Config::typeId< std::complex<double> >() {
return Type_cf64; }
148 case Config::Type_UNDEFINED:
return "UNDEFINED";
166 inline std::ostream &operator<<(std::ostream &stream,
Config::Type type) {
167 stream << typeName(type) <<
" (" << (int)type <<
")";
191 template <
class Scalar>
222 virtual void send(
const RawBuffer &buffer,
bool allow_overwrite=
false);
240 void addEOS(T* instance,
void (T::*
function)()) {
257 std::list<DelegateInterface *>
_eos;
276 BlockingSource(
bool parallel=
false,
bool connect_idle=
true,
bool stop_queue_on_eos=
false);
283 virtual void next() = 0;
289 virtual void start();
309 static void *_pthread_main_wrapper(
void *);
332 #endif // __SDR_NODE_HH__
A collection of configuration information that is send by a source to all connected sinks to properga...
Definition: node.hh:35
Complex (aka I/Q) type of 32bit floats aka. std::complex.
Definition: node.hh:51
virtual void process(const Buffer< Scalar > &buffer, bool allow_overwrite)=0
Needs to be implemented by any sub-type to process the received data.
Base class of all buffers, represents an untyped array of bytes.
Definition: buffer.hh:32
virtual ~BlockingSource()
Destructor.
Definition: node.cc:149
Config _config
Holds the source configuration, this can be updated by calling setConfig.
Definition: node.hh:253
double _sampleRate
Holds the sample rate of the source.
Definition: node.hh:100
Specific delegate to a method of an object .
Definition: queue.hh:27
void propagateConfig(const Config &config)
Propagates the given configuration to all connected sinks.
Definition: node.cc:108
Config()
Empty constructor, will result into an invalid configuration.
Definition: node.cc:9
Source()
Constructor.
Definition: node.cc:56
const Config & operator=(const Config &other)
Assignment operator.
Definition: node.cc:29
Real signed 16b ints.
Definition: node.hh:44
virtual void send(const RawBuffer &buffer, bool allow_overwrite=false)
Sends the given buffer to all connected sinks.
Definition: node.cc:67
std::list< DelegateInterface * > _eos
The connected EOS singal handlers.
Definition: node.hh:257
Iterface of a blocking source.
Definition: node.hh:267
Typed sink.
Definition: node.hh:192
Complex (aka I/Q) type of unsigned 16b ints.
Definition: node.hh:49
bool _is_parallel
If true, the surce is processed in parallel.
Definition: node.hh:303
Definition: autocast.hh:8
size_t numBuffers() const
Returns the max.
Definition: node.hh:89
Type _type
Holds the type of the source.
Definition: node.hh:98
Real signed 8b ints.
Definition: node.hh:42
bool hasSampleRate() const
If true, the configuration has a sample rate.
Definition: node.hh:75
Generic source class.
Definition: node.hh:213
Real unsigned 8b ints.
Definition: node.hh:41
void _parallel_main()
The parallel main loop.
Definition: node.cc:172
void signalEOS()
Signals the EOS.
Definition: node.cc:127
virtual ~Proxy()
Destructor.
Definition: node.cc:203
bool hasType() const
If true, the configuration has a type.
Definition: node.hh:69
std::map< SinkBase *, bool > _sinks
The connected sinks.
Definition: node.hh:255
Real 64b floats aka. "double".
Definition: node.hh:46
virtual double sampleRate() const
Returns the configured sample rate or 0 otherwise.
Definition: node.cc:122
virtual ~Sink()
Drestructor.
Definition: node.hh:198
bool isActive() const
Returns true if the source is active.
Definition: node.hh:286
Real unsigned 16b ints.
Definition: node.hh:43
virtual void setConfig(const Config &config)
Stores the configuration and propergates it if the configuration has been changed.
Definition: node.cc:98
bool _is_active
If true, the source is active.
Definition: node.hh:301
virtual void config(const Config &src_cfg)
Configures the node.
Definition: node.cc:208
virtual void next()=0
This method gets called either by the Queue on idle events or by a thread to read more data from the ...
virtual void config(const Config &src_cfg)=0
Needs to be implemented by any sub-type to check and perform the configuration of the node...
void connect(SinkBase *sink, bool direct=false)
Connect this source to a sink.
Definition: node.cc:87
virtual void handleBuffer(const RawBuffer &buffer, bool allow_overwrite)=0
Needs to be implemented by any sub-type to process the received data.
void setNumBuffers(size_t N)
Sets the max.
Definition: node.hh:91
size_t _bufferSize
Holds the max.
Definition: node.hh:102
Type type() const
Returns the type.
Definition: node.hh:71
Proxy()
Constructor.
Definition: node.cc:197
virtual void start()
This function starts the input stream.
Definition: node.cc:154
pthread_t _thread
The thread of the source.
Definition: node.hh:305
void setType(Type type)
Sets the type.
Definition: node.hh:73
Sink()
Constructor.
Definition: node.hh:196
static Type typeId()
Returns the type-id of the template type.
SinkBase()
Constructor.
Definition: node.cc:45
Real 32b floats aka. "float".
Definition: node.hh:45
bool hasNumBuffers() const
If true, the configuration has a number of buffers.
Definition: node.hh:87
size_t bufferSize() const
Returns the max.
Definition: node.hh:83
virtual void stop()
This function stops the input stream.
Definition: node.cc:162
Type
The type IDs.
Definition: node.hh:39
Basic interface of all Sinks.
Definition: node.hh:174
virtual ~Source()
Destructor.
Definition: node.cc:62
void setSampleRate(double rate)
Sets the sample rate.
Definition: node.hh:79
Complex (aka I/Q) type of signed 8b ints.
Definition: node.hh:48
virtual void handleBuffer(const RawBuffer &buffer, bool allow_overwrite)
Forwards the buffer.
Definition: node.cc:213
bool operator==(const Config &other) const
Coparison operator.
Definition: node.cc:36
Complex (aka I/Q) type of signed 16b ints.
Definition: node.hh:50
Complex (aka I/Q) type of unsigned 8b ints.
Definition: node.hh:47
virtual Config::Type type() const
Returns the configured source type or Config::Type_UNDEFINED otherwise.
Definition: node.cc:117
A NOP node.
Definition: node.hh:315
BlockingSource(bool parallel=false, bool connect_idle=true, bool stop_queue_on_eos=false)
Constructor.
Definition: node.cc:137
void disconnect(SinkBase *sink)
Disconnect a sink again.
Definition: node.cc:93
void addEOS(T *instance, void(T::*function)())
Adds a callback to the end-of-stream signal of the source.
Definition: node.hh:240
void _nonvirt_idle_cb()
The non-virtual idle callback.
Definition: node.cc:179
virtual void handleBuffer(const RawBuffer &buffer, bool allow_overwrite)
Re-implemented from SinkBase.
Definition: node.hh:205
virtual ~SinkBase()
Destructor.
Definition: node.cc:49
void setBufferSize(size_t size)
Sets the max.
Definition: node.hh:85
bool hasBufferSize() const
If true, the configuration has a buffer size.
Definition: node.hh:81
Complex (aka I/Q) type of 64bit floats aka. std::complex.
Definition: node.hh:52
size_t _numBuffers
Holds the max.
Definition: node.hh:104
double sampleRate() const
Returns the sample rate.
Definition: node.hh:77