diff --git a/Makefile b/Makefile index fea9236..e097081 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,8 @@ GPP_SRCS := Main.cpp Rbm.cpp Layer.cpp Stack.cpp MainComponent.cpp GPP_OBJS := $(addprefix ${BUILD_DIR}/, $(subst .cpp,.o,$(GPP_SRCS))) GCC_SRCS := noise.c GCC_OBJS := $(addprefix ${BUILD_DIR}/, $(subst .c,.o,$(GCC_SRCS))) + +TEST_SRCS := source/main.cpp source/Rbm.cpp source/Layer.cpp source/Stack.cpp source/noise.c CXXFLAGS += -std=c++11 -L juce/build/${CONFIG} CXXFLAGS_debug := ${CXXFLAGS} -O0 -g @@ -24,7 +26,8 @@ LIBS := -lstdc++ -lm -larmadillo -ljsoncpp -ljuce -lfreetype -lpthread -ldl -lrt DEFINES := -DARMA_OPENMP_THREADS=1 all: ${BUILD_DIR}/rbm.elf - +test: ${BUILD_DIR}/test.elf + ${GPP_OBJS}: $(BUILD_DIR)/%.o : source/%.cpp mkdir -p $(dir $@) g++ ${CXXFLAGS_${CONFIG}} ${DEFINES} ${INCLUDES} -o $@ -c $< @@ -36,6 +39,10 @@ ${GCC_OBJS}: $(BUILD_DIR)/%.o : source/%.c ${BUILD_DIR}/rbm.elf: ${GPP_OBJS} ${GCC_OBJS} juce/build/${CONFIG}/libjuce.a gcc ${LFLAGS_${CONFIG}} ${GPP_OBJS} ${GCC_OBJS} ${LIBS} -o $@ +${BUILD_DIR}/test.elf: ${TEST_SRCS} + mkdir -p $(dir $@) + g++ ${CXXFLAGS_${CONFIG}} ${DEFINES} -o $@ ${TEST_SRCS} -larmadillo -ljsoncpp + juce/build/${CONFIG}/libjuce.a: make -C juce clean: diff --git a/source/Stack.cpp b/source/Stack.cpp index 3c17829..b8423f8 100644 --- a/source/Stack.cpp +++ b/source/Stack.cpp @@ -28,7 +28,18 @@ Stack::Stack(const Stack& orig) } Stack::~Stack() +{ } + +size_t Stack::numLayers() { + size_t count = 0; + Layer *pLayer = m_pLayers; + while(pLayer) + { + count++; + pLayer = pLayer->upper; + } + return count; } void Stack::addLayer(Layer *pOtherLayer) diff --git a/source/Stack.hpp b/source/Stack.hpp index c7264cb..3d32ffd 100644 --- a/source/Stack.hpp +++ b/source/Stack.hpp @@ -42,6 +42,9 @@ public: { std::cout << "Stack::batchchanged() called" << std::endl; } + + size_t numLayers(); + private: const std::string &m_prjname; Layer *m_pLayers;