// Generated by gtkmmproc -- DO NOT MODIFY!


#include <libgdamm/parameterlist.h>
#include <libgdamm/private/parameterlist_p.h>

/* $Id: parameterlist.ccg,v 1.7 2006/11/06 04:38:05 murrayc Exp $ */
// -*- C++ -*- //

/* parameter.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-parameter-list.h>
#include <libgda/gda-parameter.h>
#include <libgda/gda-parameter-util.h>
#include <libgda/gda-enum-types.h>
#include <libgda/gda-dict.h>

namespace Gnome
{

namespace Gda
{

ParameterList::ParameterList(const Glib::RefPtr<Dict>& dict, const Glib::SListHandle<Parameter>& params) :
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Glib::Object(Glib::ConstructParams(parameterlist_class_.init(), "dict",dict->gobj(),"params",params.data(),NULL, static_cast<char*>(0)))
{

}

Glib::RefPtr<ParameterList> ParameterList::create(const Glib::SListHandle<Parameter>& params)
{
	Glib::RefPtr<Dict> dict(Glib::wrap(_gda_parameter_list_get_dict(params.data())));
	return Glib::RefPtr<ParameterList>(new ParameterList(dict, params));
}

Glib::RefPtr<ParameterList> ParameterList::create()
{
  return Glib::RefPtr<ParameterList>(Glib::wrap(gda_parameter_list_new(NULL)));
}

Value ParameterList::get_param_default_value(const Glib::RefPtr<const Parameter>& param) const
{
  return Value(gda_parameter_list_get_param_default_value(const_cast<GdaParameterList*>(gobj()), const_cast<GdaParameter*>(param->gobj())));
}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool ParameterList::restrict_param_by_name(const Glib::ustring& param_name, const Glib::RefPtr<DataModel>& model, int col)
#else
bool ParameterList::restrict_param_by_name(const Glib::ustring& param_name, const Glib::RefPtr<DataModel>& model, int col, std::auto_ptr<Glib::Error>& error)
#endif
{
  Glib::RefPtr<Parameter> param = find_param(param_name);
  if(!param) return false;

#ifdef GLIBMM_EXCEPTIONS_ENABLED
  return param->restrict_values(model, col);
#else
  return param->restrict_values(model, col, error);
#endif // GLIBMM_EXCEPTIONS_ENABLED
}

} //namespace Gda

} // namespace Gnome


namespace
{


static const Glib::SignalProxyInfo ParameterList_signal_public_data_changed_info =
{
  "public_data_changed",
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
};


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

static const Glib::SignalProxyInfo ParameterList_signal_param_plugin_changed_info =
{
  "param_plugin_changed",
  (GCallback) &ParameterList_signal_param_plugin_changed_callback,
  (GCallback) &ParameterList_signal_param_plugin_changed_callback
};


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

static const Glib::SignalProxyInfo ParameterList_signal_param_changed_info =
{
  "param_changed",
  (GCallback) &ParameterList_signal_param_changed_callback,
  (GCallback) &ParameterList_signal_param_changed_callback
};


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

static const Glib::SignalProxyInfo ParameterList_signal_param_attr_changed_info =
{
  "param_attr_changed",
  (GCallback) &ParameterList_signal_param_attr_changed_callback,
  (GCallback) &ParameterList_signal_param_attr_changed_callback
};


} // anonymous namespace


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

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

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

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

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


namespace Glib
{

Glib::RefPtr<Gnome::Gda::ParameterList> wrap(GdaParameterList* object, bool take_copy)
{
  return Glib::RefPtr<Gnome::Gda::ParameterList>( dynamic_cast<Gnome::Gda::ParameterList*> (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& ParameterList_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_ = &ParameterList_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_parameter_list_get_type());

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

  }

  return *this;
}

void ParameterList_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->public_data_changed = &public_data_changed_callback;
  klass->param_plugin_changed = &param_plugin_changed_callback;
  klass->param_changed = &param_changed_callback;
  klass->param_attr_changed = &param_attr_changed_callback;
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
}

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
void ParameterList_Class::public_data_changed_callback(GdaParameterList* 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);
}
void ParameterList_Class::param_plugin_changed_callback(GdaParameterList* self, GdaParameter* 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_param_plugin_changed(Glib::wrap(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->param_plugin_changed)
    (*base->param_plugin_changed)(self, p0);
}
void ParameterList_Class::param_changed_callback(GdaParameterList* self, GdaParameter* 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_param_changed(Glib::wrap(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->param_changed)
    (*base->param_changed)(self, p0);
}
void ParameterList_Class::param_attr_changed_callback(GdaParameterList* self, GdaParameter* 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_param_attr_changed(Glib::wrap(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->param_attr_changed)
    (*base->param_attr_changed)(self, p0);
}
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED


Glib::ObjectBase* ParameterList_Class::wrap_new(GObject* object)
{
  return new ParameterList((GdaParameterList*)object);
}


/* The implementation: */

