/* 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_MODULEMGR_H
#define BLINKER_MODULEMGR_H

#include <list>
#include <string>

#include "Directory.h"
#include "ListTracker.h"
#include "Mgrs.h"
#include "Module.h"
#include "TimeCallee.h"

namespace Blinker {

/// manager for modules of one type
template<typename MODULE>
class ModuleMgr: public TimeCallee
{
protected:
  /// module container
  class Cntr;

  /// module list tracker
  typedef ListTracker<ModuleMgr, Cntr, Directory> ModuleListTracker;

public:
  /**
   * @brief constructor
   * @param[in] name module manager name / module class name
   * @param[in] name module name
   * @param[in] mgrs managers
   * @param[in] dirBase base directory
   */
  ModuleMgr(const std::string &name, Mgrs &mgrs, const Directory &dirBase);

  /// destructor
  ~ModuleMgr();

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

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

public:
  /// callback when requested time reached
  virtual void timeCall();

protected:
  /// check for update of configuration
  void updateConfig();

protected:
  std::string       m_name;              ///< module manager name
  Mgrs              &m_mgrs;             ///< managers
  Directory         m_dirBase;           ///< base directory
  ModuleListTracker m_moduleListTracker; ///< module list tracker
}; // class ModuleMgr

} // namespace Blinker

#endif // #ifndef BLINKER_MODULEMGR_H

