1 #ifndef __SDR_COMBINE_HH__
2 #define __SDR_COMBINE_HH__
16 template <
class Scalar>
36 if (Config::typeId<Scalar>() != src_cfg.
type()) {
38 err <<
"Can not configure CombinSink: Invalid source type " << src_cfg.
type()
39 <<
", expected " << Config::typeId<Scalar>();
65 template <
class Scalar>
72 for (
size_t i=0; i<N; i++) {
81 for (
size_t i=0; i<
_sinks.size(); i++) {
105 err <<
"Can not configure Combine node: Invalid type of sink #" << idx
113 err <<
"Can ont configure Combine node: Invalid sample rate of sink #" << idx
124 for (
size_t i=0; i<
_sinks.size(); i++) {
134 size_t N = std::numeric_limits<size_t>::max();
135 for (
size_t i=0; i<
_sinks.size(); i++) {
136 N = std::min(N,
_buffers[i].stored());
145 std::vector< CombineSink<Scalar> *>
_sinks;
155 template <
class Scalar>
170 err <<
"Interleave: Sink index " << i <<
" out of range [0," <<
_N <<
")";
181 if (Config::typeId<Scalar>() != cfg.
type()) {
183 err <<
"Can not configure Interleave node: Invalid source type " << cfg.
type()
184 <<
", expected " << Config::typeId<Scalar>();
195 if (0 == N) {
return; }
199 msg <<
"Interleave: Output buffer in use: Drop " <<
_N <<
"x" << N
203 for (
size_t i=0; i<buffers.size(); i++) { buffers[i].drop(N); }
209 for (
size_t i=0; i<num; i++) {
210 for (
size_t j=0; j<
_N; j++, idx++) {
215 for (
size_t i=0; i<
_N; i++) {
216 buffers[i].drop(num);
230 #endif // __SDR_COMBINE_HH__
A collection of configuration information that is send by a source to all connected sinks to properga...
Definition: node.hh:35
virtual void config(const Config &cfg)
Configures the interleave node.
Definition: combine.hh:177
Interleaves several input streams.
Definition: combine.hh:156
size_t _index
The index of the sink within the combine node.
Definition: combine.hh:55
void notifyData(size_t idx)
Determines the minimum amount of data that is available on all ring buffers.
Definition: combine.hh:132
A simple typed ring-buffer.
Definition: buffer.hh:473
virtual void send(const RawBuffer &buffer, bool allow_overwrite=false)
Sends the given buffer to all connected sinks.
Definition: node.cc:67
Buffer< Scalar > _buffer
The putput buffer.
Definition: combine.hh:226
Typed sink.
Definition: node.hh:192
virtual void process(const Buffer< Scalar > &buffer, bool allow_overwrite)
Handles the given buffer.
Definition: combine.hh:47
Definition: autocast.hh:8
virtual void config(const Config &cfg)=0
Needs to be overridden.
bool hasSampleRate() const
If true, the configuration has a sample rate.
Definition: node.hh:75
Generic source class.
Definition: node.hh:213
RingBuffer< Scalar > & _buffer
The input ring-buffer.
Definition: combine.hh:59
The runtime error class.
Definition: exception.hh:36
size_t _N
The number of sinks.
Definition: combine.hh:224
size_t size() const
Returns the number of elements of type T in this buffer.
Definition: buffer.hh:166
bool hasType() const
If true, the configuration has a type.
Definition: node.hh:69
virtual void process(std::vector< RingBuffer< Scalar > > &buffers, size_t N)=0
Needs to be overridden.
A combine node.
Definition: combine.hh:13
virtual void setConfig(const Config &config)
Stores the configuration and propergates it if the configuration has been changed.
Definition: node.cc:98
Buffer< T > head(size_t n) const
Returns a new view on this buffer.
Definition: buffer.hh:237
void log(const LogMessage &message)
Logs a message.
Definition: logger.cc:100
std::vector< RingBuffer< Scalar > > _buffers
The ring buffers of all combine sinks.
Definition: combine.hh:143
Type type() const
Returns the type.
Definition: node.hh:71
void setType(Type type)
Sets the type.
Definition: node.hh:73
std::vector< CombineSink< Scalar > * > _sinks
The combine sinks.
Definition: combine.hh:145
virtual void config(const Config &src_cfg)
Configures the sink.
Definition: combine.hh:32
static Logger & get()
Returns the singleton instance of the logger.
Definition: logger.cc:89
Combine< Scalar > * _parent
A reference to the combine node.
Definition: combine.hh:57
The configuration error class.
Definition: exception.hh:24
virtual void process(std::vector< RingBuffer< Scalar > > &buffers, size_t N)
Processes the data from all sinks.
Definition: combine.hh:194
A log message.
Definition: logger.hh:22
size_t bufferSize() const
Returns the max.
Definition: node.hh:83
Combine(size_t N)
Constructor, N specifies the number of sinks.
Definition: combine.hh:70
Interleave(size_t N)
Constructor.
Definition: combine.hh:160
virtual ~CombineSink()
Destructor.
Definition: combine.hh:27
void setSampleRate(double rate)
Sets the sample rate.
Definition: node.hh:79
Sink< Scalar > * sink(size_t i)
Retunrs the i-th sink.
Definition: combine.hh:167
Config _config
The output configuration.
Definition: combine.hh:147
bool isUnused() const
We assume here that buffers are owned by one object: A buffer is therefore "unused" if the owner hold...
Definition: buffer.hh:87
void notifyConfig(size_t idx, const Config &cfg)
Unifies the configuration of all sinks.
Definition: combine.hh:97
CombineSink(Combine< Scalar > *combine, size_t index, RingBuffer< Scalar > &buffer)
Constructor.
Definition: combine.hh:21
A single sink of a Combine node.
Definition: combine.hh:17
virtual ~Combine()
Destructor.
Definition: combine.hh:79
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
double sampleRate() const
Returns the sample rate.
Definition: node.hh:77