BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
f87ca98
Branches
Tags
master
Blinker
src
noarch
Stream.cpp
merged frame processing with no frame processing
Stefan Schuermans
commited
f87ca98
at 2011-12-04 12:58:57
Stream.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 <set> #include <BlinkenLib/BlinkenFrame.h> #include "Stream.h" #include "StreamRecv.h" namespace Blinker { /// constructor Stream::Stream(): m_pFrame(NULL) { } /// virtual destructor Stream::~Stream() { // free current frame if (m_pFrame) BlinkenFrameFree(m_pFrame); } /** * @brief attach a stream receiver * @param[in] recv stream receiver to attach */ void Stream::attach(StreamRecv *recv) { m_recvs.insert(recv); // send current frame to receiver recv->setFrame(m_name, m_pFrame); } /** * @brief detach a stream receiver * @param[in] recv stream receiver to detach */ void Stream::detach(StreamRecv *recv) { m_recvs.erase(recv); } /** * @brief set current frame * @param[in] pFrame current frame (NULL for none) */ void Stream::setFrame(stBlinkenFrame *pFrame) { // leave if frame is already set to an identical one if (pFrame && m_pFrame && !BlinkenFrameCompare(pFrame, m_pFrame)) return; if (!pFrame && !m_pFrame) return; // update local copy of current frame if (m_pFrame) { BlinkenFrameFree(m_pFrame); m_pFrame = NULL; } if (pFrame) { m_pFrame = BlinkenFrameClone(pFrame); // in case of NULL returned: out of memory - got on without frame } // pass frame to all receivers Recvs::iterator it; for (it = m_recvs.begin(); it != m_recvs.end(); ++it) (*it)->setFrame(m_name, m_pFrame); } /** * @brief get current frame * @param[out] pFrame current frame (NULL for none) */ void Stream::getCurFrame(stBlinkenFrame *&pFrame) { pFrame = m_pFrame; } } // namespace Blinker