/* 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.
 *
 */

#ifndef CHANNELDESCRIPTION_HPP
#define CHANNELDESCRIPTION_HPP CHANNELDESCRIPTION_HPP

#include "nmm/nmm_prefix.hpp"

#include <iostream>
#include <list>
#include <string>

#include "nmm/comm/serialize/SerializedValue.hpp"
#include "nmm/comm/serialize/TValue.hpp"

namespace NMM{

  /**
   * This class stores Channel-Informations for EPG
   */
  class ChannelDescription : public SerializedValue
  {
  private:
    NMM::TValue<string> id;
    NMM::TValue<list<string> > names;

  public:
    
    ChannelDescription();
    ChannelDescription(const ChannelDescription&);
    ~ChannelDescription();

    /**
     *Set the ID for this channel
     *@param channel-ID
     */
    void setID (string channelid);
    /**
     *Get the channel-ID of this channel
     *@return string channel-ID
     */
    string getID() const;
    /**
     *Get the channel-ID of this channel
     *@return string channel-ID
     */
    string getID();

    /**
     *Adds a Channel-name for this channel
     *@param channel-name
     */
    void addChannelName(string name);
    /**
     *Sets a list of channel-names
     *@param list of channel-names
     */
    void setChannelNames(list<string> namelist);

    /**
     *Get all the names set for this channel
     *@return list<string> channel-names
     */
    list<string> getChannelNames() const;
    /**
     *Get all the names set for this channel
     *@return list<string> channel-names
     */
    list<string> getChannelNames();
    
    /**
     *Test, if this ChannelDescription is empty. This is true, if no channel-id and no name is set
     */
    bool empty() const { return (id.getRValue().empty() && names.getRValue().empty());}
    /**
     *Test, if this ChannelDescription is empty. This is true, if no channel-id and no name is set
     */
    bool empty() { return (id.getRValue().empty() && names.getRValue().empty());}
 
    //Interface SerialzedValue
    ChannelDescription* copy();

    bool operator==(const ChannelDescription &cd) const;
    bool operator<(const ChannelDescription &cd) const;

  private:
    void registerValues();

  };

  OValueStream& operator<<(OValueStream& os, const list<ChannelDescription>& cd);
  IValueStream& operator>>(IValueStream& is, list<ChannelDescription>& cd);



  class ChannelDescriptionList : public SerializedValue{
  private:
    NMM::TValue<list<ChannelDescription> > internal_list;

  public:
    ChannelDescriptionList() : SerializedValue("ChannelDescriptionList", "NMM"){registerAttributes();}
    ChannelDescriptionList(const ChannelDescriptionList &pl): SerializedValue("ChannelDescriptionList", "NMM"){*this=pl; registerAttributes();}
    ChannelDescriptionList(list<ChannelDescription> l): SerializedValue("ChannelDescriptionList", "NMM"){internal_list = l;registerAttributes();}
  private:
    void registerAttributes(){insertArgument(&internal_list);}

  public:
    list<ChannelDescription> getList() const {return internal_list.getRValue();}
    unsigned int size() const {return internal_list.getRValue().size();}
    void pus_back(ChannelDescription cd){internal_list.getRValue().push_back(cd);}
    ChannelDescription back() const {return internal_list.getRValue().back();}
    void pop_back() {internal_list.getRValue().pop_back();}
  };

  OValueStream& operator<<(OValueStream& os, const std::list<ChannelDescriptionList>& pl);
  IValueStream& operator>>(IValueStream& is, std::list<ChannelDescriptionList>&pl);

}

#include "nmm/nmm_suffix.hpp"

#endif
