BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
f0c104c
Branches
Tags
master
Blinker
src
noarch
Printer.cpp
implemented specialized setting files for different data types, simplified input/output stream handling in modules
Stefan Schuermans
commited
f0c104c
at 2011-12-04 20:10:37
Printer.cpp
Blame
History
Raw
/* Blinker Copyright 2011 Stefan Schuermans <stefan@blinkenarea.org> Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html a blinkenarea.org project */ #include <iostream> #include <stdlib.h> #include <string> #include <string.h> #include <BlinkenLib/BlinkenFrame.h> #include "CallMgr.h" #include "Directory.h" #include "File.h" #include "InStreamFile.h" #include "Module.h" #include "Printer.h" #include "StreamMgr.h" #include "StreamRecv.h" namespace Blinker { /** * @brief constructor * @param[in] callMgr callback manager * @param[in] streamMgr stream manager * @param[in] dirBase base directory */ Printer::Printer(CallMgr &callMgr, StreamMgr &streamMgr, const Directory &dirBase): Module(callMgr, streamMgr, dirBase), m_fileInStream(dirBase.getFile("instream"), streamMgr) { // set up m_fileInStream.setStreamRecv(this); } /// virtual destructor Printer::~Printer() { // clean up m_fileInStream.setStreamRecv(NULL); } /// check for update of configuration void Printer::updateConfig() { // input stream name file was modified -> re-get input stream if (m_fileInStream.checkModified()) m_fileInStream.update(); } /** * @brief set current frame * @param[in] stream stream name * @param[in] pFrame current frame (NULL for none) */ void Printer::setFrame(const std::string &stream, stBlinkenFrame *pFrame) { if (pFrame) { char *str = BlinkenFrameToString(pFrame); for (int i = strlen(str) - 2; i >= 0 && str[i] != '\n'; --i) str[i] = 0; // remove last line (delay) std::cout << "frame" << std::endl << str; free(str); } else { std::cout << "no frame" << std::endl; } (void)stream; // unused } } // namespace Blinker