Updated
git-svn-id: http://moon:8086/svn/software/trunk/libsrc/cpp@879 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+59
-15
@@ -1,25 +1,69 @@
|
|||||||
MAKE_HOME := /home/jens/work/software/make
|
########################################################################
|
||||||
|
####################### Makefile Template ##############################
|
||||||
|
########################################################################
|
||||||
|
|
||||||
CONFIG ?= debug
|
# Compiler settings - Can be customized.
|
||||||
TARGET ?= test01
|
CC = g++
|
||||||
BUILD_DIR := ./build/${CONFIG}
|
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
|
############## Do not change anything from here downwards! #############
|
||||||
LIBS := -lstdc++ -lm -larmadillo
|
SRC = $(wildcard $(SRCDIR)/*$(EXT))
|
||||||
DEFINES += -DPROCESSOR_BUFFER_USE_EXCEPTIONS
|
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
|
.PHONY: clean
|
||||||
all: ${BUILD_DIR}/${TARGET}
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf ${BUILD_DIR}/*
|
$(RM) $(DELOBJ) $(DEP) $(APPNAME)
|
||||||
|
|
||||||
distclean:
|
# Cleans only all files with the extension .d
|
||||||
rm -rf ${BUILD_DIR}
|
.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,6 +1,6 @@
|
|||||||
|
|
||||||
PACKAGES += Processor-1.0
|
PACKAGES += Processor-1.0
|
||||||
|
|
||||||
CXX_SRCS += src/ABlock.cpp
|
CXX_SRCS += src/Block.cpp src/Processor.cpp
|
||||||
DEFINES +=
|
DEFINES +=
|
||||||
INCLUDES += -I $(shell pwd)/src
|
INCLUDES += -I $(shell pwd)/src
|
||||||
|
|||||||
@@ -12,8 +12,13 @@
|
|||||||
#define RETURN_OR_EXCEPT(code) return code
|
#define RETURN_OR_EXCEPT(code) return code
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class IBuffer
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class Buffer
|
class Buffer : public IBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Result
|
enum Result
|
||||||
@@ -90,5 +95,4 @@ class Buffer
|
|||||||
|
|
||||||
#include "Buffer.tcc"
|
#include "Buffer.tcc"
|
||||||
|
|
||||||
|
|
||||||
#endif // __PROCESSOR_BUFFER_HPP__
|
#endif // __PROCESSOR_BUFFER_HPP__
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <memory>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Buffer<T>::Buffer(size_t capacity)
|
Buffer<T>::Buffer(size_t capacity)
|
||||||
|
|||||||
@@ -1,22 +1,12 @@
|
|||||||
#include "TestBlock.hpp"
|
#include "TestBlock.hpp"
|
||||||
|
|
||||||
template<typename T>
|
void TestBlock::process(IBuffer &in, IBuffer &out)
|
||||||
TestBlock<T>::TestBlock()
|
|
||||||
{
|
{
|
||||||
|
auto buf_in = reinterpret_cast<Buffer<DTIN>&>(in);
|
||||||
|
auto buf_out = reinterpret_cast<Buffer<DTOUT>&>(out);
|
||||||
|
|
||||||
}
|
size_t toCopy = buf_in.len();
|
||||||
|
buf_out.write(buf_in.data_r(), toCopy);
|
||||||
template<typename T>
|
buf_in.consume(toCopy);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,19 +3,26 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ABlock.hpp>
|
#include <Block.hpp>
|
||||||
|
|
||||||
template <typename T>
|
using DTIN = double;
|
||||||
class TestBlock : public ABlock<T>
|
using DTOUT = double;
|
||||||
|
|
||||||
|
class TestBlock : public Block
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestBlock();
|
TestBlock(size_t bufSize)
|
||||||
~TestBlock();
|
: 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:
|
private:
|
||||||
|
Buffer<DTIN> m_buf_in;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -8,10 +8,8 @@
|
|||||||
#define LENGTH(a) (sizeof(a)/sizeof(a[0]))
|
#define LENGTH(a) (sizeof(a)/sizeof(a[0]))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main()
|
int test01()
|
||||||
{
|
{
|
||||||
printf("Hallo Welt!\n");
|
|
||||||
|
|
||||||
arma::mat myMat;
|
arma::mat myMat;
|
||||||
// myMat.as_col();
|
// myMat.as_col();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user