// Generated by gtkmmproc -- DO NOT MODIFY!


#include <libgdamm/datamodeliter.h>
#include <libgdamm/private/datamodeliter_p.h>

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

/* datamodeliter.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 Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library 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-data-model-iter.h>
#include <libgda/gda-enum-types.h>
#include <libgdamm/datamodel.h>

namespace Gnome
{

namespace Gda
{

} /* namespace Gda */

} /* namespace Gnome */


namespace
{


static const Glib::SignalProxyInfo DataModelIter_signal_end_of_data_info =
{
  "end-of-data",
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
};


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

static const Glib::SignalProxyInfo DataModelIter_signal_row_changed_info =
{
  "row-changed",
  (GCallback) &DataModelIter_signal_row_changed_callback,
  (GCallback) &DataModelIter_signal_row_changed_callback
};


} // anonymous namespace


Gnome::Gda::DataModelIterError::DataModelIterError(Gnome::Gda::DataModelIterError::Code error_code, const Glib::ustring& error_message)
:
  Glib::Error (GDA_DATA_MODEL_ITER_ERROR, error_code, error_message)
{}

Gnome::Gda::DataModelIterError::DataModelIterError(GError* gobject)
:
  Glib::Error (gobject)
{}

Gnome::Gda::DataModelIterError::Code Gnome::Gda::DataModelIterError::code() const
{
  return static_cast<Code>(Glib::Error::code());
}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
void Gnome::Gda::DataModelIterError::throw_func(GError* gobject)
{
  throw Gnome::Gda::DataModelIterError(gobject);
}
#else
//When not using exceptions, we just pass the Exception object around without throwing it:
std::auto_ptr<Glib::Error> Gnome::Gda::DataModelIterError::throw_func(GError* gobject)
{
  return std::auto_ptr<Glib::Error>(new Gnome::Gda::DataModelIterError(gobject));
}
#endif //GLIBMM_EXCEPTIONS_ENABLED

// static
GType Glib::Value<Gnome::Gda::DataModelIterError::Code>::value_type()
{
  return gda_data_model_iter_error_get_type();
}


namespace Glib
{

Glib::RefPtr<Gnome::Gda::DataModelIter> wrap(GdaDataModelIter* object, bool take_copy)
{
  return Glib::RefPtr<Gnome::Gda::DataModelIter>( dynamic_cast<Gnome::Gda::DataModelIter*> (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& DataModelIter_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_ = &DataModelIter_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_data_model_iter_get_type());

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

  }

  return *this;
}

void DataModelIter_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);

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
  klass->end_of_data = &end_of_data_callback;
  klass->row_changed = &row_changed_callback;
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
}

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
void DataModelIter_Class::end_of_data_callback(GdaDataModelIter* 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_end_of_data();
        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->end_of_data)
    (*base->end_of_data)(self);
}
void DataModelIter_Class::row_changed_callback(GdaDataModelIter* self, gint 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_row_changed(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->row_changed)
    (*base->row_changed)(self, p0);
}
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED


Glib::ObjectBase* DataModelIter_Class::wrap_new(GObject* object)
{
  return new DataModelIter((GdaDataModelIter*)object);
}


/* The implementation: */

GdaDataModelIter* DataModelIter::gobj_copy()
{
  reference();
  return gobj();
}

DataModelIter::DataModelIter(const Glib::ConstructParams& construct_params)
:
  ParameterList(construct_params)
{

}

DataModelIter::DataModelIter(GdaDataModelIter* castitem)
:
  ParameterList((GdaParameterList*)(castitem))
{}

DataModelIter::~DataModelIter()
{}


DataModelIter::CppClassType DataModelIter::datamodeliter_class_; // initialize static member

GType DataModelIter::get_type()
{
  return datamodeliter_class_.init().get_type();
}

GType DataModelIter::get_base_type()
{
  return gda_data_model_iter_get_type();
}


DataModelIter::DataModelIter(const Glib::RefPtr<DataModel>& data_model)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  ParameterList(Glib::ConstructParams(datamodeliter_class_.init(), "data_model", Glib::unwrap(data_model), static_cast<char*>(0)))
{
  

}

Glib::RefPtr<DataModelIter> DataModelIter::create(const Glib::RefPtr<DataModel>& data_model)
{
  return Glib::RefPtr<DataModelIter>( new DataModelIter(data_model) );
}
bool DataModelIter::is_valid() const
{
  return gda_data_model_iter_is_valid(const_cast<GdaDataModelIter*>(gobj()));
}

bool DataModelIter::set_at_row(int row)
{
  return gda_data_model_iter_set_at_row(gobj(), row);
}

bool DataModelIter::move_next()
{
  return gda_data_model_iter_move_next(gobj());
}

bool DataModelIter::move_prev()
{
  return gda_data_model_iter_move_prev(gobj());
}

int DataModelIter::get_row() const
{
  return gda_data_model_iter_get_row(const_cast<GdaDataModelIter*>(gobj()));
}

void DataModelIter::invalidate_contents()
{
gda_data_model_iter_invalidate_contents(gobj()); 
}

int DataModelIter::get_column_for_param(const Glib::RefPtr<Parameter>& param)
{
  return gda_data_model_iter_get_column_for_param(gobj(), Glib::unwrap(param));
}

Glib::RefPtr<Parameter> DataModelIter::get_param_for_column(int col)
{

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

}

Glib::RefPtr<const Parameter> DataModelIter::get_param_for_column(int col) const
{
  return const_cast<DataModelIter*>(this)->get_param_for_column(col);
}


Glib::SignalProxy0< void > DataModelIter::signal_end_of_data()
{
  return Glib::SignalProxy0< void >(this, &DataModelIter_signal_end_of_data_info);
}


Glib::SignalProxy1< void,int > DataModelIter::signal_row_changed()
{
  return Glib::SignalProxy1< void,int >(this, &DataModelIter_signal_row_changed_info);
}


#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy<int> DataModelIter::property_current_row() 
{
  return Glib::PropertyProxy<int>(this, "current-row");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly<int> DataModelIter::property_current_row() const
{
  return Glib::PropertyProxy_ReadOnly<int>(this, "current-row");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<DataModel> > DataModelIter::property_data_model() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::RefPtr<DataModel> >(this, "data-model");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy< Glib::RefPtr<DataModel> > DataModelIter::property_forced_model() 
{
  return Glib::PropertyProxy< Glib::RefPtr<DataModel> >(this, "forced-model");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<DataModel> > DataModelIter::property_forced_model() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::RefPtr<DataModel> >(this, "forced-model");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy<bool> DataModelIter::property_update_model() 
{
  return Glib::PropertyProxy<bool>(this, "update-model");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly<bool> DataModelIter::property_update_model() const
{
  return Glib::PropertyProxy_ReadOnly<bool>(this, "update-model");
}
#endif //GLIBMM_PROPERTIES_ENABLED


#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
void Gnome::Gda::DataModelIter::on_end_of_data()
{
  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->end_of_data)
    (*base->end_of_data)(gobj());
}
void Gnome::Gda::DataModelIter::on_row_changed(int row)
{
  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->row_changed)
    (*base->row_changed)(gobj(),row);
}
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED


} // namespace Gda

} // namespace Gnome


