// Generated by gtkmmproc -- DO NOT MODIFY!


#include <libgdamm/command.h>
#include <libgdamm/private/command_p.h>

/* $Id: command.ccg,v 1.2 2004/03/30 21:46:24 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 <libgda/gda-data-model.h>
#include <libgda/gda-enum-types.h>

namespace Gnome
{

namespace Gda
{

Command::Command(const Glib::ustring& text, CommandType type, CommandOptions options)
: gobject_( gda_command_new(text.c_str(), (GdaCommandType)type, (GdaCommandOptions)options) )
{
  
}

} // namespace Gda

} // namespace Gnome


namespace
{
} // anonymous namespace

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

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


namespace Glib
{

Gnome::Gda::Command wrap(GdaCommand* object, bool take_copy /* = false */)
{
  return Gnome::Gda::Command(object, take_copy);
}

} // namespace Glib


namespace Gnome
{

namespace Gda
{


Command::Command()
:
  gobject_ (0) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
{}

Command::Command(const Command& src)
:
  gobject_ ((src.gobject_) ? gda_command_copy(src.gobject_) : 0)
{}

Command::Command(GdaCommand* castitem, bool make_a_copy /* = false */)
{
  if(!make_a_copy)
  {
    // It was given to us by a function which has already made a copy for us to keep.
    gobject_ = castitem;
  }
  else
  {
    // We are probably getting it via direct access to a struct,
    // so we can not just take it - we have to take a copy of it.
    if(castitem)
      gobject_ = gda_command_copy(castitem);
    else
      gobject_ = 0;
  }
}

Command& Command::operator=(const Command& src)
{
  GdaCommand *const new_gobject = (src.gobject_) ? gda_command_copy(src.gobject_) : 0;

  if(gobject_)
    gda_command_free(gobject_);

  gobject_ = new_gobject;

  return *this;
}

Command::~Command()
{
  if(gobject_)
    gda_command_free(gobject_);
}

GdaCommand* Command::gobj_copy() const
{
  return gda_command_copy(gobject_);
}


Glib::ustring Command::get_text() const
{
  return Glib::convert_const_gchar_ptr_to_ustring(gda_command_get_text(const_cast<GdaCommand*>(gobj())));
}

void Command::set_text(const Glib::ustring& text)
{
gda_command_set_text(gobj(), text.c_str()); 
}

CommandType Command::get_command_type() const
{
  return ((CommandType)(gda_command_get_command_type(const_cast<GdaCommand*>(gobj()))));
}

void Command::set_command_type(CommandType type)
{
gda_command_set_command_type(gobj(), ((GdaCommandType)(type))); 
}

CommandOptions Command::get_options() const
{
  return ((CommandOptions)(gda_command_get_options(const_cast<GdaCommand*>(gobj()))));
}

void Command::set_options(CommandOptions options)
{
gda_command_set_options(gobj(), ((GdaCommandOptions)(options))); 
}


} // namespace Gda

} // namespace Gnome


