diff --git a/libheptaled/.clang b/libheptaled/.clang new file mode 100644 index 0000000..66b4cb2 --- /dev/null +++ b/libheptaled/.clang @@ -0,0 +1 @@ + --std=c++11 diff --git a/libheptaled/Makefile b/libheptaled/Makefile new file mode 100644 index 0000000..b11ed6c --- /dev/null +++ b/libheptaled/Makefile @@ -0,0 +1,27 @@ +OBJDIR = bin + +CXX = clang++ +CXXFLAGS = --std=c++11 +LDFLAGS = + + +$(OBJDIR)/display.o : common.h digit.h display.h display.cpp + +all : start $(OBJDIR)/display.o + @echo ":: Done !" + +start : + @echo " LibHeptaled" + @echo "=============" + @echo ":: Building using $(CXX)" + +$(OBJDIR)/%.o : %.cpp Makefile + mkdir -p $$(dirname $@) + $(CXX) $(CXXFLAGS) -c $< -o $@ + +$(OBJDIR)/$(TARGET) : $(OBJDIR)/$(TARGET).o + $(CXX) $+ $(LDFLAGS) -o $@ + +clean : + @rm -rf $(OBJDIR) + diff --git a/libheptaled/common.h b/libheptaled/common.h new file mode 100644 index 0000000..56718ae --- /dev/null +++ b/libheptaled/common.h @@ -0,0 +1,12 @@ +#ifndef COMMON_H +#define COMMON_H COMMON_H + +#include + +namespace HeptaLed { + + typedef std::vector ByteBuffer; +} + +#endif + diff --git a/libheptaled/digit.h b/libheptaled/digit.h new file mode 100644 index 0000000..bb97c96 --- /dev/null +++ b/libheptaled/digit.h @@ -0,0 +1,19 @@ +#ifndef DIGIT_H +#define DIGIT_H DIGIT_H + +#include + +#include "common.h" + +namespace HeptaLed { + + + class Digit { + public: + virtual void render(std::string::const_iterator stringIt, ByteBuffer::iterator const& bufferIt) = 0; + + }; +} + + +#endif diff --git a/libheptaled/display.cpp b/libheptaled/display.cpp new file mode 100644 index 0000000..f571a99 --- /dev/null +++ b/libheptaled/display.cpp @@ -0,0 +1,26 @@ +#include "display.h" + +namespace HeptaLed { + + Display& Display::add(std::shared_ptr digit) { + digits.push_back(digit); + return *this; + } + + + ByteBuffer Display::render(std::string const& s) { + ByteBuffer buffer(digits.size()); + + std::string::const_iterator stringIt = s.begin(); + ByteBuffer::iterator byteIt = buffer.begin(); + + for(DigitVector::iterator it = digits.begin(); it != digits.end(); ++it) { + (*it)->render(stringIt,byteIt); + ++byteIt; + } + + return buffer; + } + + +} diff --git a/libheptaled/display.h b/libheptaled/display.h new file mode 100644 index 0000000..39c131a --- /dev/null +++ b/libheptaled/display.h @@ -0,0 +1,28 @@ +#ifndef DISPLAY_H +#define DISPLAY_H DISPLAY_H + +#include +#include +#include +#include + +#include "common.h" +#include "digit.h" + +namespace HeptaLed { + + typedef std::vector> DigitVector; + + class Display { + + public: + Display& add(std::shared_ptr digit); + ByteBuffer render(std::string const& s); + + private: + DigitVector digits; + }; +} + + +#endif