// Generated by gtkmmproc -- DO NOT MODIFY!


#include <libgdamm/queryjoin.h>
#include <libgdamm/private/queryjoin_p.h>

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

/* queryjoin.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-enum-types.h>
#include <libgda/gda-query-join.h>

#include <libgdamm/query.h>
#include <libgdamm/querycondition.h>

namespace Gnome
{

namespace Gda
{

QueryJoin::QueryJoin(const Glib::RefPtr<Query>& query, const Glib::RefPtr<QueryTarget>& target_1, const Glib::RefPtr<QueryTarget>& target_2)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  QueryObject(Glib::ConstructParams(queryjoin_class_.init(), "dict",gda_object_get_dict(GDA_OBJECT(query->gobj())),"query",Glib::unwrap(query),"target1",Glib::unwrap(target_1),"target2",Glib::unwrap(target_2), static_cast<char*>(0)))
{
}

QueryJoin::QueryJoin(const Glib::RefPtr<Query>& query, const Glib::ustring& target_1_xml_id, const Glib::ustring& target_2_xml_id)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  QueryObject(Glib::ConstructParams(queryjoin_class_.init(), "dict",gda_object_get_dict(GDA_OBJECT(query->gobj())),"query",Glib::unwrap(query),"target1-id",target_1_xml_id.c_str(),"target2-id",target_2_xml_id.c_str(), static_cast<char*>(0)))
{
}

} /* namespace Gda */

} /* namespace Gnome */


namespace
{


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


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


} // anonymous namespace

// static
GType Glib::Value<Gnome::Gda::QueryJoinType>::value_type()
{
  return gda_query_join_type_get_type();
}


namespace Glib
{

Glib::RefPtr<Gnome::Gda::QueryJoin> wrap(GdaQueryJoin* object, bool take_copy)
{
  return Glib::RefPtr<Gnome::Gda::QueryJoin>( dynamic_cast<Gnome::Gda::QueryJoin*> (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& QueryJoin_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_ = &QueryJoin_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_query_join_get_type());

    // Add derived versions of interfaces, if the C type implements any interfaces:
  XmlStorage::add_interface(get_type());
  Referer::add_interface(get_type());

  }

  return *this;
}

void QueryJoin_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->condition_changed = &condition_changed_callback;
  klass->type_changed = &type_changed_callback;
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
}

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
void QueryJoin_Class::condition_changed_callback(GdaQueryJoin* 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_condition_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->condition_changed)
    (*base->condition_changed)(self);
}
void QueryJoin_Class::type_changed_callback(GdaQueryJoin* 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_type_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->type_changed)
    (*base->type_changed)(self);
}
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED


Glib::ObjectBase* QueryJoin_Class::wrap_new(GObject* object)
{
  return new QueryJoin((GdaQueryJoin*)object);
}


/* The implementation: */

GdaQueryJoin* QueryJoin::gobj_copy()
{
  reference();
  return gobj();
}

QueryJoin::QueryJoin(const Glib::ConstructParams& construct_params)
:
  QueryObject(construct_params)
{

}

QueryJoin::QueryJoin(GdaQueryJoin* castitem)
:
  QueryObject((GdaQueryObject*)(castitem))
{}

QueryJoin::~QueryJoin()
{}


QueryJoin::CppClassType QueryJoin::queryjoin_class_; // initialize static member

GType QueryJoin::get_type()
{
  return queryjoin_class_.init().get_type();
}

GType QueryJoin::get_base_type()
{
  return gda_query_join_get_type();
}


Glib::RefPtr<QueryJoin> QueryJoin::create(const Glib::RefPtr<Query>& query, const Glib::RefPtr<QueryTarget>& target_1, const Glib::RefPtr<QueryTarget>& target_2)
{
  return Glib::RefPtr<QueryJoin>( new QueryJoin(query, target_1, target_2) );
}
Glib::RefPtr<QueryJoin> QueryJoin::create(const Glib::RefPtr<Query>& query, const Glib::ustring& target_1_xml_id, const Glib::ustring& target_2_xml_id)
{
  return Glib::RefPtr<QueryJoin>( new QueryJoin(query, target_1_xml_id, target_2_xml_id) );
}
void QueryJoin::set_join_type(QueryJoinType type)
{
gda_query_join_set_join_type(gobj(), ((GdaQueryJoinType)(type))); 
}

