/* 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_T_EDOBJECT_HPP
#define NMM_T_EDOBJECT_HPP NMM_T_EDOBJECT_HPP

#include "nmm/nmm_prefix.hpp"

#include "EDObject.hpp"
#include "UnexpectedException.hpp"
#include "Event.hpp"

#include "nmm/Exception.hpp"

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

namespace NMM {
  
  /** A TemplateEventDispatcherObject for a method with 0 arguments
   * @param T   Type of the object
   * @param U   Type of the method
   * @param V   Type of the return value
   */
  template<class T, class U = Result (T::*)() , class V = Result>
  class TEDObject0 : public EDObject {
    typedef U TEDMethod0;
  public:
    /** Constructor
     * @param object     pointer to the object.
     * @param method : pointer to the objects memberfunction
     */
    TEDObject0(T* object, TEDMethod0 method)
      : __object(object), __method(method)
    { }

    /** Dispatches the event.
     * 
     * @param event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const {Event* event = 0; try { event = new Event(key); event->setReturnValue(new TValue<V>(Value::INVALUE)); return event;} catch ( ... ) { delete event;} return 0; }

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod0  __method;     ///< pointer to the objects memberfuncion
  };


  /** A TemplateEventDispatcherObject for a method with 0 arguments and Return-Value void
   * @param T   Node-type
   */
  template<class T, class U >
  class TEDObject0<T, U, void>  : public EDObject {
    typedef U TEDMethod0;
  public:
    /** Constructor
     * @param object   pointer to the Node object.
     * @param method   pointer to a memberfunction
     */
    TEDObject0(T* object, TEDMethod0 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event Event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const { return new Event(key);}

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod0  __method;     ///< pointer to the objects memberfuncion
  };


  /** A TemplateEventDispatcherObject for a method with 1 argument
   * @param T  Node-type
   * @param U  type of the first method argument
   */
  template<class T, class U, class V = Result (T::*)(U&), class W = Result>
  class TEDObject1 : public EDObject {
    typedef V TEDMethod1;
  public:
    /** Constructor
     * @param object  pointer to the Node object.
     * @param method  pointer to a memberfunction
     */
    TEDObject1(T* object, TEDMethod1 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const  {Event* event = 0; try { event = new Event(key, new TValue<U>(Value::INVALUE)); event->setReturnValue(new TValue<W>(Value::INVALUE)); return event; } catch (...) { delete event;} return 0;}

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod1  __method;     ///< pointer to the objects memberfuncion
  };

  /** A specialized TemplateEventDispatcherObject for a method with 1 argument and return value void
   * @param T   Node-type
   * @param U   type of the first method argument
   */
  template<class T, class U, class V>
  class TEDObject1<T, U, V, void> : public EDObject {
    typedef  V TEDMethod1 ;
  public:
    /** Constructor
     * @param object pointer to the Node object.
     * @param method pointer to a memberfunction
     */
    TEDObject1(T* object, TEDMethod1 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const  { Event* event = 0; try {event = new Event(key, new TValue<U>(Value::INVALUE)); return event; } catch (...) { delete event; } return 0; }

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod1  __method;     ///< pointer to the objects memberfuncion
  };


  /** A TemplateEventDispatcherObject for a method with 2 arguments
   * @param T   Node-type
   * @param U   type of the first method-argument
   * @param V   type of the second mehtod-argument
   */
  template<class T, class U, class V, class W = Result (T::*)(U&, V&), class X = Result>
  class TEDObject2 : public EDObject {
    typedef W TEDMethod2;
  public:

    /** Constructor
     * @param object pointer to the Node object.
     * @param method pointer to a memberfunction
     */
    TEDObject2(T* object, TEDMethod2 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const   { Event* event = 0; try { event = new Event(key, new TValue<U>(Value::INVALUE), new TValue<V>(Value::INVALUE));  event->setReturnValue(new TValue<X>(Value::INVALUE)); return event; } catch ( ... ) { delete event; } return 0;}

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod2  __method;     ///< pointer to the objects memberfuncion
  };


  /** A TemplateEventDispatcherObject for a method with 2 arguments
   * @param T   Node-type
   * @param U   type of the first method-argument
   * @param V   type of the second mehtod-argument
   */
  template<class T, class U, class V, class W >
  class TEDObject2<T, U, V, W, void> : public EDObject {
    typedef W TEDMethod2;
  public:
    /** Constructor
     * @param object pointer to the Node object.
     * @param method pointer to a memberfunction
     */
    TEDObject2(T* object, TEDMethod2 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const   { Event* event = 0; try { event = new Event(key, new TValue<U>(Value::INVALUE), new TValue<V>(Value::INVALUE)); return event; } catch ( ... ) { delete event; } return 0;}

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod2  __method;     ///< pointer to the objects memberfuncion
  };



  /** A TemplateEventDispatcherObject for a method with 3 arguments
   * @param T   Node-type
   * @param U   type of the first method-argument
   * @param V   type of the second mehtod-argument
   * @param W   type of the third method-argument
   */
  template<class T, class U, class V, class W, class X = Result (T::*)(U&,V&,W&), class Y = Result>
  class TEDObject3 : public EDObject {
    typedef X TEDMethod3;
  public:
    /** Constructor
     * @param object pointer to the Node object.
     * @param method pointer to a memberfunction
     */
    TEDObject3(T* object, TEDMethod3 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const   { Event* event = 0; try { event = new Event(key, new TValue<U>(Value::INVALUE), new TValue<V>(Value::INVALUE), new TValue<W>(Value::INVALUE)); event->setReturnValue(new TValue<Y>(Value::INVALUE));  return event; } catch ( ... ) { delete event; } return 0;}

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod3  __method;     ///< pointer to the objects memberfuncion
  };


  /** A TemplateEventDispatcherObject for a method with 3 arguments
   * @param T   Node-type
   * @param U   type of the first method-argument
   * @param V   type of the second mehtod-argument
   * @param W   type of the third method-argument
   */
  template<class T, class U, class V, class W, class X>
  class TEDObject3<T, U, V, W, X, void> : public EDObject {
    typedef X TEDMethod3;
  public:
    /** Constructor
     * @param object pointer to the Node object.
     * @param method pointer to a memberfunction
     */
    TEDObject3(T* object, TEDMethod3 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const   { Event* event = 0; try { event =  new Event(key, new TValue<U>(Value::INVALUE), new TValue<V>(Value::INVALUE), new TValue<W>(Value::INVALUE)); return event; } catch ( ... ) { delete event;} return 0;}

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod3  __method;     ///< pointer to the objects memberfuncion
  };

  /** A TemplateEventDispatcherObject for a method with 4 arguments
   * @param T   Node-type
   * @param U   type of the first method-argument
   * @param V   type of the second mehtod-argument
   * @param W   type of the third method-argument
   * @param X   type of the fourth method-argument
   */
  template<class T, class U, class V, class W, class X, class Y = Result (T::*)(U&, V&, W&, X&), class Z = Result>
  class TEDObject4 : public EDObject {
    typedef Y TEDMethod4;
  public:
    /** Constructor
     * @param object pointer to the Node object.
     * @param method pointer to a memberfunction
     */
    TEDObject4(T* object, TEDMethod4 method)
      : __object(object), __method(method)
    {}

     /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const   { Event* event = 0; try { event = new Event(key, new TValue<U>(Value::INVALUE), new TValue<V>(Value::INVALUE), new TValue<W>(Value::INVALUE), new TValue<X>(Value::INVALUE)); event->setReturnValue(new TValue<Z>(Value::INVALUE)); return event; } catch ( ... ) {delete event;} return 0;  }

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod4  __method;     ///< pointer to the objects memberfuncion
  };


  /** A TemplateEventDispatcherObject for a method with 4 arguments
   * @param T   Node-type
   * @param U   type of the first method-argument
   * @param V   type of the second mehtod-argument
   * @param W   type of the third method-argument
   * @param X   type of the fourth method-argument
   */
  template<class T, class U, class V, class W, class X, class Y>
  class TEDObject4<T, U, V, W, X, Y, void> : public EDObject {
    typedef Y TEDMethod4;
  public:
    /** Constructor
     * @param object pointer to the Node object.
     * @param method pointer to a memberfunction
     */
    TEDObject4(T* object, TEDMethod4 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const   { Event* event = 0; try {event = new Event(key, new TValue<U>(Value::INVALUE), new TValue<V>(Value::INVALUE), new TValue<W>(Value::INVALUE), new TValue<X>(Value::INVALUE)); return event; } catch ( ... ) { delete event; } return 0;}

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod4  __method;     ///< pointer to the objects memberfuncion
  };




  /** A TemplateEventDispatcherObject for a method with 4 arguments
   * @param T   Node-type
   * @param U   type of the first method-argument
   * @param V   type of the second mehtod-argument
   * @param W   type of the third method-argument
   * @param X   type of the fourth method-argument
   * @param A_5   type of the fifth method-argument
   */
  template<class T, class U, class V, class W, class X, class A_5,class Y = Result (T::*)(U&, V&, W&, X&, A_5&), class Z = Result>
  class TEDObject5 : public EDObject {
    typedef Y TEDMethod5;
  public:
    /** Constructor
     * @param object pointer to the Node object.
     * @param method pointer to a memberfunction
     */
    TEDObject5(T* object, TEDMethod5 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const   { Event* event = 0; try { event = new Event(key, new TValue<U>(Value::INVALUE), new TValue<V>(Value::INVALUE), new TValue<W>(Value::INVALUE), new TValue<X>(Value::INVALUE), new TInValue<A_5>()); event->setReturnValue(new TValue<Z>(Value::INVALUE)); return event; } catch ( ... ) { delete event; } return 0;  }

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod5  __method;     ///< pointer to the objects memberfuncion
  };


  /** A TemplateEventDispatcherObject for a method with 4 arguments
   * @param T   Node-type
   * @param U   type of the first method-argument
   * @param V   type of the second mehtod-argument
   * @param W   type of the third method-argument
   * @param X   type of the fourth method-argument
   * @param A_5   type of the fifth method-argument
   */
  template<class T, class U, class V, class W, class X, class A_5,class Y>
  class TEDObject5<T, U, V, W, X, A_5, Y, void> : public EDObject {
    typedef Y TEDMethod5;
  public:
    /** Constructor
     * @param object pointer to the Node object.
     * @param method pointer to a memberfunction
     */
    TEDObject5(T* object, TEDMethod5 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const   { Event* event = 0; try { event =  new Event(key, new TValue<U>(Value::INVALUE), new TValue<V>(Value::INVALUE), new TValue<W>(Value::INVALUE), new TValue<X>(Value::INVALUE), new TInValue<A_5>()); return event; } catch ( ... ) { delete event; } return 0; }

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod5  __method;     ///< pointer to the objects memberfuncion
  };





  /** A TemplateEventDispatcherObject for a method with 4 arguments
   * @param T   Node-type
   * @param U   type of the first method-argument
   * @param V   type of the second mehtod-argument
   * @param W   type of the third method-argument
   * @param X   type of the fourth method-argument
   * @param A_5   type of the fifth method-argument
   */
  template<class T, class U, class V, class W, class X, class A_5, class A_6, class Y = Result (T::*)(U&, V&, W&, X&, A_5&, A_6&), class Z = Result>
  class TEDObject6 : public EDObject {
    typedef Y TEDMethod6;
  public:
    /** Constructor
     * @param object     pointer to the Node object.
     * @param method : pointer to a memberfunction
     */
    TEDObject6(T* object, TEDMethod6 method)
      : __object(object), __method(method)
    {}

     /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const   { Event* event = 0; try { event = new Event(key, new TValue<U>(Value::INVALUE), new TValue<V>(Value::INVALUE), new TValue<W>(Value::INVALUE), new TValue<X>(Value::INVALUE), new TInValue<A_5>(), new TInOutValue<A_6>()); event->setReturnValue(new TValue<Z>(Value::INVALUE)); return event; } catch ( ... ) { delete event; } return 0;  }

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod6  __method;     ///< pointer to the objects memberfuncion
  };


  /** A TemplateEventDispatcherObject for a method with 4 arguments
   * @param T   Node-type
   * @param U   type of the first method-argument
   * @param V   type of the second mehtod-argument
   * @param W   type of the third method-argument
   * @param X   type of the fourth method-argument
   */
  template<class T, class U, class V, class W, class X, class A_5,class A_6, class Y>
  class TEDObject6<T, U, V, W, X, A_5, A_6, Y, void> : public EDObject {
    typedef Y TEDMethod6;
  public:
    /** Constructor
     * @param object     pointer to the Node object.
     * @param method : pointer to a memberfunction
     */
    TEDObject6(T* object, TEDMethod6 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const   { Event* event = 0; try { event = new Event(key, new TValue<U>(Value::INVALUE), new TValue<V>(Value::INVALUE), new TValue<W>(Value::INVALUE), new TValue<X>(Value::INVALUE), new TInValue<A_5>(), new TInValue<A_6>()); } catch ( ... ) { delete event; } return 0; }

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod6  __method;     ///< pointer to the objects memberfuncion
  };






  /** A TemplateEventDispatcherObject for a method with 4 arguments
   * @param T   Node-type
   * @param U   type of the first method-argument
   * @param V   type of the second mehtod-argument
   * @param W   type of the third method-argument
   * @param X   type of the fourth method-argument
   * @param A_5   type
   */
  template<class T, class U, class V, class W, class X, class A_5, class A_6, class A_7, class Y = Result (T::*)(U&, V&, W&, X&, A_5&, A_6&, A_7&), class Z = Result>
  class TEDObject7 : public EDObject {
    typedef Y TEDMethod7;
  public:
    /** Constructor
     * @param object     pointer to the Node object.
     * @param method : pointer to a memberfunction
     */
    TEDObject7(T* object, TEDMethod7 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const   { Event* event = 0; try { event = new Event(key, new TValue<U>(Value::INVALUE), new TValue<V>(Value::INVALUE), new TValue<W>(Value::INVALUE), new TValue<X>(Value::INVALUE), new TInValue<A_5>(), new TInValue<A_6>(), new TInValue<A_7>()); event->setReturnValue(new TValue<Z>()); return event;  } catch ( ... ) { delete event; } return 0; }

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod7  __method;     ///< pointer to the objects memberfuncion
  };


  /** A TemplateEventDispatcherObject for a method with 4 arguments
   * @param T   Node-type
   * @param U   type of the first method-argument
   * @param V   type of the second mehtod-argument
   * @param W   type of the third method-argument
   * @param X   type of the fourth method-argument
   */
  template<class T, class U, class V, class W, class X, class A_5, class A_6, class A_7, class Y>
  class TEDObject7<T, U, V, W, X, A_5, A_6, A_7, Y, void> : public EDObject {
    typedef Y TEDMethod7;
  public:
    /** Constructor
     * @param object pointer to the Node object.
     * @param method pointer to a memberfunction
     */
    TEDObject7(T* object, TEDMethod7 method)
      : __object(object), __method(method)
    {}

    /** Dispatches the event.
     *
     * @param event event to dispatch
     * @return result of dispatching
     */
    virtual Result dispatch(Event& event);

    /** Creates an Event with TInValues. 
     *
     * The TInValues have correct type and can configured by a stream.
     *
     * @param key event key
     * @return pointer to new Event, NULL if creation failed
     */
    virtual Event* createEvent(const std::string& key = "")  const   { Event* event = 0; try { event =  new Event(key, new TValue<U>(Value::INVALUE), new TValue<V>(Value::INVALUE), new TValue<W>(Value::INVALUE), new TValue<X>(Value::INVALUE), new TInValue<A_5>(), new TInValue<A_6>(), new TInValue<A_7>()); return event; } catch ( ... ) { delete event; } return 0; }

  private:
    T*          __object;     ///< pointer to the object
    TEDMethod7  __method;     ///< pointer to the objects memberfuncion
  };



  /***************************Implementaion of the dispatch method***************************************************/

  template<class T, class U, class V>
  Result TEDObject0<T, U, V>::dispatch(Event& event) {
    if (event.getArgSize() != 0){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 0. Event has argumentsize " << event.getArgSize() << endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 0. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    } try {
      /* Begin> Create the values if they are not set*/
      if (!event.getReturnValue())
        event.setReturnValue(new TOutValue<V>());

      /* Begin> Perform type conversion */
      TValue<V>* return_value = dynamic_cast< TValue<V>* >(const_cast<Value*>(event.getReturnValue()));
      TValue<V>* method_return_value = 0;

      /*Begin> Hack: If method's return value is result return the result*/
      TValue<Result> tmp_value;
      TValue<Result>* result_value = &tmp_value; //hack to avoid warnings
      method_return_value = dynamic_cast<TValue<V>*>(result_value);
      /*End< */

      /* Begin> Execute the method*/
      if (return_value) {
        return_value->setValue((__object->*__method)( ));

        if (method_return_value)
          method_return_value->setValue(return_value->getValue());
      }
      else {
        GLOBAL_WARNING_STREAM2("Warning : Return value of Event " << event.getKey() << "is not stored " << endl);
        if (method_return_value)
          method_return_value->setValue((__object->*__method)( ));
        else
          (__object->*__method)( );
      }
      /* End< */

      if (method_return_value) {
        return result_value->getValue();
      }

      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }
  }

  template<class T, class U>
  Result TEDObject0<T, U, void>::dispatch(Event& event) {
    if (event.getArgSize() != 0){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 0. Event has argumentsize " << event.getArgSize() << endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 0. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    } try {
      (__object->*__method)( );
      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }
  }

  template<class T, class U, class V, class W>
  Result TEDObject1<T, U, V, W>::dispatch(Event& event) {
    if (event.getArgSize() != 1){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 1. Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 1. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }
    if (!event.getReturnValue())
      event.setReturnValue(new TOutValue<W>());


    TValue<U>* value = dynamic_cast< TValue<U> * >(const_cast<Value*>(event.getValue(0)));
    TValue<W>* return_value = dynamic_cast< TValue<W>* >(const_cast<Value*>(event.getReturnValue()));

    /*Begin> Hack: If method's return value is result return the result*/
    TValue<W>* method_return_value = 0;
    TValue<Result> tmp_value;
    TValue<Result>* result_value = &tmp_value; //hack to avoid warnings
    method_return_value = dynamic_cast<TValue<W>*>(result_value);
    /*End< */


    if (!value) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    try {
      if (return_value) {
        return_value->setValue( (__object->*__method)( value->getRValue() ) );

        if (method_return_value)
          method_return_value->setValue(return_value->getValue());
      } else {
        GLOBAL_WARNING_STREAM2("Warning : Return value of Event " << event.getKey() << "is not stored " << endl);
        if (method_return_value)
          method_return_value->setValue((__object->*__method)( value->getRValue() ));
        else
          (__object->*__method)( value->getRValue() );
      }

      if (method_return_value) {
        return result_value->getValue();
      }

      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }
  }


  template<class T, class U, class V>
  Result TEDObject1<T, U, V, void>::dispatch(Event& event) {
    if (event.getArgSize() != 1){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 1. Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 1. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    TValue<U>* value = dynamic_cast< TValue<U> * >(const_cast<Value*>(event.getValue(0)));

    if (!value) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    try {
      (__object->*__method)( value->getRValue() ) ;
      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }
  }


  template<class T, class U, class V, class W, class X>
  Result TEDObject2<T, U, V, W, X>::dispatch(Event& event) {
    if (event.getArgSize() != 2) {
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 2 for Event " << event.getKey() << ". Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 2. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    if (!event.getValue(1)) {
      event.setValue(1, new TOutValue<V>());
    }
    /* End< */

    if (!event.getReturnValue())
      event.setReturnValue(new TOutValue<X>());

    TValue<U>* value_0 = dynamic_cast<TValue<U>*>(const_cast<Value*>(event.getValue(0)));
    TValue<V>* value_1 = dynamic_cast<TValue<V>*>(const_cast<Value*>(event.getValue(1)));
    TValue<X>* return_value = dynamic_cast< TValue<X>* >(const_cast<Value*>(event.getReturnValue()));

    /*Begin> Hack: If method's return value is result return the result*/
    TValue<X>* method_return_value = 0;
    TValue<Result> tmp_value;
    TValue<Result>* result_value = &tmp_value; //hack to avoid warnings
    method_return_value = dynamic_cast<TValue<X>*>(result_value);
    /*End< */

    if (!value_0) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }

    if (!value_1) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 2. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }

    try {
      if (return_value) {
        return_value->setValue((__object->*__method)( value_0->getRValue(), value_1->getRValue() ));

        if (method_return_value)
          method_return_value->setValue(return_value->getValue());
      }
      else {
        GLOBAL_WARNING_STREAM2("Warning : Return value of Event " << event.getKey() << "is not stored " << endl);
        if (method_return_value)
          method_return_value->setValue((__object->*__method)( value_0->getRValue(), value_1->getRValue() ));
        else
          (__object->*__method)( value_0->getRValue(), value_1->getRValue() );
      }

      if (method_return_value)
        return result_value->getValue();

      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }
  }


  template<class T, class U, class V, class W>
  Result TEDObject2<T, U, V, W, void>::dispatch(Event& event) {
    if (event.getArgSize() != 2) {
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 2 for Event " << event.getKey() << ". Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 2. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    if (!event.getValue(1)) {
      GLOBAL_ERROR_STREAM2("Warning : 2. Value of void event " << event.getKey() << " is 0. create a default value " <<  endl);
      event.setValue(1, new TOutValue<V>());
    }

    TValue<U>* value_0 = dynamic_cast<TValue<U>*>(const_cast<Value*>(event.getValue(0)));
    TValue<V>* value_1 = dynamic_cast<TValue<V>*>(const_cast<Value*>(event.getValue(1)));

    if (!value_0) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }

    if (!value_1) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 2. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }

    try {
      (__object->*__method)( value_0->getRValue(), value_1->getRValue() );
      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }
  }

  template<class T, class U, class V, class W, class X, class Y>
  Result TEDObject3<T, U, V, W, X, Y>::dispatch(Event& event) {
    if (event.getArgSize() != 3){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 3. Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 3. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    if (!event.getValue(1)) {
      event.setValue(1, new TOutValue<V>());
    }

    if (!event.getValue(2)) {
      event.setValue(2, new TOutValue<W>());
    }

    if (!event.getReturnValue())
      event.setReturnValue(new TOutValue<Y>());


    TValue<U>* value_0 = dynamic_cast<TValue<U>*>(const_cast<Value*>(event.getValue(0)));
    TValue<V>* value_1 = dynamic_cast<TValue<V>*>(const_cast<Value*>(event.getValue(1)));
    TValue<W>* value_2 = dynamic_cast<TValue<W>*>(const_cast<Value*>(event.getValue(2)));
    TValue<Y>* return_value = dynamic_cast< TValue<Y>* >(const_cast<Value*>(event.getReturnValue()));

    /*Begin> Hack: If method's return value is result return the result*/
    TValue<Y>* method_return_value = 0;
    TValue<Result> tmp_value;
    TValue<Result>* result_value = &tmp_value; //hack to avoid warnings
    method_return_value = dynamic_cast<TValue<Y>*>(result_value);
    /*End< */


    if (!value_0) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_1) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 2. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_2) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 3. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    try {
      if (return_value) {
        return_value->setValue( (__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue() ) );
        if (method_return_value)
          method_return_value->setValue(return_value->getValue());
      } else {
        GLOBAL_WARNING_STREAM2("Warning : Return value of Event " << event.getKey() << "is not stored " << endl);
        if (method_return_value)
          method_return_value->setValue((__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue() ));
        else
          (__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue() );
      }

      if (method_return_value)
        return result_value->getValue();

      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }

  }

  template<class T, class U, class V, class W, class X>
  Result TEDObject3<T, U, V, W, X, void>::dispatch(Event& event) {
    if (event.getArgSize() != 3){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 3. Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 3. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    if (!event.getValue(1)) {
      event.setValue(1, new TOutValue<V>());
    }

    if (!event.getValue(2)) {
      event.setValue(2, new TOutValue<W>());
    }


    TValue<U>* value_0 = dynamic_cast<TValue<U>*>(const_cast<Value*>(event.getValue(0)));
    TValue<V>* value_1 = dynamic_cast<TValue<V>*>(const_cast<Value*>(event.getValue(1)));
    TValue<W>* value_2 = dynamic_cast<TValue<W>*>(const_cast<Value*>(event.getValue(2)));

    if (!value_0) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_1) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 2. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_2) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 3. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    try {
      (__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue() );
      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }

  }

  template<class T, class U, class V, class W, class X, class Y, class Z>
  Result TEDObject4<T, U, V, W, X, Y, Z>::dispatch(Event& event) {
    if (event.getArgSize() != 4){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 4. Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 4. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    if (!event.getValue(1)) {
      event.setValue(1, new TOutValue<V>());
    }

    if (!event.getValue(2)) {
      event.setValue(2, new TOutValue<W>());
    }

    if (!event.getValue(3)) {
      event.setValue(3, new TOutValue<X>());
    }

    if (!event.getReturnValue())
      event.setReturnValue(new TOutValue<Z>());

    TValue<U>* value_0 = dynamic_cast<TValue<U>*>(const_cast<Value*>(event.getValue(0)));
    TValue<V>* value_1 = dynamic_cast<TValue<V>*>(const_cast<Value*>(event.getValue(1)));
    TValue<W>* value_2 = dynamic_cast<TValue<W>*>(const_cast<Value*>(event.getValue(2)));
    TValue<X>* value_3 = dynamic_cast<TValue<X>*>(const_cast<Value*>(event.getValue(3)));
    TValue<Z>* return_value = dynamic_cast< TValue<Z>* >(const_cast<Value*>(event.getReturnValue()));

    /*Begin> Hack: If method's return value is result return the result*/
    TValue<Z>* method_return_value = 0;
    TValue<Result> tmp_value;
    TValue<Result>* result_value = &tmp_value; //hack to avoid warnings
    method_return_value = dynamic_cast<TValue<Z>*>(result_value);
    /*End< */

    if (!value_0) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_1) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 2. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_2) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 3. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_3) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 4. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    try {
      if (return_value) {
        return_value->setValue((__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue() ));
        if (method_return_value)
          method_return_value->setValue(return_value->getValue());
      } else {
        GLOBAL_WARNING_STREAM2("Warning : Return value of Event " << event.getKey() << "is not stored " << endl);
        if (method_return_value)
          method_return_value->setValue((__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue() ));
        else
          (__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue() );
      }

      if (method_return_value)
        return result_value->getValue();

      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }

  }


  template<class T, class U, class V, class W, class X, class Y>
  Result TEDObject4<T, U, V, W, X, Y, void>::dispatch(Event& event) {
    if (event.getArgSize() != 4){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 4. Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 4. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    if (!event.getValue(1)) {
      event.setValue(1, new TOutValue<V>());
    }

    if (!event.getValue(2)) {
      event.setValue(2, new TOutValue<W>());
    }

    if (!event.getValue(3)) {
      event.setValue(3, new TOutValue<X>());
    }

    TValue<U>* value_0 = dynamic_cast<TValue<U>*>(const_cast<Value*>(event.getValue(0)));
    TValue<V>* value_1 = dynamic_cast<TValue<V>*>(const_cast<Value*>(event.getValue(1)));
    TValue<W>* value_2 = dynamic_cast<TValue<W>*>(const_cast<Value*>(event.getValue(2)));
    TValue<X>* value_3 = dynamic_cast<TValue<X>*>(const_cast<Value*>(event.getValue(3)));

    if (!value_0) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_1) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 2. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_2) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 3. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_3) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 4. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    try {
      (__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue() );
      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }

  }




  template<class T, class U, class V, class W, class X, class A_5, class Y, class Z>
  Result TEDObject5<T, U, V, W, X, A_5, Y, Z>::dispatch(Event& event) {
    if (event.getArgSize() != 5){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 5. Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 5. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    if (!event.getValue(1)) {
      event.setValue(1, new TOutValue<V>());
    }

    if (!event.getValue(2)) {
      event.setValue(2, new TOutValue<W>());
    }

    if (!event.getValue(3)) {
      event.setValue(3, new TOutValue<X>());
    }

    if (!event.getValue(4)) {
      event.setValue(4, new TOutValue<A_5>());
    }

    if (!event.getReturnValue())
      event.setReturnValue(new TOutValue<Z>());


    TValue<U>* value_0 = dynamic_cast<TValue<U>*>(const_cast<Value*>(event.getValue(0)));
    TValue<V>* value_1 = dynamic_cast<TValue<V>*>(const_cast<Value*>(event.getValue(1)));
    TValue<W>* value_2 = dynamic_cast<TValue<W>*>(const_cast<Value*>(event.getValue(2)));
    TValue<X>* value_3 = dynamic_cast<TValue<X>*>(const_cast<Value*>(event.getValue(3)));
    TValue<A_5>* value_4 = dynamic_cast<TValue<A_5>*>(const_cast<Value*>(event.getValue(4)));

    TValue<Z>* return_value = dynamic_cast< TValue<Z>* >(const_cast<Value*>(event.getReturnValue()));

    /*Begin> Hack: If method's return value is result return the result*/
    TValue<Z>* method_return_value = 0;
    TValue<Result> tmp_value;
    TValue<Result>* result_value = &tmp_value; //hack to avoid warnings
    method_return_value = dynamic_cast<TValue<Z>*>(result_value);
    /*End< */

    if (!value_0) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_1) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 2. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_2) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 3. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_3) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 4. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_4) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 5. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }

    try {
      if (return_value) {
        return_value->setValue((__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue(), value_4->getRValue() ));
        if (method_return_value)
          method_return_value->setValue(return_value->getValue());
      } else {
        GLOBAL_WARNING_STREAM2("Warning : Return value of Event " << event.getKey() << "is not stored " << endl);
        if (method_return_value)
          method_return_value->setValue((__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue(), value_4->getRValue() ));
        else
          (__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue(), value_4->getRValue() );
      }

      if (method_return_value)
        return result_value->getValue();

      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }

  }




  template<class T, class U, class V, class W, class X, class A_5, class Y>
  Result TEDObject5<T, U, V, W, X, A_5, Y, void>::dispatch(Event& event) {
    if (event.getArgSize() != 5){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 5. Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 4. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    if (!event.getValue(1)) {
      event.setValue(1, new TOutValue<V>());
    }

    if (!event.getValue(2)) {
      event.setValue(2, new TOutValue<W>());
    }

    if (!event.getValue(3)) {
      event.setValue(3, new TOutValue<X>());
    }

    if (!event.getValue(4)) {
      event.setValue(4, new TOutValue<A_5>());
    }


    TValue<U>* value_0 = dynamic_cast<TValue<U>*>(const_cast<Value*>(event.getValue(0)));
    TValue<V>* value_1 = dynamic_cast<TValue<V>*>(const_cast<Value*>(event.getValue(1)));
    TValue<W>* value_2 = dynamic_cast<TValue<W>*>(const_cast<Value*>(event.getValue(2)));
    TValue<X>* value_3 = dynamic_cast<TValue<X>*>(const_cast<Value*>(event.getValue(3)));
    TValue<A_5>* value_4 = dynamic_cast<TValue<A_5>*>(const_cast<Value*>(event.getValue(4)));

    if (!value_0) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_1) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 2. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_2) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 3. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_3) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 4. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }

    if (!value_4) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 5. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }

    try {
      (__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue(), value_4->getRValue() );
      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }

  }







  template<class T, class U, class V, class W, class X, class A_5, class A_6, class Y, class Z>
  Result TEDObject6<T, U, V, W, X, A_5, A_6, Y, Z>::dispatch(Event& event) {
    if (event.getArgSize() != 6){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 6. Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 6. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    if (!event.getValue(1)) {
      event.setValue(1, new TOutValue<V>());
    }

    if (!event.getValue(2)) {
      event.setValue(2, new TOutValue<W>());
    }

    if (!event.getValue(3)) {
      event.setValue(3, new TOutValue<X>());
    }

    if (!event.getValue(4)) {
      event.setValue(4, new TOutValue<A_5>());
    }

    if (!event.getValue(5)) {
      event.setValue(5, new TOutValue<A_6>());
    }

    if (!event.getReturnValue())
      event.setReturnValue(new TOutValue<Z>());

    TValue<U>* value_0 = dynamic_cast<TValue<U>*>(const_cast<Value*>(event.getValue(0)));
    TValue<V>* value_1 = dynamic_cast<TValue<V>*>(const_cast<Value*>(event.getValue(1)));
    TValue<W>* value_2 = dynamic_cast<TValue<W>*>(const_cast<Value*>(event.getValue(2)));
    TValue<X>* value_3 = dynamic_cast<TValue<X>*>(const_cast<Value*>(event.getValue(3)));
    TValue<A_5>* value_4 = dynamic_cast<TValue<A_5>*>(const_cast<Value*>(event.getValue(4)));
    TValue<A_6>* value_5 = dynamic_cast<TValue<A_6>*>(const_cast<Value*>(event.getValue(5)));

    TValue<Z>* return_value = dynamic_cast< TValue<Z>* >(const_cast<Value*>(event.getReturnValue()));

    /*Begin> Hack: If method's return value is result return the result*/
    TValue<Z>* method_return_value = 0;
    TValue<Result> tmp_value;
    TValue<Result>* result_value = &tmp_value; //hack to avoid warnings
    method_return_value = dynamic_cast<TValue<Z>*>(result_value);
    /*End< */

    if (!value_0) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_1) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 2. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_2) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 3. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_3) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 4. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_4) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 5. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_5) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 6. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }

    try {
      if (return_value) {
        return_value->setValue((__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue(), value_4->getRValue(), value_5->getRValue() ));
        if (method_return_value)
          method_return_value->setValue(return_value->getValue());
      } else {
        GLOBAL_WARNING_STREAM2("Warning : Return value of Event " << event.getKey() << "is not stored " << endl);
        if (method_return_value)
          method_return_value->setValue((__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue(), value_4->getRValue(), value_5->getRValue() ));
        else
          (__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue(), value_4->getRValue(), value_5->getRValue() );
      }

      if (method_return_value)
        return result_value->getValue();

      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }

  }




  template<class T, class U, class V, class W, class X, class A_5, class A_6, class Y>
  Result TEDObject6<T, U, V, W, X, A_5, A_6, Y, void>::dispatch(Event& event) {
    if (event.getArgSize() != 6){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 6. Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 6. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    if (!event.getValue(1)) {
      event.setValue(1, new TOutValue<V>());
    }

    if (!event.getValue(2)) {
      event.setValue(2, new TOutValue<W>());
    }

    if (!event.getValue(3)) {
      event.setValue(3, new TOutValue<X>());
    }

    if (!event.getValue(4)) {
      event.setValue(4, new TOutValue<A_5>());
    }

    if (!event.getValue(5)) {
      event.setValue(5, new TOutValue<A_6>());
    }

    TValue<U>* value_0 = dynamic_cast<TValue<U>*>(const_cast<Value*>(event.getValue(0)));
    TValue<V>* value_1 = dynamic_cast<TValue<V>*>(const_cast<Value*>(event.getValue(1)));
    TValue<W>* value_2 = dynamic_cast<TValue<W>*>(const_cast<Value*>(event.getValue(2)));
    TValue<X>* value_3 = dynamic_cast<TValue<X>*>(const_cast<Value*>(event.getValue(3)));
    TValue<A_5>* value_4 = dynamic_cast<TValue<A_5>*>(const_cast<Value*>(event.getValue(4)));
    TValue<A_6>* value_5 = dynamic_cast<TValue<A_6>*>(const_cast<Value*>(event.getValue(5)));

    if (!value_0) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_1) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 2. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_2) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 3. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_3) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 4. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_4) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 5. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_5) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 6. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }

    try {
      (__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue(), value_4->getRValue(), value_5->getRValue() );
      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }

  }




  template<class T, class U, class V, class W, class X, class A_5, class A_6, class A_7, class Y, class Z>
  Result TEDObject7<T, U, V, W, X, A_5, A_6, A_7, Y, Z>::dispatch(Event& event) {
    if (event.getArgSize() != 7){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 7. Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 7. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    if (!event.getValue(1)) {
      event.setValue(1, new TOutValue<V>());
    }

    if (!event.getValue(2)) {
      event.setValue(2, new TOutValue<W>());
    }

    if (!event.getValue(3)) {
      event.setValue(3, new TOutValue<X>());
    }

    if (!event.getValue(4)) {
      event.setValue(4, new TOutValue<A_5>());
    }

    if (!event.getValue(5)) {
      event.setValue(5, new TOutValue<A_6>());
    }
    if (!event.getValue(6)) {
      event.setValue(6, new TOutValue<A_7>());
    }

    if (!event.getReturnValue())
      event.setReturnValue(new TOutValue<Z>());

    TValue<U>* value_0 = dynamic_cast<TValue<U>*>(const_cast<Value*>(event.getValue(0)));
    TValue<V>* value_1 = dynamic_cast<TValue<V>*>(const_cast<Value*>(event.getValue(1)));
    TValue<W>* value_2 = dynamic_cast<TValue<W>*>(const_cast<Value*>(event.getValue(2)));
    TValue<X>* value_3 = dynamic_cast<TValue<X>*>(const_cast<Value*>(event.getValue(3)));
    TValue<A_5>* value_4 = dynamic_cast<TValue<A_5>*>(const_cast<Value*>(event.getValue(4)));
    TValue<A_6>* value_5 = dynamic_cast<TValue<A_6>*>(const_cast<Value*>(event.getValue(5)));
    TValue<A_7>* value_6 = dynamic_cast<TValue<A_7>*>(const_cast<Value*>(event.getValue(6)));

    TValue<Z>* return_value = dynamic_cast< TValue<Z>* >(const_cast<Value*>(event.getReturnValue()));

    /*Begin> Hack: If method's return value is result return the result*/
    TValue<Z>* method_return_value = 0;
    TValue<Result> tmp_value;
    TValue<Result>* result_value = &tmp_value; //hack to avoid warnings
    method_return_value = dynamic_cast<TValue<Z>*>(result_value);
    /*End< */

    if (!value_0) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_1) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 2. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_2) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 3. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_3) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 4. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_4) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 5. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_5) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 6. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_6) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 7. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }

    try {
      if (return_value) {
        return_value->setValue((__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue(), value_4->getRValue(), value_5->getRValue(), value_6->getRValue() ));
        if (method_return_value)
          method_return_value->setValue(return_value->getValue());
      } else {
        GLOBAL_WARNING_STREAM2("Warning : Return value of Event " << event.getKey() << "is not stored " << endl);
        if (method_return_value)
          method_return_value->setValue((__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue(), value_4->getRValue(), value_5->getRValue(), value_6->getRValue() ));
        else
          (__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue(), value_4->getRValue(), value_5->getRValue(), value_6->getRValue() );
      }

      if (method_return_value)
        return result_value->getValue();

      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }

  }




  template<class T, class U, class V, class W, class X, class A_5, class A_6, class A_7, class Y>
  Result TEDObject7<T, U, V, W, X, A_5, A_6, A_7, Y, void>::dispatch(Event& event) {
    if (event.getArgSize() != 7){
      GLOBAL_ERROR_STREAM2("Warning : Expected Arg size 7. Wrong argumentsize " << event.getArgSize() <<  endl);
      event.setException(UnexpectedException("Invalid argumentsize. Expected argumentsize 7. Event has argumentsize " + event.getArgSize()));
      return FAILURE;
    }

    /* Begin> Create the values if they are not set*/
    if (!event.getValue(0)) {
      event.setValue(0, new TOutValue<U>());
    }

    if (!event.getValue(1)) {
      event.setValue(1, new TOutValue<V>());
    }

    if (!event.getValue(2)) {
      event.setValue(2, new TOutValue<W>());
    }

    if (!event.getValue(3)) {
      event.setValue(3, new TOutValue<X>());
    }

    if (!event.getValue(4)) {
      event.setValue(4, new TOutValue<A_5>());
    }

    if (!event.getValue(5)) {
      event.setValue(5, new TOutValue<A_6>());
    }

    if (!event.getValue(6)) {
      event.setValue(6, new TOutValue<A_7>());
    }

    TValue<U>* value_0 = dynamic_cast<TValue<U>*>(const_cast<Value*>(event.getValue(0)));
    TValue<V>* value_1 = dynamic_cast<TValue<V>*>(const_cast<Value*>(event.getValue(1)));
    TValue<W>* value_2 = dynamic_cast<TValue<W>*>(const_cast<Value*>(event.getValue(2)));
    TValue<X>* value_3 = dynamic_cast<TValue<X>*>(const_cast<Value*>(event.getValue(3)));
    TValue<A_5>* value_4 = dynamic_cast<TValue<A_5>*>(const_cast<Value*>(event.getValue(4)));
    TValue<A_6>* value_5 = dynamic_cast<TValue<A_6>*>(const_cast<Value*>(event.getValue(5)));
    TValue<A_7>* value_6 = dynamic_cast<TValue<A_7>*>(const_cast<Value*>(event.getValue(6)));

    if (!value_0) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 1. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_1) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 2. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_2) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 3. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_3) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 4. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_4) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 5. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_5) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 6. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }
    if (!value_6) {
      GLOBAL_ERROR_STREAM2("Dynamic cast of Event " << event.getKey() << " Failed." << endl);
      event.setException(UnexpectedException("Dynamic cast of 7. argument in event " + event.getKey() +" failed"));
      return FAILURE;
    }

    try {
      (__object->*__method)( value_0->getRValue(), value_1->getRValue(), value_2->getRValue(), value_3->getRValue(), value_4->getRValue(), value_5->getRValue(), value_6->getRValue() );
      return SUCCESS;
    } catch (const SerializedException& exception) {
      event.setException(exception);
      return FAILURE;
    } catch (const Exception& exception) {
      event.setException(UnexpectedException(exception.getComment()));
      return FAILURE;
    } catch (...) {
      event.setException(UnexpectedException());
      return FAILURE;
    }

  }
  
}

#include "nmm/nmm_suffix.hpp"

#endif
