// Generated by gmmproc 2.40.0 -- DO NOT MODIFY!


#include <glibmm.h>

#include <libgdamm/column.h>
#include <libgdamm/private/column_p.h>


/* $Id: column.ccg,v 1.5 2006/11/06 23:38:35 murrayc Exp $ */
// -*- C++ -*- // this is for the .ccg, I realize gensig puts one in

/* datamodel.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 <libgda/gda-column.h>
#include <libgda/gda-enum-types.h>

namespace Gnome
{

namespace Gda
{

bool Column::equal(const Glib::RefPtr<const Column>& src) const
{
  if(!src)
    return false;

  const bool result = get_description() == src->get_description() &&
                get_name() == src->get_name() &&
                get_dbms_type() == src->get_dbms_type() &&
                get_g_type() == src->get_g_type() &&
                get_allow_null() == src->get_allow_null() &&
                get_auto_increment() == src->get_auto_increment() &&
                get_position() == src->get_position() &&
                get_default_value() == src->get_default_value();

  return result;
}


static void on_set_attribute_destroy(gpointer data)
{
  g_free((char*)data);
}

void Column::set_attribute(const Glib::ustring& attribute, const Value& value)
{
  //gda_column_set_attribute() has stupid memory management.
  //See http://bugzilla.gnome.org/show_bug.cgi?id=564402
  gchar* dup = g_strdup(attribute.c_str());
  gda_column_set_attribute(gobj(), dup, (value).gobj(), &on_set_attribute_destroy); 
}


} // namespace Gda

} // namespace Gnome


namespace
{


static void Column_signal_name_changed_callback(GdaColumn* self, const gchar* p0,void* data)
{
  using namespace Gnome::Gda;
  typedef sigc::slot< void,const Glib::ustring& > 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::convert_const_gchar_ptr_to_ustring(p0)
);
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }
}

static const Glib::SignalProxyInfo Column_signal_name_changed_info =
{
  "name-changed",
  (GCallback) &Column_signal_name_changed_callback,
  (GCallback) &Column_signal_name_changed_callback
};


static void Column_signal_g_type_changed_callback(GdaColumn* self, GType p0,GType p1,void* data)
{
  using namespace Gnome::Gda;
  typedef sigc::slot< void,GType,GType > 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))(p0, p1);
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
      Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }
}

static const Glib::SignalProxyInfo Column_signal_g_type_changed_info =
{
  "g-type-changed",
  (GCallback) &Column_signal_g_type_changed_callback,
  (GCallback) &Column_signal_g_type_changed_callback
};


} // anonymous namespace


namespace Glib
{

Glib::RefPtr<Gnome::Gda::Column> wrap(GdaColumn* object, bool take_copy)
{
  return Glib::RefPtr<Gnome::Gda::Column>( dynamic_cast<Gnome::Gda::Column*> (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& Column_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_ = &Column_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_column_get_type());

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

  }

  return *this;
}


void Column_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->name_changed = &name_changed_callback;
  klass->g_type_changed = &g_type_changed_callback;
}


void Column_Class::name_changed_callback(GdaColumn* self, const gchar* 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_name_changed(Glib::convert_const_gchar_ptr_to_ustring(p0)
);
        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->name_changed)
    (*base->name_changed)(self, p0);
}
void Column_Class::g_type_changed_callback(GdaColumn* self, GType p0, GType p1)
{
  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_g_type_changed(p0, p1);
        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->g_type_changed)
    (*base->g_type_changed)(self, p0, p1);
}


Glib::ObjectBase* Column_Class::wrap_new(GObject* object)
{
  return new Column((GdaColumn*)object);
}


/* The implementation: */

GdaColumn* Column::gobj_copy()
{
  reference();
  return gobj();
}

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

}

Column::Column(GdaColumn* castitem)
:
  Glib::Object((GObject*)(castitem))
{}


Column::~Column()
{}


Column::CppClassType Column::column_class_; // initialize static member

GType Column::get_type()
{
  return column_class_.init().get_type();
}


GType Column::get_base_type()
{
  return gda_column_get_type();
}


Column::Column()
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Glib::Object(Glib::ConstructParams(column_class_.init()))
{
  

}

Glib::RefPtr<Column> Column::create()
{
  return Glib::RefPtr<Column>( new Column() );
}

Glib::RefPtr<Column> Column::copy() const
{
  return Glib::wrap(gda_column_copy(const_cast<GdaColumn*>(gobj())));
}

Glib::ustring Column::get_description() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gda_column_get_description(const_cast<GdaColumn*>(gobj())));
}

void Column::set_description(const Glib::ustring& title)
{
  gda_column_set_description(gobj(), title.c_str());
}

Value Column::get_attribute(const Glib::ustring& attribute) const
{
  return Value(gda_column_get_attribute(const_cast<GdaColumn*>(gobj()), attribute.c_str()));
}

Glib::ustring Column::get_name() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gda_column_get_name(const_cast<GdaColumn*>(gobj())));
}

void Column::set_name(const Glib::ustring& name)
{
  gda_column_set_name(gobj(), name.c_str());
}

Glib::ustring Column::get_dbms_type() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gda_column_get_dbms_type(const_cast<GdaColumn*>(gobj())));
}

void Column::set_dbms_type(const Glib::ustring& dbms_type)
{
  gda_column_set_dbms_type(gobj(), dbms_type.c_str());
}

GType Column::get_g_type() const
{
  return gda_column_get_g_type(const_cast<GdaColumn*>(gobj()));
}

void Column::set_g_type(GType type)
{
  gda_column_set_g_type(gobj(), type);
}

bool Column::get_allow_null() const
{
  return gda_column_get_allow_null(const_cast<GdaColumn*>(gobj()));
}

void Column::set_allow_null(bool allow)
{
  gda_column_set_allow_null(gobj(), static_cast<int>(allow));
}

bool Column::get_auto_increment() const
{
  return gda_column_get_auto_increment(const_cast<GdaColumn*>(gobj()));
}

void Column::set_auto_increment(bool is_auto)
{
  gda_column_set_auto_increment(gobj(), static_cast<int>(is_auto));
}

gint Column::get_position() const
{
  return gda_column_get_position(const_cast<GdaColumn*>(gobj()));
}

void Column::set_position(gint position)
{
  gda_column_set_position(gobj(), position);
}

Value Column::get_default_value() const
{
  return Value(gda_column_get_default_value(const_cast<GdaColumn*>(gobj())));
}

void Column::set_default_value(const Value& default_value)
{
  gda_column_set_default_value(gobj(), (default_value).gobj());
}


Glib::SignalProxy1< void,const Glib::ustring& > Column::signal_name_changed()
{
  return Glib::SignalProxy1< void,const Glib::ustring& >(this, &Column_signal_name_changed_info);
}


Glib::SignalProxy2< void,GType,GType > Column::signal_g_type_changed()
{
  return Glib::SignalProxy2< void,GType,GType >(this, &Column_signal_g_type_changed_info);
}


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

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


void Gnome::Gda::Column::on_name_changed(const Glib::ustring& old_name)
{
  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->name_changed)
    (*base->name_changed)(gobj(),old_name.c_str());
}
void Gnome::Gda::Column::on_g_type_changed(GType old_type, GType new_type)
{
  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->g_type_changed)
    (*base->g_type_changed)(gobj(),old_type,new_type);
}


} // namespace Gda

} // namespace Gnome


