BlinkenArea - GitList
Repositories
Blog
Wiki
Blinker
Code
Commits
Branches
Tags
Search
Tree:
f670ca0
Branches
Tags
master
Blinker
src
common
StreamMgr.cpp
rename noarch (misnormer) to common
Stefan Schuermans
commited
f670ca0
at 2014-01-03 12:06:24
StreamMgr.cpp
Blame
History
Raw
/* Blinker Copyright 2011-2014 Stefan Schuermans <stefan@blinkenarea.org> Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html a blinkenarea.org project */ #include <map> #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