// Generated by gtkmmproc -- DO NOT MODIFY!


#include <libgdamm/set.h>
#include <libgdamm/private/set_p.h>

// -*- C++ -*- // this is for the .ccg, I realize gensig puts one in

/* set.cc
 * 
 * Copyright 2003 libgdamm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <libgdamm/set.h>
#include <libgdamm/datamodel.h>
#include <libgda/gda-set.h>

namespace Gnome
{

namespace Gda
{

template<class T>
bool Set::set_holder_value(const Glib::ustring& id, T value)
{
  return gda_set_set_holder_value (gobj(), id.c_str(), value);
}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
void Set::add_holder_as_value(const Glib::ustring& id, const Gda::Value& value)
#else
void Set::add_holder_as_value(const Glib::ustring& id, const Gda::Value& value, std::auto_ptr<Glib::Error>& error)
#endif
{
  Glib::RefPtr<Holder> holder = Holder::create(value.get_value_type(), id);
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  holder->set_value(value);
#else
  holder->set_value(value, error);
#endif
  add_holder(holder);
}

} /* namespace Gda */

} /* namespace Gnome */


namespace
{


static void Set_signal_holder_changed_callback(GdaSet* self, GdaHolder* p0,void* data)
{
  using namespace Gnome::Gda;
  typedef sigc::slot< void,const Glib::RefPtr<Holder>& > SlotType;

  // Do not try to call a signal on a disassociated wrapper.
  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true /* take_copy */)
);
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }
}

static const Glib::SignalProxyInfo Set_signal_holder_changed_info =
{
  "holder-changed",
  (GCallback) &Set_signal_holder_changed_callback,
  (GCallback) &Set_signal_holder_changed_callback
};


static const Glib::SignalProxyInfo Set_signal_public_data_changed_info =
{
  "public-data-changed",
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
};


static GError* Set_signal_validate_set_callback(GdaSet* self, void* data)
{
  using namespace Gnome::Gda;
  typedef sigc::slot< Glib::Error > SlotType;

  // Do not try to call a signal on a disassociated wrapper.
  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        return ((*static_cast<SlotType*>(slot))()).gobj();
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }

  typedef GError* RType;
  return RType();
}

static GError* Set_signal_validate_set_notify_callback(GdaSet* self,  void* data)
{
  using namespace Gnome::Gda;
  typedef sigc::slot< void > SlotType;

  // Do not try to call a signal on a disassociated wrapper.
  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))();
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }

  typedef GError* RType;
  return RType();
}

static const Glib::SignalProxyInfo Set_signal_validate_set_info =
{
  "validate-set",
  (GCallback) &Set_signal_validate_set_callback,
  (GCallback) &Set_signal_validate_set_notify_callback
};


static GError* Set_signal_validate_holder_change_callback(GdaSet* self, GdaHolder* p0,GValue* p1,void* data)
{
  using namespace Gnome::Gda;
  typedef sigc::slot< Glib::Error,const Glib::RefPtr<Holder>&,const Value& > SlotType;

  // Do not try to call a signal on a disassociated wrapper.
  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        return ((*static_cast<SlotType*>(slot))(Glib::wrap(p0, true /* take_copy */)
, Value(p1)
)).gobj();
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }

  typedef GError* RType;
  return RType();
}

static GError* Set_signal_validate_holder_change_notify_callback(GdaSet* self, GdaHolder* p0,GValue* p1, void* data)
{
  using namespace Gnome::Gda;
  typedef sigc::slot< void,const Glib::RefPtr<Holder>&,const Value& > SlotType;

  // Do not try to call a signal on a disassociated wrapper.
  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true /* take_copy */)
, Value(p1)
);
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }

  typedef GError* RType;
  return RType();
}

static const Glib::SignalProxyInfo Set_signal_validate_holder_change_info =
{
  "validate-holder-change",
  (GCallback) &Set_signal_validate_holder_change_callback,
  (GCallback) &Set_signal_validate_holder_change_notify_callback
};


