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

#include "nmm/nmm_prefix.hpp"

#include "nmm/Exception.hpp"

#include "TypeInfo.hpp"

namespace NMM {
  
  /** Base class for exceptions that occour during the serialization/deserialization. 
   */
  class InvalidTypeException : public Exception
  {
  public:
    /** Constructor.
     */
    InvalidTypeException()
      : Exception("InvalidTypeException") {}

    /** Constructor.
     *
     * @param message that describes the error
     */
    InvalidTypeException(const std::string& message)
      : Exception("InvalidTypeException : " + message) {}

    /** Constructor.
     * This execption is used if an invalid type occurs during deserialization 
     * 
     * @param expected_type expected type for deserialization
     * @param current_type occured type for deserialization 
     */
    InvalidTypeException(const TypeInfo& expected_type, const TypeInfo& current_type)
      : Exception("InvalidTypeException : "), __expected_type(expected_type), __current_type(current_type)
    {}
    
    /** Virtiual copy constructor
     * 
     * @return copy of the exception 
     */
    InvalidTypeException* copy() const { return new InvalidTypeException(*this); }
    
    /** Returns the object type that is expected by the deserialization process
     * @return object type that is expected by the deserialization process
     */
    inline    const TypeInfo& getExpectedType() const { return __expected_type; }

    /** Returns the object type that occurs instead of the expected type during the deserialization process
     * @return object type that occurs during the deserialization process
     */
    inline    const TypeInfo& getCurrentType()  const { return __current_type; }
    private:
      TypeInfo __expected_type;  ///< expected type for deserialization
      TypeInfo __current_type;   ///< occured type for deserialization 
  };
}

#include "nmm/nmm_suffix.hpp"

#endif
