BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
f87ca98
Branches
Tags
master
Blinker
src
noarch
Printer.cpp
merged frame processing with no frame processing
Stefan Schuermans
commited
f87ca98
at 2011-12-04 12:58:57
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 "Module.h" #include "Printer.h" #include "SettingFile.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")), m_pInStream(NULL) { // get input stream and attach to it getInStream(); } /// virtual destructor Printer::~Printer() { // detach from input stream and release it releaseInStream(); } /// check for update of configuration void Printer::updateConfig() { // input stream name file was modified -> re-get input stream if (m_fileInStream.checkModified()) { releaseInStream(); getInStream(); } } /** * @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 } /// get input stream and attach to it void Printer::getInStream() { // get input stream m_fileInStream.getStr(m_nameInStream); m_pInStream = &m_streamMgr.refStream(m_nameInStream); // attach to input stream if (m_pInStream) m_pInStream->attach(this); } /// detach from input stream and release it void Printer::releaseInStream() { // detach from input stream if (m_pInStream) m_pInStream->detach(this); // unreference stream m_pInStream = NULL; m_streamMgr.unrefStream(m_nameInStream); } } // namespace Blinker