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

#include <glibmm.h>

/* $Id: datamodel.hg,v 1.15 2004/06/06 16:32:45 murrayc Exp $ */
// -*- C++ -*- // this is for the .hg, I realize gensig puts one in

/* datamodel.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 <glibmm/object.h>
#include <libgdamm/command.h>
#include <libgdamm/row.h>
#include <libgdamm/fieldattributes.h>
#include <libgda/gda-data-model.h>


#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GdaDataModel GdaDataModel;
typedef struct _GdaDataModelClass GdaDataModelClass;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


namespace Gnome
{

namespace Gda
{ class DataModel_Class; } // namespace Gda

} // namespace Gnome
namespace Gnome
{

namespace Gda
{

class Row;


class DataModel : public Glib::Object
{
  
#ifndef DOXYGEN_SHOULD_SKIP_THIS

public:
  typedef DataModel CppObjectType;
  typedef DataModel_Class CppClassType;
  typedef GdaDataModel BaseObjectType;
  typedef GdaDataModelClass BaseClassType;

private:  friend class DataModel_Class;
  static CppClassType datamodel_class_;

private:
  // noncopyable
  DataModel(const DataModel&);
  DataModel& operator=(const DataModel&);

protected:
  explicit DataModel(const Glib::ConstructParams& construct_params);
  explicit DataModel(GdaDataModel* castitem);

#endif /* DOXYGEN_SHOULD_SKIP_THIS */

public:
  virtual ~DataModel();

#ifndef DOXYGEN_SHOULD_SKIP_THIS
  static GType get_type()      G_GNUC_CONST;
  static GType get_base_type() G_GNUC_CONST;
#endif

  ///Provides access to the underlying C GObject.
  GdaDataModel*       gobj()       { return reinterpret_cast<GdaDataModel*>(gobject_); }

  ///Provides access to the underlying C GObject.
  const GdaDataModel* gobj() const { return reinterpret_cast<GdaDataModel*>(gobject_); }

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

private:

public:

  
  void changed();
  
  void row_inserted(int row);
  
  void row_updated(int row);
  
  void row_removed(int row);
  
  void column_inserted(int col);
  
  void column_updated(int col);
  
  void column_removed(int col);  
  
  void freeze();  
  
  void thaw();


  int get_n_rows() const;
  
  int get_n_columns() const;

  //TODO: Use C++ type:
  
  FieldAttributes describe_column(int col);
  
  Glib::ustring get_column_title(int col) const;
  
  void set_column_title(int col, const Glib::ustring& title);
  
  int get_column_position(const Glib::ustring& title) const;

  //We use a custom conversion here, because we need to copy the value:
   

  Row get_row(int row) const;

  //We use a custom conversion here, because we need to copy the value:
  //#m4 __CONVERSION(`GdaValue*',`Value',`Glib::wrap($3, true /* take_copy=true */)')
   

  Value get_value_at(int col, int row) const;


  bool is_updatable() const;

  //TODO: Use C++ types:
  
  const GdaRow* append_row(const GList *values);
  
  bool remove_row(const Row& row);
  
  bool update_row(const Row& row);

  
  bool append_column(const FieldAttributes& col);
  
  bool update_column(int col, const FieldAttributes& attrs);
  
  bool remove_column(int col);
              
  /** For example,
   * void on_foreach(const Row& row);
   */
  typedef sigc::slot<bool, const Row&> SlotForEach;
  
  void foreach(const SlotForEach& slot);
  
  
  bool has_changed() const;
  
  bool begin_update();
  
  bool cancel_update();
  
  bool end_update();


  Glib::ustring to_comma_separated() const;
  
  Glib::ustring to_tab_separated() const;
  
  Glib::ustring to_xml(bool standalone) const;


  //TODO: Wrap these if we want to depend on libxml++
  //_WRAP_METHOD(xmlNodePtr to_xml(const GLib::ustring& name), gda_data_model_to_xml_node)
  //_WRAP_METHOD(bool add_data(xmlNodePtr node), gda_data_model_add_data_from_xml_node)


  Glib::ustring get_command_text() const;
  
  void set_command_text(const Glib::ustring& txt);
  
  CommandType get_command_type() const;
  
  void set_command_type(CommandType type);

  
  Glib::SignalProxy0< void > signal_changed();


    virtual int get_n_rows_vfunc();
    virtual int get_n_columns_vfunc();
    virtual GdaFieldAttributes* describe_column_vfunc(int col);
    virtual const GdaValue* get_value_at_vfunc(int col, int row);


public:

public:
  //C++ methods used to invoke GTK+ virtual functions:

protected:
  //GTK+ Virtual Functions (override these to change behaviour):

  //Default Signal Handlers::
  virtual void on_changed();


};

} // namespace Gda
} // namespace Gnome


namespace Glib
{
  /** @relates Gnome::Gda::DataModel
   * @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.
   */
  Glib::RefPtr<Gnome::Gda::DataModel> wrap(GdaDataModel* object, bool take_copy = false);
}


#endif /* _LIBGDAMM_DATAMODEL_H */

