// Generated by gtkmmproc -- DO NOT MODIFY!


#include <libgdamm/datamodelquery.h>
#include <libgdamm/private/datamodelquery_p.h>

/* $Id: datamodelquery.ccg,v 1.1 2006/12/15 15:02:27 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 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 <libgdamm/serverprovider.h>
#include <libgda/gda-data-model-query.h>
#include <libgda/gda-enum-types.h>


namespace Gnome
{

namespace Gda
{

DataModelQuery::DataModelQuery(const Glib::RefPtr<Gda::Query>& query)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Object(Glib::ConstructParams(datamodelquery_class_.init(), "query",Glib::unwrap(query),"dict",gda_object_get_dict(GDA_OBJECT(query->gobj())), static_cast<char*>(0)))
{
}


} /* namespace Gda */

} /* namespace Gnome */


namespace
{
} // anonymous namespace


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

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

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

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

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

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


namespace Glib
{

Glib::RefPtr<Gnome::Gda::DataModelQuery> wrap(GdaDataModelQuery* object, bool take_copy)
{
  return Glib::RefPtr<Gnome::Gda::DataModelQuery>( dynamic_cast<Gnome::Gda::DataModelQuery*> (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& DataModelQuery_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_ = &DataModelQuery_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_query_get_type());

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

  }

  return *this;
}

void DataModelQuery_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
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
}

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED


Glib::ObjectBase* DataModelQuery_Class::wrap_new(GObject* object)
{
  return new DataModelQuery((GdaDataModelQuery*)object);
}


/* The implementation: */

GdaDataModelQuery* DataModelQuery::gobj_copy()
{
  reference();
  return gobj();
}

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

}

DataModelQuery::DataModelQuery(GdaDataModelQuery* castitem)
:
  Object((GdaObject*)(castitem))
{}

DataModelQuery::~DataModelQuery()
{}


DataModelQuery::CppClassType DataModelQuery::datamodelquery_class_; // initialize static member

GType DataModelQuery::get_type()
{
  return datamodelquery_class_.init().get_type();
}

GType DataModelQuery::get_base_type()
{
  return gda_data_model_query_get_type();
}


Glib::RefPtr<DataModelQuery> DataModelQuery::create(Glib::RefPtr<Query>& query)
{
  return Glib::RefPtr<DataModelQuery>( new DataModelQuery(query) );
}
Glib::RefPtr<ParameterList> DataModelQuery::get_parameter_list()
{

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

}

Glib::RefPtr<const ParameterList> DataModelQuery::get_parameter_list() const
{
  return const_cast<DataModelQuery*>(this)->get_parameter_list();
}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool DataModelQuery::query_refresh()
#else
bool DataModelQuery::query_refresh(std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  bool retvalue = gda_data_model_query_refresh(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;

}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool DataModelQuery::set_modification_query(const Glib::ustring& query)
#else
bool DataModelQuery::set_modification_query(const Glib::ustring& query, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  bool retvalue = gda_data_model_query_set_modification_query(gobj(), query.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;

}

#ifdef GLIBMM_EXCEPTIONS_ENABLED
bool DataModelQuery::compute_modification_queries(const Glib::ustring& target, DataModelQueryOptions options)
#else
bool DataModelQuery::compute_modification_queries(const Glib::ustring& target, DataModelQueryOptions options, std::auto_ptr<Glib::Error>& error)
#endif //GLIBMM_EXCEPTIONS_ENABLED
{
  GError* gerror = 0;
  bool retvalue = gda_data_model_query_compute_modification_queries(gobj(), target.c_str(), ((GdaDataModelQueryOptions)(options)), &(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;

}


#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED


} // namespace Gda

} // namespace Gnome


