// -*- c++ -*-
/* This is a generated file, do not edit.  Generated from signalproxy.h.m4 */

#ifndef _GLIBMM_SIGNALPROXY_H
#define _GLIBMM_SIGNALPROXY_H

extern "C"
{
  typedef void (*GCallback) (void);
  typedef struct _GObject GObject;
}

#include <sigc++/sigc++.h>


namespace Glib
{

// Forward declarations
class ObjectBase;

#ifndef DOXYGEN_SHOULD_SKIP_THIS

struct SignalProxyInfo
{
  const char* signal_name;
  GCallback   callback;
  GCallback   notify_callback;
};

#endif //DOXYGEN_SHOULD_SKIP_THIS

// This base class is used by SignalProxyNormal and SignalProxyProperty.
class SignalProxyBase
{
public:
  SignalProxyBase(Glib::ObjectBase* obj);

#ifndef DOXYGEN_SHOULD_SKIP_THIS
  static inline SigC::SlotNode* data_to_slot(void* data)
  {
    // We store a ProxyConnection_ on the data slot of the closure.
    // But that type is not exposed, so we use the base type.
    SigC::ConnectionNode *const conn = static_cast<SigC::ConnectionNode*>(data);

    // Return 0 if the connection is blocked.
    return (!conn->blocked()) ? static_cast<SigC::SlotNode*>(conn->slot_.impl()) : 0;
  }
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

protected:
  ObjectBase* obj_;

private:
  SignalProxyBase& operator=(const SignalProxyBase&); // not implemented
};


// shared portion of a Signal
//   The proxy just serves to hold the name of the signal and the object
//   which is to be connected.  Actually, proxies are controlled by
//   the template derivatives, which serve as gatekeepers for the
//   types allowed on a particular signal.
class SignalProxyNormal : public SignalProxyBase
{
public:
  ~SignalProxyNormal();

  /// stops the current signal emmision (not in SigC++)
  void emission_stop();

#ifndef DOXYGEN_SHOULD_SKIP_THIS
  // This callback for SignalProxy0<void>
  // is defined here to avoid code duplication.
  static void slot0_void_callback(GObject*, void* data);
#endif

protected:
  SignalProxyNormal(Glib::ObjectBase* obj, const SignalProxyInfo* info);

  SigC::ConnectionNode* connect_(const SigC::SlotBase& slot_base, bool after);
  SigC::ConnectionNode* connect_notify_(const SigC::SlotBase& slot_base, bool after);

private:
  const SignalProxyInfo* info_;

  SigC::ConnectionNode* connect_impl_(GCallback callback, const SigC::SlotBase& slot_base, bool after);

  // no copy assignment
  SignalProxyNormal& operator=(const SignalProxyNormal&);
};





/**** Glib::SignalProxy0 ***************************************************/

/** Proxy for signals with 0 arguments.
 * Use the connect() method, with SigC::slot() to connect signals to signal handlers.
 */
template <class R>
class SignalProxy0 : public SignalProxyNormal
{
public:
  typedef SigC::Slot0<R>    SlotType;
  typedef SigC::Slot0<void> VoidSlotType;

  SignalProxy0(ObjectBase* obj, const SignalProxyInfo* info)
    : SignalProxyNormal(obj, info) {}

  SigC::Connection connect(const SlotType& slot, bool after = true)
    { return SigC::Connection(connect_(slot, after)); }

  SigC::Connection connect_notify(const VoidSlotType& slot, bool after = false)
    { return SigC::Connection(connect_notify_(slot, after)); }
};


/**** Glib::SignalProxy1 ***************************************************/

/** Proxy for signals with 1 arguments.
 * Use the connect() method, with SigC::slot() to connect signals to signal handlers.
 */
template <class R,class P1>
class SignalProxy1 : public SignalProxyNormal
{
public:
  typedef SigC::Slot1<R,P1>    SlotType;
  typedef SigC::Slot1<void,P1> VoidSlotType;

  SignalProxy1(ObjectBase* obj, const SignalProxyInfo* info)
    : SignalProxyNormal(obj, info) {}

  SigC::Connection connect(const SlotType& slot, bool after = true)
    { return SigC::Connection(connect_(slot, after)); }

