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

#include "nmm/nmm_prefix.hpp"

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

namespace NMM {

class IValueStream;
class OValueStream;

  /** Class stores informations related to a node. 
   */

class DLLEXPORT NodeInfo : public SerializedValue {
public:
/** @name Constructor & Destructor
  */
//@{
/** Default Constructor.
  */
  NodeInfo();

  /** Constructor to set all members.
   *
   * @param node_id id of the node
   * @param lib_name name of library in which this node is contained
   * @param node_name name of the node
   * @param inst_count number of current existing instances of this node
   * @param max_count maximum possible number of existing instances of this node
   * @param node_type type of this node
   */
  NodeInfo(const ObjectID& node_id, const string& lib_name, const string& node_name, int inst_count, int max_count, int node_type);

  /** Copy constructor.
   *
   * @param ni NodeInfo to copy
   */
  NodeInfo(const NodeInfo& ni);

  /** Virtual copy constructor.
   */
  virtual NodeInfo* copy()                                const   { return new NodeInfo(*this); }
  //@}
  
  /** @name Set NodeInfo parameter
   */
  //@{
  /** This method sets the ObjectID.
   *
   * @param node_id ObjectID to set
   */
  inline void setObjectID(const ObjectID& node_id)                    { __node_id.setValue(node_id); }
  
  /** This method sets the name of the Node.
   *
   * @param node_name name of the node
   */
  inline void setNodeName(const string& node_name)                { __node_name.setValue(node_name); }

  /** This method sets the name of the library that offers the node.
   *
   * @param lib_name name of the library
   */
  inline void setLibraryName(const string& lib_name)              { __library_name.setValue(lib_name); }
  
  /** This method sets the current instance count.
   * 
   * @param count new value of the instance count
   */
  inline void setInstanceCount(int count)                         { __node_id.setValue(count); }
  
  /** This method sets the maximum instance count.
   *
   * @param count new value of number of maximum instances
   */
  inline void setMaxInstanceCount(int count)                      { __node_id.setValue(count); }

  /** This method sets the type of the node.
   *
   * @param nt Node type
   */
  inline void setNodeType(int nt)                                 { __node_type.setValue(nt); }
  //@}
  
  /** @name Get NodeInfo parameter
   */
  //@{
  /** This method returns the ObjectID of the described node.
   *
   * @return ObjectID the node 
   */
  inline ObjectID getObjectID()                               const   { return __node_id.getValue(); }
  
  /** This method returns the name of the library that offers the Node.
   *
   * @return name of the library that offers the Node
   */
  inline const string& getLibraryName()                   const   { return __library_name.getRValue(); }

  /** This method returns the name of the Node.
   *
   * @return name of the Node
   */
  inline const string& getNodeName()                      const   { return __node_name.getRValue(); }

  /** This method returns the current instance count of this Node.
   *
   * @return current instance count of this Node
   */
  inline int getInstanceCount()                           const   { return __instance_count.getRValue(); }

  /** This method returns the maximum instance count of this Node.
   * 
   * @return maximum instance count of this Node
   */
  inline int getMaxInstanceCount()                        const   { return __max_instance_count.getRValue(); }

  /** This method returns the type of the Node.
   *
   * @return type of the Node
   */
  inline int getNodeType()                                const   { return __node_type.getValue(); }
//@}

private:

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


  TValue<ObjectID>  __node_id;                             ///< stores the ObjectID of a Node
  TValue<string>    __library_name;                        ///< stores the library name 
  TValue<string>    __node_name;                           ///< stores the name of the Node
  TValue<nmm_int32>       __instance_count;                      ///< stores the current instance count
  TValue<nmm_int32>       __max_instance_count;                  ///< stores the maximum instance count
  TValue<nmm_int32>       __node_type;                           ///< stores the type of the node.
};

  /** Serialization operator for lists of NodeInfo.
   *
   * @param ov OValueStream to write to
   * @param string_list list of NodeInfo to serialize
   * @return reference to OValueStream given by argument
   */
  OValueStream& operator<<(OValueStream& ov, const std::list<NodeInfo>& string_list);

  /** Deserialization operator for lists of NodeInfo.
   *
   * @param iv IValueStream to read from
   * @param string_list list variable to write to
   * @return reference to IValueStream given by argument
   */
  IValueStream& operator>>(IValueStream& iv, std::list<NodeInfo>& string_list);

}
#include "nmm/nmm_suffix.hpp"

#endif