static void Set_signal_holder_attr_changed_callback(GdaSet* self, GdaHolder* p0,const gchar* p1,GValue* p2,void* data)
{
  using namespace Gnome::Gda;
  typedef sigc::slot< void,const Glib::RefPtr<Holder>&,const Glib::ustring&,Value > SlotType;

  // Do not try to call a signal on a disassociated wrapper.
  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true /* take_copy */)
, Glib::convert_const_gchar_ptr_to_ustring(p1)
, Value(p2)
);
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }
}

static const Glib::SignalProxyInfo Set_signal_holder_attr_changed_info =
{
  "holder-attr-changed",
  (GCallback) &Set_signal_holder_attr_changed_callback,
  (GCallback) &Set_signal_holder_attr_changed_callback
};


} // anonymous namespace


namespace Glib
{

Glib::RefPtr<Gnome::Gda::Set> wrap(GdaSet* object, bool take_copy)
{
  return Glib::RefPtr<Gnome::Gda::Set>( dynamic_cast<Gnome::Gda::Set*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
  //We use dynamic_cast<> in case of multiple inheritance.
}

} /* namespace Glib */


namespace Gnome
{

namespace Gda
{


/* The *_Class implementation: */

const Glib::Class& Set_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Class has to know the class init function to clone custom types.
    class_init_func_ = &Set_Class::class_init_function;

    // This is actually just optimized away, apparently with no harm.
    // Make sure that the parent type has been created.
    //CppClassParent::CppObjectType::get_type();

    // Create the wrapper type, with the same class/instance size as the base type.
    register_derived_type(gda_set_get_type());

    // Add derived versions of interfaces, if the C type implements any interfaces:

  }

  return *this;
}


void Set_Class::class_init_function(void* g_class, void* class_data)
{
  BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
  CppClassParent::class_init_function(klass, class_data);


  klass->holder_changed = &holder_changed_callback;
  klass->public_data_changed = &public_data_changed_callback;
}


void Set_Class::holder_changed_callback(GdaSet* self, GdaHolder* p0)
{
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        // Call the virtual member method, which derived classes might override.
        obj->on_holder_changed(Glib::wrap(p0, true /* take_copy */)
);
        return;
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
        g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
    );

  // Call the original underlying C function:
  if(base && base->holder_changed)
    (*base->holder_changed)(self, p0);
}
void Set_Class::public_data_changed_callback(GdaSet* self)
{
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        // Call the virtual member method, which derived classes might override.
        obj->on_public_data_changed();
        return;
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
        g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
    );

  // Call the original underlying C function:
  if(base && base->public_data_changed)
    (*base->public_data_changed)(self);
}


Glib::ObjectBase* Set_Class::wrap_new(GObject* object)
{
  return new Set((GdaSet*)object);
}


/* The implementation: */

GdaSet* Set::gobj_copy()
{
  reference();
  return gobj();
}

Set::Set(const Glib::ConstructParams& construct_params)
:
  Glib::Object(construct_params)
{

}

Set::Set(GdaSet* castitem)
:
  Glib::Object((GObject*)(castitem))
{}


Set::~Set()
{}


Set::CppClassType Set::set_class_; // initialize static member

GType Set::get_type()
{
  return set_class_.init().get_type();
}


GType Set::get_base_type()
{
  return gda_set_get_type();
}


Set::Set(const HolderVector& holders)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Glib::Object(Glib::ConstructParams(set_class_.init(), "holders", Glib::SListHandler<  Glib::RefPtr<Holder> >::vector_to_slist(holders).data(), static_cast<char*>(0)))
{
  

}

Glib::RefPtr<Set> Set::create(const HolderVector& holders)
{
  return Glib::RefPtr<Set>( new Set(holders) );
}

Glib::RefPtr<Set> Set::copy()
{
  return Glib::wrap(gda_set_copy(gobj()));
}

