added
git-svn-id: http://moon:8086/svn/software/trunk/libsrc/cpp@880 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
#include "NullSink.hpp"
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef NULLSINK_HPP
|
||||
#define NULLSINK_HPP
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Block.hpp>
|
||||
|
||||
class NullSink : public Block
|
||||
{
|
||||
public:
|
||||
NullSink(DType dt_in)
|
||||
: Block(1, 0, dt_in, DType::None)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual ~NullSink() = default;
|
||||
|
||||
void process(IBuffer &in) override
|
||||
{
|
||||
if (dtype_in() == DType::Double)
|
||||
{
|
||||
auto buf = reinterpret_cast<Buffer<double>&>(in);
|
||||
process_double(buf);
|
||||
}
|
||||
}
|
||||
|
||||
void process_double(Buffer<double> &buf)
|
||||
{
|
||||
buf.consume(buf.len());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
#include "NullSource.hpp"
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef NULLSOURCE_HPP
|
||||
#define NULLSOURCE_HPP
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Block.hpp>
|
||||
|
||||
class NullSource : public Block
|
||||
{
|
||||
public:
|
||||
NullSource(DType dtype)
|
||||
: Block(0, 1, DType::None, dtype)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual ~NullSource() = default;
|
||||
|
||||
void process(IBuffer &out) override
|
||||
{
|
||||
if (dtype_out() == DType::Double)
|
||||
{
|
||||
auto buf_out = reinterpret_cast<Buffer<double>&>(out);
|
||||
process_double(buf_out);
|
||||
}
|
||||
}
|
||||
|
||||
void process_double(Buffer<double> &out)
|
||||
{
|
||||
double d = 0;
|
||||
for (int i=0; i < (out.capacity() - out.len()); i++)
|
||||
{
|
||||
out.write(&d, 1);
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // NULLSOURCE_HPP
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <cstdio>
|
||||
#include <armadillo>
|
||||
|
||||
int test01();
|
||||
int test02();
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hallooooooooooooooooooo Welt!\n");
|
||||
int result = test01();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <cstdio>
|
||||
#include <armadillo>
|
||||
|
||||
#include "Processor.hpp"
|
||||
#include "NullSource.hpp"
|
||||
#include "NullSink.hpp"
|
||||
#include "TestBlock.hpp"
|
||||
|
||||
|
||||
#ifndef LENGTH
|
||||
#define LENGTH(a) (sizeof(a)/sizeof(a[0]))
|
||||
#endif
|
||||
|
||||
int test02()
|
||||
{
|
||||
Processor processor;
|
||||
NullSource nullSrc(Block::DType::Double);
|
||||
NullSink nullSink(Block::DType::Double);
|
||||
TestBlock testblock(1024);
|
||||
|
||||
nullSrc.addBuffer(testblock.buffer());
|
||||
testblock.addBuffer(nullSink.buffer());
|
||||
|
||||
processor.blockAdd(nullSrc);
|
||||
processor.blockAdd(testblock);
|
||||
processor.blockAdd(nullSink);
|
||||
|
||||
processor.run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user