/* Blinker
Copyright 2011-2019 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 "OpConn.h"
#include "OpConnIf.h"
#include "OpMgr.h"
#include "OpReqIf.h"
namespace Blinker {
/// constructor
OpMgr::OpMgr()
{
}
/// destructor
OpMgr::~OpMgr()
{
}
/**
* @brief open operator interface
* @param[in] name operator interface name
* @param[in] pOpReqIf interface to call on incoming operator request
* @return if operator interface could be opened
*/
bool OpMgr::open(const std::string &name, OpReqIf *pOpReqIf)
{
if (m_reqIfs.find(name) != m_reqIfs.end())
return false; // already open
m_reqIfs[name] = pOpReqIf;
return true;
}
/**
* @brief close operator interface
* @param[in] name operator interface name
* @return if interface name was open before
*/
bool OpMgr::close(const std::string &name)
{
ReqIfMap::iterator itReqIf = m_reqIfs.find(name);
if (itReqIf == m_reqIfs.end())
return false; // was not open
m_reqIfs.erase(itReqIf);
return true;