Value Set::get_holder_value(const Glib::ustring& holder_id) const
{
  return Value(gda_set_get_holder_value(const_cast<GdaSet*>(gobj()), holder_id.c_str()));
}

Glib::RefPtr<Holder> Set::get_holder(const Glib::ustring& holder_id)
{

  Glib::RefPtr<Holder> retvalue = Glib::wrap(gda_set_get_holder(gobj(), holder_id.c_str()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;

}

Glib::RefPtr<const Holder> Set::get_holder(const Glib::ustring& holder_id) const
{

  Glib::RefPtr<const Holder> retvalue = Glib::wrap(gda_set_get_holder(const_cast<GdaSet*>(gobj()), holder_id.c_str()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;

}

void Set::add_holder(const Glib::RefPtr<Holder>& holder)
{
gda_set_add_holder(gobj(), Glib::unwrap(holder)); 
}

void Set::remove_holder(const Glib::RefPtr<Holder>& holder)
{
gda_set_remove_holder(gobj(), Glib::unwrap(holder)); 
}

void Set::merge_with_set(const Glib::RefPtr<Set>& set_to_merge)
{
gda_set_merge_with_set(gobj(), Glib::unwrap(set_to_merge)); 
}

bool Set::is_valid() const
{
  GError* gerror = 0;
  bool retvalue = gda_set_is_valid(const_cast<GdaSet*>(gobj()), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  return retvalue;

}


Glib::SignalProxy1< void,const Glib::RefPtr<Holder>& > Set::signal_holder_changed()
{
  return Glib::SignalProxy1< void,const Glib::RefPtr<Holder>& >(this, &Set_signal_holder_changed_info);
}


Glib::SignalProxy0< void > Set::signal_public_data_changed()
{
  return Glib::SignalProxy0< void >(this, &Set_signal_public_data_changed_info);
}


Glib::SignalProxy0< Glib::Error > Set::signal_validate_set()
{
  return Glib::SignalProxy0< Glib::Error >(this, &Set_signal_validate_set_info);
}


Glib::SignalProxy2< Glib::Error,const Glib::RefPtr<Holder>&,const Value& > Set::signal_validate_holder_change()
{
  return Glib::SignalProxy2< Glib::Error,const Glib::RefPtr<Holder>&,const Value& >(this, &Set_signal_validate_holder_change_info);
}


Glib::SignalProxy3< void,const Glib::RefPtr<Holder>&,const Glib::ustring&,Value > Set::signal_holder_attr_changed()
{
  return Glib::SignalProxy3< void,const Glib::RefPtr<Holder>&,const Glib::ustring&,Value >(this, &Set_signal_holder_attr_changed_info);
}


#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy<Glib::ustring> Set::property_description() 
{
  return Glib::PropertyProxy<Glib::ustring>(this, "description");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly<Glib::ustring> Set::property_description() const
{
  return Glib::PropertyProxy_ReadOnly<Glib::ustring>(this, "description");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy<Glib::ustring> Set::property_id() 
{
  return Glib::PropertyProxy<Glib::ustring>(this, "id");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly<Glib::ustring> Set::property_id() const
{
  return Glib::PropertyProxy_ReadOnly<Glib::ustring>(this, "id");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy<Glib::ustring> Set::property_name() 
{
  return Glib::PropertyProxy<Glib::ustring>(this, "name");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly<Glib::ustring> Set::property_name() const
{
  return Glib::PropertyProxy_ReadOnly<Glib::ustring>(this, "name");
}
#endif //GLIBMM_PROPERTIES_ENABLED


void Gnome::Gda::Set::on_holder_changed(const Glib::RefPtr<Holder>& holder)
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->holder_changed)
    (*base->holder_changed)(gobj(),Glib::unwrap(holder));
}
void Gnome::Gda::Set::on_public_data_changed()
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->public_data_changed)
    (*base->public_data_changed)(gobj());
}


} // namespace Gda

} // namespace Gnome


