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


#include <glibmm.h>

#include <libgdamm/xatransaction.h>
#include <libgdamm/private/xatransaction_p.h>


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

/* xatransaction.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-xa-transaction.h>

namespace Gnome
{

namespace Gda
{

typedef std::vector< Glib::RefPtr<Connection> > ConnectionVector;
  
bool XaTransaction::commit(ConnectionVector& cncs_to_recover)
{
  GError* gerror = 0;
  GSList* cncs = NULL;
  const bool retvalue = gda_xa_transaction_commit (gobj(), &cncs, &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

  cncs_to_recover = Glib::SListHandler< Glib::RefPtr<const Connection> >::slist_to_vector(cncs, Glib::OWNERSHIP_SHALLOW);
  
  return retvalue;
}

bool XaTransaction::commit_recovered(ConnectionVector& cncs_to_recover)
{
  GError* gerror = 0;
  GSList* cncs = NULL;
  bool retvalue = gda_xa_transaction_commit_recovered (gobj(), &cncs, &gerror);
  if(gerror)
    ::Glib::Error::throw_exception(gerror);

   cncs_to_recover = Glib::SListHandler< Glib::RefPtr<const Connection> >::slist_to_vector(cncs, Glib::OWNERSHIP_SHALLOW);
  
  return retvalue;
}

}

} /* namespace Gnome */


namespace
{
} // anonymous namespace


namespace Glib
{

Glib::RefPtr<Gnome::Gda::XaTransaction> wrap(GdaXaTransaction* object, bool take_copy)
{
  return Glib::RefPtr<Gnome::Gda::XaTransaction>( dynamic_cast<Gnome::Gda::XaTransaction*> (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& XaTransaction_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_ = &XaTransaction_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_xa_transaction_get_type());

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

  }

  return *this;
}


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


}


Glib::ObjectBase* XaTransaction_Class::wrap_new(GObject* object)
{
  return new XaTransaction((GdaXaTransaction*)object);
}


/* The implementation: */

GdaXaTransaction* XaTransaction::gobj_copy()
{
  reference();
  return gobj();
}

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

}

XaTransaction::XaTransaction(GdaXaTransaction* castitem)
:
  Glib::Object((GObject*)(castitem))
{}


XaTransaction::~XaTransaction()
{}


XaTransaction::CppClassType XaTransaction::xatransaction_class_; // initialize static member

GType XaTransaction::get_type()
{
  return xatransaction_class_.init().get_type();
}


GType XaTransaction::get_base_type()
{
  return gda_xa_transaction_get_type();
}


XaTransaction::XaTransaction(guint32 format_id, const Glib::ustring& transaction_id)
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Glib::Object(Glib::ConstructParams(xatransaction_class_.init(), "format_id", format_id, "transaction_id", transaction_id.c_str(), static_cast<char*>(0)))
{
  

}

Glib::RefPtr<XaTransaction> XaTransaction::create(guint32 format_id, const Glib::ustring& transaction_id)
{
  return Glib::RefPtr<XaTransaction>( new XaTransaction(format_id, transaction_id) );
}

bool XaTransaction::register_connection(const Glib::RefPtr<Connection>& cnc, const Glib::ustring& branch)
{
  GError* gerror = 0;
  bool retvalue = gda_xa_transaction_register_connection(gobj(), Glib::unwrap(cnc), branch.c_str(), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

void XaTransaction::unregister_connection(const Glib::RefPtr<Connection>& cnc)
{
  gda_xa_transaction_unregister_connection(gobj(), Glib::unwrap(cnc));
}

bool XaTransaction::begin()
{
  GError* gerror = 0;
  bool retvalue = gda_xa_transaction_begin(gobj(), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

bool XaTransaction::rollback()
{
  GError* gerror = 0;
  bool retvalue = gda_xa_transaction_rollback(gobj(), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}


#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly< Glib::ustring > XaTransaction::property_transaction_id() const
{
  return Glib::PropertyProxy_ReadOnly< Glib::ustring >(this, "transaction-id");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly< guint > XaTransaction::property_format_id() const
{
  return Glib::PropertyProxy_ReadOnly< guint >(this, "format-id");
}
#endif //GLIBMM_PROPERTIES_ENABLED


} // namespace Gda

} // namespace Gnome


