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

#include "nmm/nmm_prefix.hpp"

#include "nmm/multimedia/NodeDescription.hpp"
#include "nmm/comm/ObjectID.hpp"

namespace NMM {

  /** Used in class RegistryMemento to describe all properties of a Node.
   */
  class MementoStruct : public SerializedValue {
  public:

    /** Constructor.
     */
    MementoStruct();

    /** Copy constructor.
     *
     * @param m MementoStruct to copy
     */
    MementoStruct(const MementoStruct& m);
  
    /** Returns copy of this MementoStruct.
     *
     * @return poitner to copy of this MementoStruct
     */
    virtual MementoStruct* copy()                 const { return new MementoStruct(*this); }
  
    /** Returns NodeDescription.
     *
     * @return NodeDescription
     */
    const NodeDescription& getNodeDescription()   const { return __node_description; }
  
    /** Returns ObjectID.
     *
     * @return ObjectID
     */
    const ObjectID&        getObjectID()          const { return __object_id.getRValue() ; }
  
    /** Returns maximum possible number of instances.
     *
     * @return maximum possible number of instances
     */
    unsigned int           getMaxInstanceCount()  const { return __max_instance_count.getRValue(); }
  
    /** Returns index of plug-in the node described by this MementoStruct is contained.
     *
     * @return plug-in index
     */
    unsigned int           getPluginIndex()       const { return __plugin_index.getValue(); }

    /** Sets NodeDescription.
     *
     * @param nd NodeDescription to set
     */
    void setNodeDescription( const NodeDescription& nd )        { __node_description = nd; }
  
    /** Sets ObjectID.
     *
     * @param object_id ObjectID to set
     */
    void setObjectID( const ObjectID& object_id )               { __object_id.setValue( object_id ); }
  
    /** Sets maximum possible number of instances.
     *
     * @param max_instance_count maximum possible number of instances
     */
    void setMaxInstanceCount( unsigned int max_instance_count)  { __max_instance_count.setValue( max_instance_count); }
  
    /** Sets index of plug-in the node described by this MementoStruct is contained.
     *
     * @return plug-in index
     */
    void setPluginIndex( unsigned int index)                    { __plugin_index.setValue( index ); }

  private:
  
    /** Registers attributes for serialization/deserialization.
     */
    void registerAttributes();


  private:
    NodeDescription         __node_description; ///< NodeDescription of node represented by this MementoStruct
    TValue<ObjectID>        __object_id;        ///< ObjectID of node represented by this MementoStruct
    TValue<nmm_uint32>    __max_instance_count; ///< maximum possible number of instances
    TValue<nmm_uint32>    __plugin_index;     ///< index of plug-in the node described by this MementoStruct is contained
  };

  /** Serialization operator for list of MementoStructs.
   *
   * @param ov OValueStream to write to
   * @param memento_list list of MementoStructs to write
   * @return reference to OValueStream given by argument
   */
  OValueStream& operator<<(OValueStream& ov, const list<MementoStruct>& memento_list);
  
  /** Deserialization operator for list of MementoStructs.
   *
   * @param iv IValueStream to read from
   * @param memento_list list variable to write to
   * @return reference to IValueStream given by argument
   */
  IValueStream& operator>>(IValueStream& iv, list<MementoStruct>& memento_list);

}

#include "nmm/nmm_suffix.hpp"

#endif