GdaParameterList* ParameterList::gobj_copy()
{
  reference();
  return gobj();
}

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

}

ParameterList::ParameterList(GdaParameterList* castitem)
:
  Glib::Object((GObject*)(castitem))
{}

ParameterList::~ParameterList()
{}


ParameterList::CppClassType ParameterList::parameterlist_class_; // initialize static member

GType ParameterList::get_type()
{
  return parameterlist_class_.init().get_type();
}

GType ParameterList::get_base_type()
{
  return gda_parameter_list_get_type();
}


guint ParameterList::get_length()
{
  return gda_parameter_list_get_length(gobj());
}

void ParameterList::add_parameter(const Glib::RefPtr<Parameter>& param)
{
gda_parameter_list_add_param(gobj(), Glib::unwrap(param)); 
}

Glib::RefPtr<Parameter> ParameterList::add_parameter(const Glib::ustring& name, GType type, const Glib::ustring& str)
{

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

}

Glib::RefPtr<Parameter> ParameterList::add_parameter(const Glib::ustring& name, const Value& value)
{

  Glib::RefPtr<Parameter> retvalue = Glib::wrap(gda_parameter_list_add_param_from_value(gobj(), name.c_str(), const_cast<GValue*>((value).gobj())));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;

}

void ParameterList::merge(const Glib::RefPtr<ParameterList>& paramlist_to_merge)
{
gda_parameter_list_merge(gobj(), Glib::unwrap(paramlist_to_merge)); 
}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool ParameterList::is_coherent() const
#else
bool ParameterList::is_coherent(std::auto_ptr<Glib::Error>& error) const
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  bool retvalue = gda_parameter_list_is_coherent(const_cast<GdaParameterList*>(gobj()), &(gerror));
#ifdef GLIBMM_EXCEPTIONS_ENABLED
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
#else
  if(gerror)
    error = ::Glib::Error::throw_exception(gerror);
#endif //GLIBMM_EXCEPTIONS_ENABLED

  return retvalue;

}

bool ParameterList::is_valid() const
{
  return gda_parameter_list_is_valid(const_cast<GdaParameterList*>(gobj()));
}

Glib::RefPtr<Parameter> ParameterList::find_param(const Glib::ustring& param_name)
{

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

}

Glib::RefPtr<Parameter> ParameterList::find_param_for_user(const Glib::RefPtr<Gda::Object>& user)
{

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

}

void ParameterList::set_param_default_value(const Glib::RefPtr<const Parameter>& param, const Value& value)
{
gda_parameter_list_set_param_default_value(gobj(), const_cast<GdaParameter*>(Glib::unwrap(param)), (value).gobj()); 
}

void ParameterList::set_param_default_alias(const Glib::RefPtr<const Parameter>& param, const Glib::RefPtr<const Parameter>& alias)
{
gda_parameter_list_set_param_default_alias(gobj(), const_cast<GdaParameter*>(Glib::unwrap(param)), const_cast<GdaParameter*>(Glib::unwrap(alias))); 
}

Glib::ustring ParameterList::get_spec() const
{
  return Glib::convert_return_gchar_ptr_to_ustring(gda_parameter_list_get_spec(const_cast<GdaParameterList*>(gobj())));
}

guint ParameterList::get_length() const
{
  return gda_parameter_list_get_length(const_cast<GdaParameterList*>(gobj()));
}


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


Glib::SignalProxy1< void,Glib::RefPtr<Parameter> > ParameterList::signal_param_plugin_changed()
{
  return Glib::SignalProxy1< void,Glib::RefPtr<Parameter> >(this, &ParameterList_signal_param_plugin_changed_info);
}


Glib::SignalProxy1< void,Glib::RefPtr<Parameter> > ParameterList::signal_param_changed()
{
  return Glib::SignalProxy1< void,Glib::RefPtr<Parameter> >(this, &ParameterList_signal_param_changed_info);
}


Glib::SignalProxy1< void,Glib::RefPtr<Parameter> > ParameterList::signal_param_attr_changed()
{
  return Glib::SignalProxy1< void,Glib::RefPtr<Parameter> >(this, &ParameterList_signal_param_attr_changed_info);
}


#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
void Gnome::Gda::ParameterList::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());
}
void Gnome::Gda::ParameterList::on_param_plugin_changed(Glib::RefPtr<Parameter> parameter)
{
  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->param_plugin_changed)
    (*base->param_plugin_changed)(gobj(),Glib::unwrap(parameter));
}
void Gnome::Gda::ParameterList::on_param_changed(Glib::RefPtr<Parameter> parameter)
{
  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->param_changed)
    (*base->param_changed)(gobj(),Glib::unwrap(parameter));
}
void Gnome::Gda::ParameterList::on_param_attr_changed(Glib::RefPtr<Parameter> parameter)
{
  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->param_attr_changed)
    (*base->param_attr_changed)(gobj(),Glib::unwrap(parameter));
}
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED


} // namespace Gda

} // namespace Gnome