QueryJoinType QueryJoin::get_join_type() const
{
  return ((QueryJoinType)(gda_query_join_get_join_type(const_cast<GdaQueryJoin*>(gobj()))));
}

Glib::RefPtr<Query> QueryJoin::get_query()
{

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

}

Glib::RefPtr<const Query> QueryJoin::get_query() const
{
  return const_cast<QueryJoin*>(this)->get_query();
}

Glib::RefPtr<QueryTarget> QueryJoin::get_target_1()
{

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

}

Glib::RefPtr<const QueryTarget> QueryJoin::get_target_1() const
{
  return const_cast<QueryJoin*>(this)->get_target_1();
}

Glib::RefPtr<QueryTarget> QueryJoin::get_target_2()
{

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

}

Glib::RefPtr<const QueryTarget> QueryJoin::get_target_2() const
{
  return const_cast<QueryJoin*>(this)->get_target_2();
}

void QueryJoin::swap_targets()
{
gda_query_join_swap_targets(gobj()); 
}

bool QueryJoin::set_condition_from_fkcons()
{
  return gda_query_join_set_condition_from_fkcons(gobj());
}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool QueryJoin::set_condition_from_sql(const Glib::ustring& cond)
#else
bool QueryJoin::set_condition_from_sql(const Glib::ustring& cond, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  bool retvalue = gda_query_join_set_condition_from_sql(gobj(), cond.c_str(), &(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 QueryJoin::set_condition(const Glib::RefPtr<QueryCondition>& cond)
{
  return gda_query_join_set_condition(gobj(), Glib::unwrap(cond));
}

Glib::RefPtr<QueryCondition> QueryJoin::get_condition()
{

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

}

Glib::RefPtr<const QueryCondition> QueryJoin::get_condition() const
{
  return const_cast<QueryJoin*>(this)->get_condition();
}

Glib::ustring QueryJoin::render_type() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gda_query_join_render_type(const_cast<GdaQueryJoin*>(gobj())));
}


Glib::SignalProxy0< void > QueryJoin::signal_condition_changed()
{
  return Glib::SignalProxy0< void >(this, &QueryJoin_signal_condition_changed_info);
}


Glib::SignalProxy0< void > QueryJoin::signal_type_changed()
{
  return Glib::SignalProxy0< void >(this, &QueryJoin_signal_type_changed_info);
}


#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Query> > QueryJoin::property_query() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Query> >(this, "query");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy< Glib::RefPtr<QueryTarget> > QueryJoin::property_target1() 
{
  return Glib::PropertyProxy< Glib::RefPtr<QueryTarget> >(this, "target1");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<QueryTarget> > QueryJoin::property_target1() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::RefPtr<QueryTarget> >(this, "target1");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_WriteOnly<Glib::ustring> QueryJoin::property_target1_id() 
{
  return Glib::PropertyProxy_WriteOnly<Glib::ustring>(this, "target1-id");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy< Glib::RefPtr<QueryTarget> > QueryJoin::property_target2() 
{
  return Glib::PropertyProxy< Glib::RefPtr<QueryTarget> >(this, "target2");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<QueryTarget> > QueryJoin::property_target2() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::RefPtr<QueryTarget> >(this, "target2");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_WriteOnly<Glib::ustring> QueryJoin::property_target2_id() 
{
  return Glib::PropertyProxy_WriteOnly<Glib::ustring>(this, "target2-id");
}
#endif //GLIBMM_PROPERTIES_ENABLED


#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
void Gnome::Gda::QueryJoin::on_condition_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->condition_changed)
    (*base->condition_changed)(gobj());
}
void Gnome::Gda::QueryJoin::on_type_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->type_changed)
    (*base->type_changed)(gobj());
}
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED


} // namespace Gda

} // namespace Gnome


