BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
fd00bff
Branches
Tags
master
Blinker
src
noarch
Printer.cpp
added stream name to stream receiver interface callbacks
Stefan Schuermans
commited
fd00bff
at 2011-11-16 18:35:11
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 <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 */ void Printer::setFrame(const std::string &stream, stBlinkenFrame *pFrame) { char *str = BlinkenFrameToString(pFrame); std::cout << str; free(str); (void)stream; // unused } /** * @brief set current frame to none * @param[in] stream stream name */ void Printer::setNoFrame(const std::string &stream) { 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