BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
3d07564
Branches
Tags
master
Blinker
src
noarch
Priority.cpp
created template class for tracking lists in directories, converted priority module to use this class
Stefan Schuermans
commited
3d07564
at 2011-12-10 22:52:36
Priority.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 <list> #include <string> #include <BlinkenLib/BlinkenFrame.h> #include "CallMgr.h" #include "Directory.h" #include "File.h" #include "ListTracker.h" #include "ListTracker_impl.h" #include "Module.h" #include "Priority.h" #include "PriorityInput.h" #include "OutStreamFile.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 */ Priority::Priority(CallMgr &callMgr, StreamMgr &streamMgr, const Directory &dirBase): Module(callMgr, streamMgr, dirBase), m_fileOutStream(dirBase.getFile("outstream"), streamMgr), m_inListTracker(*this, dirBase.getSubdir("inputs")), m_itCurIn(m_inListTracker.m_list.rend()) { } /// virtual destructor Priority::~Priority() { } /// check for update of configuration void Priority::updateConfig() { // input list update m_inListTracker.updateConfig(); // output stream name file was modified -> re-get output stream if (m_fileOutStream.checkModified()) m_fileOutStream.update(); } /** * @brief select specific input (called by inputs) * @param[in] input input to select */ void Priority::select(const Input *pInput) { // search inputs for passed input m_itCurIn = m_inListTracker.m_list.rbegin(); while (m_itCurIn != m_inListTracker.m_list.rend() && m_itCurIn->m_pObj != pInput) ++m_itCurIn; // send current frame curFrame(); } /// select lower priority input (called by inputs) void Priority::selectLower() { stBlinkenFrame *pFrame; // search inputs with lower priority until a frame is found while (m_itCurIn != m_inListTracker.m_list.rend()) { // check for frame if ((pFrame = m_itCurIn->m_pObj->getCurFrame())) { // frame found -> keep this input as current, send frame m_fileOutStream.setFrame(pFrame); return; } // try next input ++m_itCurIn; } // no input has got a frame -> send no frame m_fileOutStream.setFrame(NULL); } /// send current frame to output stream void Priority::curFrame() { stBlinkenFrame *pFrame; // current input available and frame it it available -> send frame if (m_itCurIn != m_inListTracker.m_list.rend() && (pFrame = m_itCurIn->m_pObj->getCurFrame())) m_fileOutStream.setFrame(pFrame); // no frame available -> send this information else m_fileOutStream.setFrame(NULL); } } // namespace Blinker