BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
fd00bff
Branches
Tags
master
Blinker
src
noarch
StreamMgr.cpp
added stream name to stream receiver interface callbacks
Stefan Schuermans
commited
fd00bff
at 2011-11-16 18:35:11
StreamMgr.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 <map> #include <set> #include <string> #include "Stream.h" #include "StreamMgr.h" namespace Blinker { /// constructor StreamMgr::StreamMgr() { } /// destructor StreamMgr::~StreamMgr() { } /** * @brief reference stream * @param[in] name stream name * @return stream * * if the stream does not exists, it is created */ Stream & StreamMgr::refStream(const std::string &name) { Entry &entry = m_streams[name]; entry.m_stream.m_name = name; entry.m_refCnt++; return entry.m_stream; } /** * @brief unreference stream * @param[in] name stream name * * if the last reference is removed, the stream is deleted */ void StreamMgr::unrefStream(const std::string &name) { StreamMap::iterator itStream = m_streams.find(name); if (itStream != m_streams.end()) { if (itStream->second.m_refCnt > 0) itStream->second.m_refCnt--; if (itStream->second.m_refCnt == 0) m_streams.erase(itStream); } } /* #################### # StreamMgr::Entry # #################### */ /// constructor StreamMgr::Entry::Entry(): m_refCnt(0) { } } // namespace Blinker