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


#include <glibmm.h>

#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 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-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());
}

void Gnome::Gda::DataModelIterError::throw_func(GError* gobject)
{
  throw Gnome::Gda::DataModelIterError(gobject);
}

// 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);


  klass->end_of_data = &end_of_data_callback;
  klass->row_changed = &row_changed_callback;
}


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);
}


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)
:
  Set(construct_params)
{

}

DataModelIter::DataModelIter(GdaDataModelIter* castitem)
:
  Set((GdaSet*)(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),
  Set(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::move_next()
{
  return gda_data_model_iter_move_next(gobj());
}

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

bool DataModelIter::move_to_row(int row)
{
  return gda_data_model_iter_move_to_row(gobj(), row);
}

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());
}

Glib::RefPtr<Holder> DataModelIter::get_holder_for_field(int col)
{
  Glib::RefPtr<Holder> retvalue = Glib::wrap(gda_data_model_iter_get_holder_for_field(gobj(), col));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

Glib::RefPtr<const Holder> DataModelIter::get_holder_for_field(int col) const
{
  Glib::RefPtr<const Holder> retvalue = Glib::wrap(gda_data_model_iter_get_holder_for_field(const_cast<GdaDataModelIter*>(gobj()), col));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

Value DataModelIter::get_value_at(int col) const
{
  GError* gerror = 0;
  Value retvalue = Value(gda_data_model_iter_get_value_at_e(const_cast<GdaDataModelIter*>(gobj()), col, &(gerror)));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

Value DataModelIter::get_value_for_field(const Glib::ustring& field_name) const
{
  return Value(gda_data_model_iter_get_value_for_field(const_cast<GdaDataModelIter*>(gobj()), field_name.c_str()));
}

bool DataModelIter::set_value_at(int col, const Value& value)
{
  GError* gerror = 0;
  bool retvalue = gda_data_model_iter_set_value_at(gobj(), col, (value).gobj(), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}


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


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);
}


} // namespace Gda

} // namespace Gnome


