/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *  
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *  
 * This file is part of NMM. 
 * 
 * NMM is free software; you can redistribute it and/or modify it    
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; only version 2 of the License.      
 * 
 * NMM is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 
 * License for more details.  
 * 
 * You should have received a copy of the GNU General Public License 
 * along with NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#include "nmm/utils/Singleton.hpp"
#include "nmm/utils/thread/ThreadMutex.hpp"
#include "nmm/utils/thread/MutexGuard.hpp"
#include "nmm/plugins/video/tv/interfaces/tvguide/ITVGuide.hpp"

namespace NMM{
  /**
     This class is used in DVBReadNode. it manages registered TVGuides so collected EPG-Data can be sent to them
  */
  class DVBReadNodeTVGuideManager{
    friend class CreateUsingNew<DVBReadNodeTVGuideManager>;
  private:
    ThreadMutex mutex;
    list<pair<ITVGuide*, int> > iTVGuide_list;
  private:
    DVBReadNodeTVGuideManager();
    ~DVBReadNodeTVGuideManager();
    
  public:
    /**
     *Add a TVGuide so it can receive EPG-Data
     *@param tvguide The ITVGuide-Interface if the EPG to be registerd
     */
    void addTVGuide(const ITVGuide *tvguide);
    /**
     *Removes the registered TVGuide with the given Interface
     *@param tvguide The TVGuide to be removed
     */
    void removeTVGuide(const ITVGuide *tvguide);    
    /**
     *Send the given ProgramDescription to all TVGuides
     */
    Result insertEvent(const ProgramDescription &pd);
    /**
     *@return true if TVGuides are registered
     *@return false if no is registered
     */
    bool hasTVGuides();
  };
  /* Typdef to access the DVBReadNodeTVGuideManager */
  typedef Singleton<DVBReadNodeTVGuideManager, CreateUsingNew> SDVBReadNodeTVGuideManager;
}
