// -*- C++ -*- //

/* batch.h
 *
 * Copyright 2006 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 <libgdamm/holder.h>
#include <libgdamm/statement.h>

_DEFS(libgdamm,libgda)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gnome
{

namespace Gda
{

/** Multiple SQL statements grouped together.
 *
 * The Gda::Batch object represents one or more SQL statements (as Gda::Statement objects) in a single object.
 * A Gda::Batch can either be built "manually" by assembling together several Gda::Statement objects, or from an 
 * SQL string using a Gda::SqlParser object.
 *
 * @ingroup DataHandlers
 */
class Batch : public Glib::Object
{
  _CLASS_GOBJECT(Batch, GdaBatch, GDA_BATCH, Glib::Object, GObject)
protected:
  _CTOR_DEFAULT()
public:
  _WRAP_CREATE()
  _WRAP_METHOD(Glib::RefPtr<Batch> copy(), gda_batch_copy)  
  
  _WRAP_METHOD(void add_statement(const Glib::RefPtr<Statement>& stmt), gda_batch_add_statement)
  _WRAP_METHOD(void remove_statement(const Glib::RefPtr<Statement>& stmt), gda_batch_remove_statement)
  _WRAP_METHOD(Glib::ustring serialize() const, gda_batch_serialize)

  typedef std::vector<Glib::RefPtr<const Statement> > StatementVector;

  //There is no non-const override for this, because the C function returns const items.
  #m4 _CONVERSION(`const GSList*',`StatementVector',`$2(Glib::SListHandler<Glib::RefPtr<const Statement> >::slist_to_vector((GSList*)$3, Glib::OWNERSHIP_NONE))')
  _WRAP_METHOD(StatementVector get_statements() const, gda_batch_get_statements)

  _WRAP_METHOD_DOCS_ONLY(gda_statement_get_parameters)
  bool get_parameters(Glib::RefPtr<Set>& out_params);
    
  // FIXME: Use better marshaller in libgda. TODO: Bug number?
  #m4 _CONVERSION(`GObject*',`Glib::RefPtr<Statement>',`Glib::wrap(GDA_STATEMENT($3))')
  _WRAP_SIGNAL(void changed(Glib::RefPtr<Statement> stmt), "changed", no_default_handler)
};

} // namespace Gda
} // namespace Gnome

