/* 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_LOVELETTERMOVIE_H
#define BLINKER_LOVELETTERMOVIE_H

#include <string>

#include <BlinkenLib/BlinkenFrame.h>
#include <BlinkenLib/BlinkenMovie.h>

#include "File.h"
#include "Loveletter.h"

namespace Blinker {

/// movie in loveletters
class Loveletter::Movie
{
public:
  /**
   * @brief constructor
   * @param[in] loveletter owning loveletter module
   * @param[in] name name of movie
   * @param[in] file movie file
   */
  Movie(Loveletter &loveletter, const std::string &name,
        const File &file);

  /// destructor
  ~Movie();

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

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

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

protected:
  /// load movie from current file
  void load();

  /// free current movie
  void free();

  /**
   * @brief convert movie name to movie number
   * @param[in] name movie name
   * @param[out] number movie number (name without all non-digits)
   */
  static void name2number(const std::string &name, std::string &number);

protected:
  Loveletter  &m_loveletter; ///< owning loveletter module
  std::string m_name;        ///< name of movie
  File        m_file;        ///< movie file
  std::string m_number;      ///< number of movie
  bool        m_addedToMap;  ///< if movie number could be added to movie map

public:
  stBlinkenMovie *m_pMovie; ///< loaded movie object
}; // class Loveletter::Movie

} // namespace Blinker

#endif // #ifndef BLINKER_LOVELETTERMOVIE_H

