// -*- c++ -*-
// Generated by gtkmmproc -- DO NOT MODIFY!
#ifndef _LIBGDAMM_COMMAND_H
#define _LIBGDAMM_COMMAND_H

#include <glibmm.h>

/* $Id: command.hg,v 1.5 2004/04/29 23:07:13 murrayc Exp $ */
// -*- C++ -*- // this is for the .hg, I realize gensig puts one in

/* command.h
 *
 * 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/transaction.h>
#include <glibmm/object.h>


#ifndef DOXYGEN_SHOULD_SKIP_THIS
extern "C" { typedef struct _GdaCommand GdaCommand; } 
#endif

namespace Gnome
{

namespace Gda
{

/** @addtogroup libgdammEnums Enums and Flags */

/**
 * @ingroup libgdammEnums
 */
enum CommandType
{
  COMMAND_TYPE_SQL,
  COMMAND_TYPE_XML,
  COMMAND_TYPE_PROCEDURE,
  COMMAND_TYPE_TABLE,
  COMMAND_TYPE_SCHEMA,
  COMMAND_TYPE_INVALID
};

} // namespace Gda

} // namespace Gnome


#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace Glib
{

template <>
class Value<Gnome::Gda::CommandType> : public Glib::Value_Enum<Gnome::Gda::CommandType>
{
public:
  static GType value_type() G_GNUC_CONST;
};

} // namespace Glib
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


namespace Gnome
{

namespace Gda
{

/**
 * @ingroup libgdammEnums
 * @par Bitwise operators:
 * <tt>%CommandOptions operator|(CommandOptions, CommandOptions)</tt><br>
 * <tt>%CommandOptions operator&(CommandOptions, CommandOptions)</tt><br>
 * <tt>%CommandOptions operator^(CommandOptions, CommandOptions)</tt><br>
 * <tt>%CommandOptions operator~(CommandOptions)</tt><br>
 * <tt>%CommandOptions& operator|=(CommandOptions&, CommandOptions)</tt><br>
 * <tt>%CommandOptions& operator&=(CommandOptions&, CommandOptions)</tt><br>
 * <tt>%CommandOptions& operator^=(CommandOptions&, CommandOptions)</tt><br>
 */
enum CommandOptions
{
  COMMAND_OPTION_IGNORE_ERRORS = 1,
  COMMAND_OPTION_STOP_ON_ERRORS = 1 << 1,
  COMMAND_OPTION_BAD_OPTION = 1 << 2
};

/** @ingroup libgdammEnums */
inline CommandOptions operator|(CommandOptions lhs, CommandOptions rhs)
  { return static_cast<CommandOptions>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }

/** @ingroup libgdammEnums */
inline CommandOptions operator&(CommandOptions lhs, CommandOptions rhs)
  { return static_cast<CommandOptions>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }

/** @ingroup libgdammEnums */
inline CommandOptions operator^(CommandOptions lhs, CommandOptions rhs)
  { return static_cast<CommandOptions>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }

/** @ingroup libgdammEnums */
inline CommandOptions operator~(CommandOptions flags)
  { return static_cast<CommandOptions>(~static_cast<unsigned>(flags)); }

/** @ingroup libgdammEnums */
inline CommandOptions& operator|=(CommandOptions& lhs, CommandOptions rhs)
  { return (lhs = static_cast<CommandOptions>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }

/** @ingroup libgdammEnums */
inline CommandOptions& operator&=(CommandOptions& lhs, CommandOptions rhs)
  { return (lhs = static_cast<CommandOptions>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }

/** @ingroup libgdammEnums */
inline CommandOptions& operator^=(CommandOptions& lhs, CommandOptions rhs)
  { return (lhs = static_cast<CommandOptions>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }

} // namespace Gda

} // namespace Gnome


#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace Glib
{

template <>
class Value<Gnome::Gda::CommandOptions> : public Glib::Value_Flags<Gnome::Gda::CommandOptions>
{
public:
  static GType value_type() G_GNUC_CONST;
};

} // namespace Glib
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


namespace Gnome
{

namespace Gda
{


class Command
{
  public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  typedef Command CppObjectType;
  typedef GdaCommand BaseObjectType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

  Command();

  // Use make_a_copy=true when getting it directly from a struct.
  explicit Command(GdaCommand* castitem, bool make_a_copy = false);

  Command(const Command& src);
  Command& operator=(const Command& src);

  ~Command();

  GdaCommand*       gobj()       { return gobject_; }
  const GdaCommand* gobj() const { return gobject_; }

  ///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
  GdaCommand* gobj_copy() const;

protected:
  GdaCommand* gobject_;

private:

  
public:
  //TODO: What do the other command types do? How do they work?
  explicit Command(const Glib::ustring& text, CommandType type = COMMAND_TYPE_SQL, CommandOptions options = COMMAND_OPTION_STOP_ON_ERRORS); //TODO: Good defaults.
 
  
  Glib::ustring get_text() const;
  
  void set_text(const Glib::ustring& text);
  
  CommandType get_command_type() const;
  
  void set_command_type(CommandType type);
  
  CommandOptions get_options() const;
  
  void set_options(CommandOptions options);
  
  Glib::RefPtr<Transaction> get_transaction();
  
  Glib::RefPtr<const Transaction> get_transaction() const;
  
  void set_transaction(const Glib::RefPtr<Transaction>& xaction);


};

} // namespace Gda
} // namespace Gnome


namespace Glib
{

  /** @relates Gnome::Gda::Command
   * @param object The C instance
   * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
   * @result A C++ instance that wraps this C instance.
   */
Gnome::Gda::Command wrap(GdaCommand* object, bool take_copy = false);

} // namespace Glib

#endif /* _LIBGDAMM_COMMAND_H */

