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

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/serialize/SerializedException.hpp"

#include "visibility.hpp"

namespace NMM {
  class InputJack;
  class OutputJack;
  class IInputJack;
  class IOutputJack;

  /** A device is of the wrong type.
   * This exception is thrown if a device was selected for a node using the IDevice::setDevice method,
   * and the device could be opened but is of the wrong type. This can happen, for example, if a sound device
   * was selected for a node which represents a TV card device.
   */
  class DLLEXPORT WrongDeviceException : public SerializedException
  {
  public:
    /** Create an exception.
     *
     * @param device Device name of the device which was not found
     */
    WrongDeviceException(const string& device = "")
      : SerializedException("WrongDeviceException"), __device(device) { setTypeName("WrongDeviceException"); registerAttributes(); }

    /** Create an exception.
     *
     * @param message Additional exception comment (a brief error description)
     * @param device Device name of the device which was not found
     */
    WrongDeviceException(const string& message, const string& device)
      : SerializedException("WrongDeviceException : " + message), __device(device) { setTypeName("WrongDeviceException"); registerAttributes();}

    /** Create an exception within a method of a NamedObject.
     *
     * @param parent NamedObject from which the exception is thrown
     * @param device Device name of the device which was not found
     */
    WrongDeviceException(const NamedObject* parent, const string& device)
      : SerializedException(parent, "WrongDeviceException"), __device(device) { setTypeName("WrongDeviceException"); registerAttributes();}

    /** Create an exception within a method of a NamedObject.
     *
     * @param parent NamedObject from which the exception is thrown
     * @param message Additional exception comment (a brief error description)
     * @param device Device name of the device which was not found
     */
    WrongDeviceException(const NamedObject* parent, const string& message, const string& device)
      : SerializedException(parent, ((message == "") ? "WrongDeviceException" : "WrongDeviceException : " + message)), __device(device) { setTypeName("WrongDeviceException"); registerAttributes();};

    /** Virtual copy constructor.
     *
     * @return A copy of this object
     */
    WrongDeviceException* copy() const { return new WrongDeviceException(*this); }

    /** Get the device ID.
     *
     * @return The device ID of the device which was not found
     */
    const string& getDevice()    const { return __device.getRValue(); }
  private: //method
    /** Register all serialized attributes.
     */
    void registerAttributes();
  private:
    TValue<string> __device;
  };

}

#include "nmm/nmm_suffix.hpp"

#endif
