/* Blinker
   Copyright 2011-2019 Stefan Schuermans <stefan@blinkenarea.org>
   Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
   a blinkenarea.org project */

#ifndef BLINKER_LOCKMGR_H
#define BLINKER_LOCKMGR_H

#include <map>

#include "Lock.h"

namespace Blinker {

/// lock manager, provides mutual exclusion among modules
class LockMgr
{
protected:
  /// map of available locks: name -> lock object
  typedef std::map<std::string, Lock> LockMap;

public:
  /// constructor
  LockMgr();

  /// destructor
  ~LockMgr();

private:
  /// copy constructor disabled
  LockMgr(const LockMgr &that);

  /// assignment operator disabled
  const LockMgr & operator=(const LockMgr &that);

public:
  /**
   * @brief get a lock object
   * @param[in] name name of lock
   */
  Lock & getLock(std::string const &name);

protected:
  /// map of available locks: name -> lock object
  LockMap m_lockMap;
}; // class LockMgr

} // namespace Blinker

#endif // #ifndef BLINKER_LOCKMGR_H

