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

#include "nmm/nmm_prefix.hpp"

#include <string>

#include "MementoStruct.hpp"
#include "RegistryID.hpp"

namespace NMM {

  /** A RegistryMemento stores the state of a certain Registry. It contains all information about
   * that are managed by a certain registry. This allows a Registry to get the information about its nodes 
   * without loading the corresponding plug-ins.
   */
class RegistryMemento : public SerializedValue {
public:                          
/** Constructor.
  */
  RegistryMemento();

/** Copy Constructor.
 * @param rm RegistryMemento which gets copied
 */
  RegistryMemento(const RegistryMemento& rm);

  /** Creates copy of this RegistryMemento.
   */
  virtual RegistryMemento* copy()             const { return new RegistryMemento(*this); }
 
  /** Checks if plugin member variable is empty.
   * @return true if plugin member variable is empty, false otherwise
   */
  bool isPluginRequired()                     const { return ! __plugin.getRValue().empty(); }

  /** Returns plug-in name.
   * @return plug-in name
   */ 
  const string& getPluginName()               const { return __plugin.getRValue(); }

  /** Sets plug-in name.
   * @param plugin plug-in name
   */
  void setPluginName(const string& plugin)          { __plugin.setValue(plugin); }

  /** Returns RegistryID.
   * @return RegistryID
   */
  const RegistryID& getRegistryID()           const { return __registry_id.getRValue(); }

  /** Returns RegistryID.
   * @return RegistryID
   */
  RegistryID& getRegistryID()                       { return __registry_id.getRValue(); }

  /** Sets RegistryID.
   * @param reg_id RegistryID to be set
   */
  void setRegistryID(const RegistryID& reg_id)      { __registry_id.setValue(reg_id); }

  /** Returns list of MementoStruct's.
   * Returns list of MementoStruct's, which specifies a node.
   * @return list of MementoStruct's
   */
  const list<MementoStruct>& getMementoList() const { return __memento_list.getRValue(); } 

  /** Adds MementoStruct.
   * Adds MementoStruct to list of MementoStructs.
   * @param memento_struct MementoStruct to be added 
   */
  void addMementoStruct(const MementoStruct& memento_struct) { __memento_list.getRValue().push_back(memento_struct); }

private:

  /** Register all attributes for serialization/deserialization.
   */
  void registerAttributes(); 
private:
  TValue<string>                   __plugin;         ///< name of plug-in this RegistryMemento describes
  TValue<RegistryID>               __registry_id;    ///< RegistryID of Registry this plug-in is registered to
  TValue< list<MementoStruct> >    __memento_list;   ///< represents nodes of plug-in
};

}//end namespace
#include "nmm/nmm_suffix.hpp"

#endif

