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

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/Interface.hpp"
#include "nmm/comm/messaging/Event.hpp"
#include "nmm/comm/messaging/IllegalStateException.hpp"
#include <memory>

#include "nmm/multimedia/IUsageNotify.hpp"

#include "visibility.hpp"

namespace NMM
{
  /** Interface for managing the usage of a shared node.
   *
   * @deprecated Usage management is not supported
   */

  class DLLEXPORT IUsage : virtual public NMM::Interface { 
  public:
    IUsage() : NMM::Interface(IUsage::IUsage_type, "NMM") { };

    IUsage(NMM::NMMObject& parent) : NMM::Interface (parent, IUsage::IUsage_type, "NMM") { };

    virtual ~IUsage() {};

    static const char* IUsage_type;

    virtual  string getInterfaceType() const { return IUsage_type; }

    NMM::Interface* copy() const { return new IUsage(*this); }
    static void used(); 
    static const char* setUsage_event;
    static const char* unsetUsage_event;
    static const char* getUsage_event;
    static const char* getRank_event;
    static const char* isMaster_event;
    /** Set the Usage of the node.
     *
     * @param usage usage of the node
     * @param user %IUsageNotify interface of this user so it will be notified, if its status (master or slave) changes
     */

    virtual void setUsage(const nmm_int32& usage, const IUsageNotify* user)
      throw(const NMM::SerializedException&);
    /** Unset the Usage of the node.
     *
     * @param usage usage of the node
     * @param user %IUsageNotify interface of this user to identify the user
     */

    virtual void unsetUsage(const nmm_int32& usage, const IUsageNotify* user)
      throw(const NMM::SerializedException&);
    /** Get the current Usage of this node.
     *
     * @return The current usage
     */

    virtual nmm_int32 getUsage()
      throw(const NMM::SerializedException&);
    /** Get the usage rank.
     * This method returns the number of users wich have requested this node before the given
     * user with the given usage.
     *
     * @param usage usage of the node
     * @param user %IUsageNotify interface of this user to identify the user
     * @return The usage rank of this node
     */

    virtual nmm_int32 getRank(const nmm_int32& usage, const IUsageNotify* user)
      throw(const NMM::SerializedException&);
    /** Checks if the given user will be master with the given usage.
     *
     * @param usage usage of the node
     * @param user %IUsageNotify interface of this user to identify the user
     * @return @c SUCCESS if the user will be master, @c FAILURE if the user will be slave
     */

    virtual Result isMaster(const nmm_int32& usage, const IUsageNotify* user)
      throw(const NMM::SerializedException&);


  };

  typedef auto_ptr<IUsage> IUsage_var;




}

#include "nmm/nmm_suffix.hpp"

#endif
