git-svn-id: http://moon:8086/svn/software/trunk/libsrc/cpp@880 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2022-05-28 13:21:43 +00:00
parent 4d1ff8d1ae
commit b6d1b1f45b
10 changed files with 255 additions and 0 deletions
View File
+82
View File
@@ -0,0 +1,82 @@
#ifndef __RADIO_BLOCK_H__
#define __RADIO_BLOCK_H__
#include <forward_list>
#include "Buffer.hpp"
class Block
{
public:
enum DType
{
None,
Float,
Double
};
Block(size_t num_in, size_t num_out, DType dtype_in, DType dtype_out)
: m_num_in(num_in)
, m_num_out(num_out)
, m_dtype_in(dtype_in)
, m_dtype_out(dtype_out)
{
}
virtual ~Block() = default;
void process()
{
if (dtype_in() == 0 and dtype_out() > 0)
{
for (auto buf : m_buf_out)
{
process(*buf);
}
}
}
virtual void process(IBuffer &in, IBuffer &out) {};
virtual void process(IBuffer &in_or_out) {};
size_t num_in()
{
return m_num_in;
}
size_t num_out()
{
return m_num_out;
}
DType dtype_in()
{
return m_dtype_in;
}
DType dtype_out()
{
return m_dtype_out;
}
void addBuffer(IBuffer *out)
{
m_buf_out.push_front(out);
}
virtual IBuffer* buffer()
{
return nullptr;
}
private:
size_t m_num_in;
size_t m_num_out;
DType m_dtype_in;
DType m_dtype_out;
std::forward_list<IBuffer*>m_buf_out;
};
#endif // __RADIO_BLOCK_H__
+11
View File
@@ -0,0 +1,11 @@
#include "Processor.hpp"
Processor::Processor()
{
}
Processor::~Processor()
{
}
+37
View File
@@ -0,0 +1,37 @@
#ifndef __RADIO_PROCESSOR_HPP_
#define __RADIO_PROCESSOR_HPP_
#include <forward_list>
#include <Block.hpp>
#pragma once
class Processor
{
public:
Processor();
~Processor();
void blockAdd(Block &block)
{
m_blockList.push_front(&block);
}
void blockRem(Block &block)
{
m_blockList.remove(&block);
}
void run()
{
for (auto block : m_blockList)
{
block->process();
}
}
private:
std::forward_list<Block*>m_blockList;
};
#endif