git-svn-id: http://moon:8086/svn/software/trunk/libsrc/cpp@879 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2022-05-28 13:20:36 +00:00
parent acc675cd35
commit 4d1ff8d1ae
7 changed files with 89 additions and 44 deletions
+59 -15
View File
@@ -1,25 +1,69 @@
MAKE_HOME := /home/jens/work/software/make
########################################################################
####################### Makefile Template ##############################
########################################################################
CONFIG ?= debug
TARGET ?= test01
BUILD_DIR := ./build/${CONFIG}
# Compiler settings - Can be customized.
CC = g++
CXXFLAGS = -std=c++11 -Wall
LDFLAGS =
include ./processor.mk
# Makefile settings - Can be customized.
APPNAME = myapp
EXT = .cpp
SRCDIR = src
OBJDIR = obj
CXX_SRCS += test/test01.cpp test/TestBlock.cpp
LIBS := -lstdc++ -lm -larmadillo
DEFINES += -DPROCESSOR_BUFFER_USE_EXCEPTIONS
############## Do not change anything from here downwards! #############
SRC = $(wildcard $(SRCDIR)/*$(EXT))
OBJ = $(SRC:$(SRCDIR)/%$(EXT)=$(OBJDIR)/%.o)
DEP = $(OBJ:$(OBJDIR)/%.o=%.d)
# UNIX-based OS variables & settings
RM = rm
DELOBJ = $(OBJ)
# Windows OS variables & settings
DEL = del
EXE = .exe
WDELOBJ = $(SRC:$(SRCDIR)/%$(EXT)=$(OBJDIR)\\%.o)
SRCS := ${CXX_SRCS} ${GCC_SRCS}
########################################################################
####################### Targets beginning here #########################
########################################################################
all: $(APPNAME)
# Builds the app
$(APPNAME): $(OBJ)
$(CC) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
# Creates the dependecy rules
%.d: $(SRCDIR)/%$(EXT)
@$(CPP) $(CFLAGS) $< -MM -MT $(@:%.d=$(OBJDIR)/%.o) >$@
# Includes all .h files
-include $(DEP)
# Building rule for .o files and its .c/.cpp in combination with all .h
$(OBJDIR)/%.o: $(SRCDIR)/%$(EXT)
$(CC) $(CXXFLAGS) -o $@ -c $<
################### Cleaning rules for Unix-based OS ###################
# Cleans complete project
.PHONY: clean
all: ${BUILD_DIR}/${TARGET}
clean:
rm -rf ${BUILD_DIR}/*
$(RM) $(DELOBJ) $(DEP) $(APPNAME)
distclean:
rm -rf ${BUILD_DIR}
# Cleans only all files with the extension .d
.PHONY: cleandep
cleandep:
$(RM) $(DEP)
#################### Cleaning rules for Windows OS #####################
# Cleans complete project
.PHONY: cleanw
cleanw:
$(DEL) $(WDELOBJ) $(DEP) $(APPNAME)$(EXE)
include $(MAKE_HOME)/compile.mk
# Cleans only all files with the extension .d
.PHONY: cleandepw
cleandepw:
$(DEL) $(DEP)
+1 -1
View File
@@ -1,6 +1,6 @@
PACKAGES += Processor-1.0
CXX_SRCS += src/ABlock.cpp
CXX_SRCS += src/Block.cpp src/Processor.cpp
DEFINES +=
INCLUDES += -I $(shell pwd)/src
+6 -2
View File
@@ -12,8 +12,13 @@
#define RETURN_OR_EXCEPT(code) return code
#endif
class IBuffer
{
};
template <typename T>
class Buffer
class Buffer : public IBuffer
{
public:
enum Result
@@ -90,5 +95,4 @@ class Buffer
#include "Buffer.tcc"
#endif // __PROCESSOR_BUFFER_HPP__
+2
View File
@@ -1,4 +1,6 @@
#include <cstdio>
#include <memory>
#include <cstring>
template<typename T>
Buffer<T>::Buffer(size_t capacity)
+6 -16
View File
@@ -1,22 +1,12 @@
#include "TestBlock.hpp"
template<typename T>
TestBlock<T>::TestBlock()
void TestBlock::process(IBuffer &in, IBuffer &out)
{
auto buf_in = reinterpret_cast<Buffer<DTIN>&>(in);
auto buf_out = reinterpret_cast<Buffer<DTOUT>&>(out);
}
template<typename T>
TestBlock<T>::~TestBlock()
{
}
template<typename T>
void TestBlock<T>::process(Buffer<T> &in, Buffer<T> &out)
{
size_t toCopy = in.len();
out.write(in.data_r(), toCopy);
in.consume(toCopy);
size_t toCopy = buf_in.len();
buf_out.write(buf_in.data_r(), toCopy);
buf_in.consume(toCopy);
}
+14 -7
View File
@@ -3,19 +3,26 @@
#pragma once
#include <ABlock.hpp>
#include <Block.hpp>
template <typename T>
class TestBlock : public ABlock<T>
using DTIN = double;
using DTOUT = double;
class TestBlock : public Block
{
public:
TestBlock();
~TestBlock();
TestBlock(size_t bufSize)
: Block(1, 1, DType::Double, DType::Double)
, m_buf_in(bufSize)
{
void process(Buffer<T> &in, Buffer<T> &out);
}
virtual ~TestBlock() = default;
void process(IBuffer &in, IBuffer &out) override;
private:
Buffer<DTIN> m_buf_in;
};
#endif
+1 -3
View File
@@ -8,10 +8,8 @@
#define LENGTH(a) (sizeof(a)/sizeof(a[0]))
#endif
int main()
int test01()
{
printf("Hallo Welt!\n");
arma::mat myMat;
// myMat.as_col();