  SigC::Connection connect_notify(const VoidSlotType& slot, bool after = false)
    { return SigC::Connection(connect_notify_(slot, after)); }
};


/**** Glib::SignalProxy2 ***************************************************/

/** Proxy for signals with 2 arguments.
 * Use the connect() method, with SigC::slot() to connect signals to signal handlers.
 */
template <class R,class P1,class P2>
class SignalProxy2 : public SignalProxyNormal
{
public:
  typedef SigC::Slot2<R,P1,P2>    SlotType;
  typedef SigC::Slot2<void,P1,P2> VoidSlotType;

  SignalProxy2(ObjectBase* obj, const SignalProxyInfo* info)
    : SignalProxyNormal(obj, info) {}

  SigC::Connection connect(const SlotType& slot, bool after = true)
    { return SigC::Connection(connect_(slot, after)); }

  SigC::Connection connect_notify(const VoidSlotType& slot, bool after = false)
    { return SigC::Connection(connect_notify_(slot, after)); }
};


/**** Glib::SignalProxy3 ***************************************************/

/** Proxy for signals with 3 arguments.
 * Use the connect() method, with SigC::slot() to connect signals to signal handlers.
 */
template <class R,class P1,class P2,class P3>
class SignalProxy3 : public SignalProxyNormal
{
public:
  typedef SigC::Slot3<R,P1,P2,P3>    SlotType;
  typedef SigC::Slot3<void,P1,P2,P3> VoidSlotType;

  SignalProxy3(ObjectBase* obj, const SignalProxyInfo* info)
    : SignalProxyNormal(obj, info) {}

  SigC::Connection connect(const SlotType& slot, bool after = true)
    { return SigC::Connection(connect_(slot, after)); }

  SigC::Connection connect_notify(const VoidSlotType& slot, bool after = false)
    { return SigC::Connection(connect_notify_(slot, after)); }
};


/**** Glib::SignalProxy4 ***************************************************/

/** Proxy for signals with 4 arguments.
 * Use the connect() method, with SigC::slot() to connect signals to signal handlers.
 */
template <class R,class P1,class P2,class P3,class P4>
class SignalProxy4 : public SignalProxyNormal
{
public:
  typedef SigC::Slot4<R,P1,P2,P3,P4>    SlotType;
  typedef SigC::Slot4<void,P1,P2,P3,P4> VoidSlotType;

  SignalProxy4(ObjectBase* obj, const SignalProxyInfo* info)
    : SignalProxyNormal(obj, info) {}

  SigC::Connection connect(const SlotType& slot, bool after = true)
    { return SigC::Connection(connect_(slot, after)); }

  SigC::Connection connect_notify(const VoidSlotType& slot, bool after = false)
    { return SigC::Connection(connect_notify_(slot, after)); }
};


/**** Glib::SignalProxy5 ***************************************************/

/** Proxy for signals with 5 arguments.
 * Use the connect() method, with SigC::slot() to connect signals to signal handlers.
 */
template <class R,class P1,class P2,class P3,class P4,class P5>
class SignalProxy5 : public SignalProxyNormal
{
public:
  typedef SigC::Slot5<R,P1,P2,P3,P4,P5>    SlotType;
  typedef SigC::Slot5<void,P1,P2,P3,P4,P5> VoidSlotType;

  SignalProxy5(ObjectBase* obj, const SignalProxyInfo* info)
    : SignalProxyNormal(obj, info) {}

  SigC::Connection connect(const SlotType& slot, bool after = true)
    { return SigC::Connection(connect_(slot, after)); }

  SigC::Connection connect_notify(const VoidSlotType& slot, bool after = false)
    { return SigC::Connection(connect_notify_(slot, after)); }
};


/**** Glib::SignalProxy6 ***************************************************/

/** Proxy for signals with 6 arguments.
 * Use the connect() method, with SigC::slot() to connect signals to signal handlers.
 */
template <class R,class P1,class P2,class P3,class P4,class P5,class P6>
class SignalProxy6 : public SignalProxyNormal
{
public:
  typedef SigC::Slot6<R,P1,P2,P3,P4,P5,P6>    SlotType;
  typedef SigC::Slot6<void,P1,P2,P3,P4,P5,P6> VoidSlotType;

  SignalProxy6(ObjectBase* obj, const SignalProxyInfo* info)
    : SignalProxyNormal(obj, info) {}

  SigC::Connection connect(const SlotType& slot, bool after = true)
    { return SigC::Connection(connect_(slot, after)); }

  SigC::Connection connect_notify(const VoidSlotType& slot, bool after = false)
    { return SigC::Connection(connect_notify_(slot, after)); }
};


} // namespace Glib


#endif /* _GLIBMM_SIGNALPROXY_H */

